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 - overwriting recording
Page Index Toggle Pages: 1
Ess - overwriting recording? (Read 624 times)
Ess - overwriting recording?
Jun 21st, 2007, 12:49am
 
Hello,

I'm fairly new to Ess so I'm hoping there's a simple solution to the following problem.

Basically, I'm filling an AudioInput buffer, then storing that audio data into an AudioChannel buffer of the same size. The problem is, when I attempt to record a second time, audioInputData() is not being called, leading me to believe that the recording engine is not cleared after stopping and starting the AudioInput. Is there a way to reset? Or is there an easier way to go about it? Feels like I'm missing a very basic concept. Thanks in advance!!

Here's the stripped-down code:


// mousePressed will begin recording
// keyPressed will play back recording from AudioChannel

import krister.Ess.*;

AudioInput myInput;
AudioChannel myChannel;

void setup() {
size(200,200);
background(100);
Ess.start(this);
myInput=new AudioInput(200000);
myChannel = new AudioChannel();
myChannel.initChannel(myChannel.frames(4536));  
frameRate(30);
}

void draw() {
}

void audioInputData(AudioInput theInput) {
println("audioInputData() called");
saveSound();
myInput.stop();
}

void saveSound(){
for(int i = 0; i < myInput.buffer.length;i++){
myChannel.samples[i] = myInput.buffer[i];
}
println("audio stored");
}

void audioChannelDone(AudioChannel ch) {
 println("audioChannelDone() called");
}

void mousePressed(){
println("start myInput");
myInput.start();
}

void keyPressed() {
 println("play myChannel");
myChannel.play();
}

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

Re: Ess - overwriting recording?
Reply #1 - Jun 22nd, 2007, 1:17am
 
my apologies, it was totally obvious after all. re-initializing myInput after it was stopped fixed the problem:


added this line...

myInput=new AudioInput(200000);

...to the end of keyPressed().

Cheesy






Re: Ess - overwriting recording?
Reply #2 - Jun 22nd, 2007, 9:01pm
 
ok, I have a new but related problem. When I attempt to record audio a second time (and every time after), there's a substantial lag time between calling myInput.start() and when the recording actually starts. I've also attempted using a completely different input for the second recording, but the lag time remains.

Has anyone else encountered this? Any ideas? Any help would be greatly appreciated!


macbook pro
intel core 2 duo
2.16GHz
1GB memory

os x 10.4.9
java 1.4
Page Index Toggle Pages: 1