Updating synth.c with a Gaussian white noise effect?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have tried to write my own SoX effect to generate Gaussian white noise as an alternative to the uniform white noise that it generates currently. Even though I have a copy of "Numerical Recipes in C", a fair amount of C experience, and the internet at my disposal, I'm still stuck.

Would anyone mind looking at the code I have come up with so far, and hopefully tell me where I am screwing up?

A patch file for synth.c is attached; patch your v14.4.2 synth.c file with my changes using:

cd sox-14.4.2/src
patch -p1 <synth.diff

(If you would like me to send you my modified synth.c itself, let me know.)

I tried a number of ways to accomplish this; that is why there are so many commented out blocks. The last block of code is where I left off.

The new effect is invoked like this:

sox -V -b 24 -r 96000 -n gaussianwhite.wav synth 60 gaussianwhitenoise gaussianwhitenoise gain -12


Thanks,
James

case synth_gaussianwhitenoise: {
static double V1, V2, S;
static int phase = 0;
double X;
do {
if(phase == 0) {
do {
V1 = DRANQD1;
V2 = DRANQD1;
S = V1 * V1 + V2 * V2;
} while (S >= 1 || S == 0);
X = V1 * sqrt(-2 * log(S) / S);
} else {
X = V2 * sqrt(-2 * log(S) / S);
}
phase = 1 - phase;
} while (X < -1 || X > 1);
synth_out = X;
//printf("%lf\n", synth_out);
}

Attachment: synth.diff
Description: Binary data

_______________________________________________
Sox-users mailing list
Sox-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sox-users

[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux