I'm trying to build a simple demo where you start recording with a keypress from AudioIn, then stop the recording, see the waveform of the recorded sound, and hear it playing. Seems like it should be trivial, but I don't find the needed methods... How to record a sample then play it?
thanks
AudioIn input;
Amplitude loudness;
void setup() {
size(100, 400);
noStroke();
input = new AudioIn(this, 0);
loudness = new Amplitude(this);
}
void keyPressed() {
if (keyCode == 32) { // start record
loudness.input(input);
}
if (keyCode == 10) { // stop record
input.stop(); // How to convert input to AudioSample ?
}
}
void draw() {
float f = loudness.analyze() * 5;
background(125, 255, 125);
rect(0, height, 100, -height * f);
}
I'm trying to build a simple demo where you start recording with a keypress from AudioIn, then stop the recording, see the waveform of the recorded sound, and hear it playing. Seems like it should be trivial, but I don't find the needed methods... How to record a sample then play it?
thanks