Active noise control

hello. im trying to make a program that could do some active noise reduction

for that i need to change a phase of the sound wave i get from microphone. any ideas?
so far i only made a microphone code.

void Start()
    {
        AudioSource audio = GetComponent<AudioSource>();
        audio.clip = Microphone.Start(null, true, 1, 22050);
        audio.loop = true;
        while (!(Microphone.GetPosition(null) > 0)) { }
        audio.Play();

    }

alt text

How did it go? I think if you simply invert the phase without considering the delay, there will be a howling.