Steve Harris <[EMAIL PROTECTED]>, on Thu Nov 29, 2001 [02:12:30 PM] said:
> On Thu, Nov 29, 2001 at 01:08:28PM +0200, Nasca Octavian Paul wrote:
> > Hi.
> > I made an very interesting sound effect which I called "AlienWah" because
> > it sounds a bit like a wah but more strange.
> > I put a *very simple* implementation (GPL), the description and a
> 
> Have you thought about turing it into a LADSPA plugin. Its really very
> easy, and more people can use it that way.
> 
> - Steve

        Hi.

        I bet this thing would be dead easy to make into a
plugin... (but I dont know anything about LADSPA right now...:)
        In case others who dont have borland and windows want to
try this, attached is a patch so that g++ will built it, and you can
use the program as a simple filter to test the effect:

# patch < g++-aw.diff
# g++ alienwah.cpp -o awah
# sox test.wav -t raw -s -r 44100 -w -c 1 - | awah | play -t raw -s -r 44100 -w -c1 -

Paul
[EMAIL PROTECTED]

(I did like the effect, too. But I dont have much experience, to
make comments.)
--- alienwah.cpp.orig   Thu Nov 29 17:45:29 2001
+++ alienwah.cpp        Thu Nov 29 20:23:40 2001
@@ -52,8 +52,9 @@
 */
 #include <complex.h>
 #include <fcntl.h>
-#include <sys\stat.h>
-#include <io.h>
+#include <sys/stat.h>
+/* #include <io.h> */
+#include <unistd.h>
 #include <stdio.h>
 #include <math.h>
 
@@ -65,24 +66,24 @@
 #define samplerate 44100
 
 #define bufsize 1024
-int buf1[bufsize];//input buffer
-int buf2[bufsize];//output buffer
+short buf1[bufsize];//input buffer
+short buf2[bufsize];//output buffer
 
 
 #define lfoskipsamples 25 // How many samples are processed before compute the lfo 
value again
 
 struct params{
    float freq,startphase,fb;
-   int delay;
+   short delay;
 } awparams;
 //alien wah internal parameters
 
 struct alienwahinternals{
- complex *delaybuf;
+ float_complex *delaybuf;
  float lfoskip;
  long int t;
- complex c;
- int k;
+ float_complex c;
+ short k;
 } awint;
 
 
@@ -94,9 +95,9 @@
   awparams.fb=fb/4+0.74;
   awparams.delay=(int)(delay/44100.0*samplerate);
   if (delay<1) delay=1;
-  awint.delaybuf=new complex[awparams.delay];
+  awint.delaybuf=new float_complex[awparams.delay];
   int i;
-  for (i=0;i<delay;i++) awint.delaybuf[i]=complex(0,0);
+  for (i=0;i<delay;i++) awint.delaybuf[i]=float_complex(0,0);
   awint.lfoskip=freq*2*3.141592653589/samplerate;
   awint.t=0;
 }
@@ -105,30 +106,26 @@
 void process(){
  int i;
  float lfo,out;
- complex outc;
+ float_complex outc;
  for(i=0;i<bufsize;i++){
         if (awint.t++%lfoskipsamples==0){
                lfo=(1+cos(awint.t*awint.lfoskip+awparams.startphase));
-               awint.c=complex(cos(lfo)*awparams.fb,sin(lfo)*awparams.fb);
+               awint.c=float_complex(cos(lfo)*awparams.fb,sin(lfo)*awparams.fb);
         };
         outc=awint.c*awint.delaybuf[awint.k]+(1-awparams.fb)*buf1[i];
         awint.delaybuf[awint.k]=outc;
         if ((++awint.k)>=awparams.delay) awint.k=0;
         out=real(outc)*3;  //take real part of outc
-        if (out<-32768) out=-32768;
-               else if (out>32767) out=32767; //Prevents clipping
-        buf2[i]=out;
+         if (out<-32768) out=-32768;
+                else if (out>32767) out=32767; //Prevents clipping
+        buf2[i]=(short)out;
  };
 }
 
 int main(){
-       char f1,f2;
        int readed;
        long int filereaded=0;
        printf("\n");
-       f1=open(infile,O_RDONLY|O_BINARY);
-       remove(outfile);
-       f2=open(outfile,O_BINARY|O_CREAT,S_IWRITE);
        long int i;
 
 
@@ -139,19 +136,17 @@
             );  
 
        do {
-               readed=read(f1,buf1,bufsize*2);
+               readed=read(STDIN_FILENO,buf1,bufsize*2);
 
                process();
 
-               write(f2,buf2,readed);
-               printf("%ld  bytes \r",filereaded);
+               write(STDOUT_FILENO,buf2,readed);
+               fprintf(stderr, "%ld  bytes \r",filereaded);
                filereaded+=readed;
        }while (readed==bufsize*2);
 
        delete(awint.delaybuf);
-       close(f1);
-       close(f2);
-       printf("\n\n");
+       fprintf(stderr, "\n\n");
 
        return(0);
 }

Reply via email to