I have this question, which can also be found at http://stackoverflow.com/questions/17744053/noise-cancellation-setup-combining-the-microphones-signals-intelligently. There you can also find more detail information + pictures.

Maybe it's interesting for you and you can help.

I built a noise cancellation setup with two microphones and two different microphone preamplifiers that go to two different channels of a stereo recording.

Here is a sample I'd use as "Datei"

http://filestore.to/?d=U5FN2IH96K

I tried

   /static void *voneinanderabziehen( char *Datei)//
   //{//
   //  char ergebnis[80]; //
   //  sprintf(ergebnis,"%s.neu.raw",Datei);//
   //  FILE* ausgabe = fopen(ergebnis, "wb");//
   //  FILE* f = fopen(Datei, "rb"); //
   //  if (f == NULL)//
   //    return;//
   //  int i = -1;//
   //  int r1 = 0;//
   //  int r2 = 0;//
   //  int l1 = 0;//
   //  int l2 = 0;//
   //  int zaehler = 0;//
   //  int l = 0;//
   //  int r = 0;//
   //  int wo = 0;//
   //  int dif = 0;//
   //  float g = 0.1;//
   //  float RC = 1.0/(1215*2*3.14);//
   //  float dt = 1.0/44100;//
   //  float alpha = dt/(RC+dt);//
   //  float beginn = 0;//
   //  float vorher = 0;//
   //  int jetzt = 0;//
   ////
   //  while(wo !=EOF)//
   //  {//
   //    wo = getc(f);//
   //    if (zaehler == 0)//
   //      beginn = wo;//
   //    zaehler++;//
   ////
   //  } //
   ////  printf("zaehler: %d\n",zaehler); //
   //  wo = 0;//
   //  rewind(f); //
   ////   printf("zurückgedreht\n");//
   ////
   //  vorher = beginn;//
   //  zaehler = 1; //
   ////
   //  while(wo !=EOF)//
   //  {//
   //    wo = getc(f); //
   //    i++;//
   //    if (i == 0)//
   //      r1 = (unsigned)wo;//
   //    if (i == 1)//
   //    {//
   //      r2 = (unsigned)wo;//
   //      r = (r2<<8)+r1; //r1 | r2 << 8; //
   //    }//
   //    if (i == 2)//
   //      l1 = (unsigned)wo;//
   //    if (i == 3)//
   //    {//
   //      l2 = (unsigned)wo;//
   //      l = (l2<<8)+l1; //l1 | l2 << 8; //
   //      //dif = r - (l*2);//
   ////
   //      jetzt = vorher + (alpha*(l - vorher));//
   //      dif = r - g*jetzt;//
   //      vorher = jetzt; //
   //      zaehler++;//
   //      if (dif != 0)//
   //      {//
   //        putc((char) ( (unsigned)dif       & 0xff),ausgabe);//
   //        putc((char) (((unsigned)dif >> 8) & 0xff),ausgabe);//
   //      } //
   //      i = -1;//
   //    }//
   //  } //
   //  fclose(f);//
   //  fclose(ausgabe); //
   //  char output[300]; //
   //  sprintf(output,"rm -frv \"%s\"",Datei);//
   //  system(output);//
   //}//
   /


Which creates moderately distorted sound until I set g to 0. Using 1 for g creates highly distorted sound.

l = left channel
r = right Channel

I am reading in the wave raw file Datei in a binary way.
jetzt = vorher + (alpha*(l - vorher)); is a low pass filter.

If you have questions, please refer to the thread mentioned. If you have questions beyond the replies there I am happy to answer them here or there.

While we are at it, how do I normalize the final mono output to make it as loud as possible without clipping, ie what's the highest/lowest value?

Best

Alexander
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to