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 › Ess, multiple streams
Page Index Toggle Pages: 1
Ess, multiple streams (Read 965 times)
Ess, multiple streams
Dec 26th, 2008, 4:12pm
 
Hello,
I try to play 2 stream in same time. But I have a problem: audioStreamWrite is called whenever the stream is ready for more data, but I can't specify which stream. Also sound are cut...

is the code:

Code:

import krister.Ess.*;

Son son1;
Son son2;

void setup(){
size(640,480);

Ess.start(this);

frameRate(30);

son1 = new Son(200,200,1, "comprends.mp3");
son2 = new Son(300,200,1, "milk.mp3");
}

void draw(){
background(0);
son1.draw();
son2.draw();
}

void audioStreamWrite(AudioStream theStream) {
son1.audioStreamWrite();
son2.audioStreamWrite();
}

public void stop() {
Ess.stop();
super.stop();
}

class Son {
AudioStream myStream;
AudioFile myFile;

int present, x, y, drag;
String son;

Son(int x1, int y1, int present1, String son1){
x=x1;
y=y1;
present=present1;
son=son1;

myFile=new AudioFile( son ,0,Ess.READ);
myStream=new AudioStream(32*1024);
myStream.sampleRate(myFile.sampleRate);
myStream.start();
}


void draw(){
noStroke();
fill(255);
ellipse(x,y,20,20);
myStream.gain(map(y, 0,height, 4, -20));
myStream.pan(map(x, 0,width, -1,1));
println(myStream.state);
}


void audioStreamWrite() {
int samplesRead=myFile.read(myStream);
if (samplesRead==0) {
myFile.close();
myFile.open(son ,myStream.sampleRate,Ess.READ);
samplesRead=myFile.read(myStream);
}
}
}
Re: Ess, multiple streams
Reply #1 - Dec 28th, 2008, 7:29pm
 
Nobody can help me?

Can I play several sounds and control effects (reverb, pitch) separately and in real time?

Excuse my insistence, but it's a student work, and I present this in january.
Re: Ess, multiple streams
Reply #2 - Jan 16th, 2009, 4:39pm
 
simple, assuming this is what you need:

void audioStreamWrite(AudioStream theStream){
  if(theStream==son1.myStream) son1.doSomething();
  else if(theStream==son2.myStream) son2.doSomething();
}
Re: Ess, multiple streams
Reply #3 - Jan 16th, 2009, 4:46pm
 
Hello,
I know, I found myself... and I felt very stupid, because it was simple!
Page Index Toggle Pages: 1