<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
I have this question, which can also be found at
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/17744053/noise-cancellation-setup-combining-the-microphones-signals-intelligently">http://stackoverflow.com/questions/17744053/noise-cancellation-setup-combining-the-microphones-signals-intelligently</a>.
There you can also find more detail information + pictures.<br>
<br>
Maybe it's interesting for you and you can help.<br>
<br>
I built a noise cancellation setup with two microphones and two
different microphone preamplifiers that go to two different channels
of a stereo recording.<br>
<br>
Here is a sample I'd use as "Datei"<br>
<br>
<a class="moz-txt-link-freetext" href="http://filestore.to/?d=U5FN2IH96K">http://filestore.to/?d=U5FN2IH96K</a><br>
<br>
I tried<br>
<br>
<blockquote><small><small><i>static void *voneinanderabziehen( char
*Datei)</i><i><br>
</i><i>{</i><i><br>
</i><i> char
ergebnis[80];
</i><i><br>
</i><i> sprintf(ergebnis,"%s.neu.raw",Datei);</i><i><br>
</i><i> FILE* ausgabe = fopen(ergebnis, "wb");</i><i><br>
</i><i> FILE* f = fopen(Datei, "rb"); </i><i><br>
</i><i> if (f == NULL)</i><i><br>
</i><i> return;</i><i><br>
</i><i> int i = -1;</i><i><br>
</i><i> int r1 = 0;</i><i><br>
</i><i> int r2 = 0;</i><i><br>
</i><i> int l1 = 0;</i><i><br>
</i><i> int l2 = 0;</i><i><br>
</i><i> int zaehler = 0;</i><i><br>
</i><i> int l = 0;</i><i><br>
</i><i> int r = 0;</i><i><br>
</i><i> int wo = 0;</i><i><br>
</i><i> int dif = 0;</i><i><br>
</i><i> float g = 0.1;</i><i><br>
</i><i> float RC = 1.0/(1215*2*3.14);</i><i><br>
</i><i> float dt = 1.0/44100;</i><i><br>
</i><i> float alpha = dt/(RC+dt);</i><i><br>
</i><i> float beginn = 0;</i><i><br>
</i><i> float vorher = 0;</i><i><br>
</i><i> int jetzt = 0;</i><i><br>
</i><i> </i><i><br>
</i><i> while(wo !=EOF)</i><i><br>
</i><i> {</i><i><br>
</i><i> wo = getc(f);</i><i><br>
</i><i> if (zaehler == 0)</i><i><br>
</i><i> beginn = wo;</i><i><br>
</i><i> zaehler++;</i><i><br>
</i><i> </i><i><br>
</i><i> } </i><i><br>
</i><i>// printf("zaehler: %d\n",zaehler); </i><i><br>
</i><i> wo = 0;</i><i><br>
</i><i> rewind(f); </i><i><br>
</i><i>// printf("zurückgedreht\n");</i><i><br>
</i><i> </i><i><br>
</i><i> vorher = beginn;</i><i><br>
</i><i> zaehler = 1; </i><i><br>
</i><i> </i><i><br>
</i><i> while(wo !=EOF)</i><i><br>
</i><i> {</i><i><br>
</i><i> wo = getc(f); </i><i><br>
</i><i> i++;</i><i><br>
</i><i> if (i == 0)</i><i><br>
</i><i> r1 = (unsigned)wo;</i><i><br>
</i><i> if (i == 1)</i><i><br>
</i><i> {</i><i><br>
</i><i> r2 = (unsigned)wo;</i><i><br>
</i><i> r = (r2<<8)+r1; //r1 | r2 << 8; </i><i><br>
</i><i> }</i><i><br>
</i><i> if (i == 2)</i><i><br>
</i><i> l1 = (unsigned)wo;</i><i><br>
</i><i> if (i == 3)</i><i><br>
</i><i> {</i><i><br>
</i><i> l2 = (unsigned)wo;</i><i><br>
</i><i> l = (l2<<8)+l1; //l1 | l2 << 8; </i><i><br>
</i><i> //dif = r - (l*2);</i><i><br>
</i><i> </i><i><br>
</i><i> jetzt = vorher + (alpha*(l - vorher));</i><i><br>
</i><i> dif = r - g*jetzt;</i><i><br>
</i><i> vorher = jetzt; </i><i><br>
</i><i> zaehler++;</i><i><br>
</i><i> if (dif != 0)</i><i><br>
</i><i> {</i><i><br>
</i><i> putc((char) ( (unsigned)dif &
0xff),ausgabe);</i><i><br>
</i><i> putc((char) (((unsigned)dif >> 8) &
0xff),ausgabe);</i><i><br>
</i><i> } </i><i><br>
</i><i> i = -1;</i><i><br>
</i><i> }</i><i><br>
</i><i> } </i><i><br>
</i><i> fclose(f);</i><i><br>
</i><i> fclose(ausgabe); </i><i><br>
</i><i> char output[300]; </i><i><br>
</i><i> sprintf(output,"rm -frv \"%s\"",Datei);</i><i><br>
</i><i> system(output);</i><i><br>
</i><i>}</i></small></small><i><br>
</i></blockquote>
<br>
Which creates moderately distorted sound until I set g to 0. Using 1
for g creates highly distorted sound.<br>
<br>
l = left channel<br>
r = right Channel<br>
<br>
I am reading in the wave raw file Datei in a binary way. <br>
jetzt = vorher + (alpha*(l - vorher)); is a low pass filter.<br>
<br>
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.<br>
<br>
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?<br>
<br>
Best<br>
<br>
Alexander<br>
</body>
</html>