We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Generating waves with Ess.ADD
Page Index Toggle Pages: 1
Generating waves with Ess.ADD (Read 461 times)
Generating waves with Ess.ADD
Apr 21st, 2008, 1:59am
 
I am trying to implement some code with Ess, that should layer different triangle waves in a sequence. It works fine when I use myTriangle.generate(myChannel, start, duration), but that does not allow for polyphony.

When I use myTriangle.generate(myChannel, Ess.ADD, start, duration), it stops working, unless I drastically increase the duration, at which point it the starting position seems to be + 50 % of the total length over. ie, if I wanted it to start 25% of the way through, it would now start 75% of the way, whereas with Ess.REPLACE it worked fine.

So, am I doing something wrong while generating these waves? Or is there another way to do this that works? I have tried many different things; Ess.SUBTRACT does the same thing as Ess.ADD. Why would it be different with these? I cannot find this mentioned anywhere in the Ess documentation.

If anyone can help, it would be much appreciated.

Relevant parts of the sound code:

Code:

void setup() {
  ...
       Ess.start(this);

       myChannel = new AudioChannel();
       myChannel.initChannel(myChannel.frames(2560));
       
               mySilence = new Silence();
               
       myChannel.softClip = true;
       
       myTriangle = new TriangleWave[POLYPHONY];
       
       myChannel.play(Ess.FOREVER);
}

void killSound() {
 myAmplify=new Amplify(0);
 myAmplify.filter(myChannel, 0, myChannel.frames(2560));
}

void processSound()
{
 killSound();
 
 Blob b;
 for (int n=0; n<theBlobDetection.getBlobNb(); n++) {
   b = theBlobDetection.getBlob(n);
   if (b!=null) {
     freq  = (int) (((b.yMin + b.h / 2) * height) + 10) * 2;
     start = (int) (b.xMin * 640 * MULTIPLE);
     end   = (int) ((b.xMin * 640 * MULTIPLE) + (b.w * 640 * MULTIPLE));
     if ( (end - start) > 30) {
       println("Adding wave: " + freq + "hz, from " + start + " ms to " + end + " ms.");
       println("Actual vals: " + freq + "hz, from " + myChannel.frames(start) + " frame " + myChannel.frames(end) + " frame");
       myTriangle[n] = new TriangleWave(freq, .5);
       myTriangle[n].generate(myChannel, Ess.ADD, myChannel.frames(start), myChannel.frames(end - start) );
     }
   }
 }
}

void audioChannelLoop(AudioChannel ch) {
 println("Current frame: " + myChannel.cue);
 println("Current ms: " + myChannel.ms(myChannel.cue));
 processSound();
}

Re: Generating waves with Ess.ADD
Reply #1 - Apr 27th, 2008, 8:31pm
 
Anyone have any idea? I've been trying unsuccessfully to figure this out for a while.

Thanks.
Page Index Toggle Pages: 1