We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi I want to record sounds (multiple sounds which should be stored in a folder) with a microphone and loop it with the other sounds I have added - song, song 2 and song 3. The problem is I want the software to initialize and loop the recorded sound by itself, so even if I shut down the program and start it up again, it should continue from where I left. Thanks in advance.
`import processing.serial.*; //Importing serial library import ddf.minim.*; //Importing minim library. Minim is the library we are using for sound-related activities, such as record and playback.
Serial myPort;
Minim minim;
AudioPlayer song; AudioPlayer song2; AudioPlayer song3;
AudioInput in; AudioRecorder recorder;
int countname; //change the name int name = 000000; int startGain = 0;
void newFile()
{
countname = (name + 1);
recorder = minim.createRecorder(in, "Rec" + countname + ".wav", true);
}
void setup() { size(120, 120);
//println(Serial.list()); myPort = new Serial(this, Serial.list()[0], 9600); myPort.bufferUntil('\n');
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 2048); newFile();//go to change file name
song = minim.loadFile("beyonce.mp3"); song2 = minim.loadFile("dajam.wav"); song3 = minim.loadFile("Rec1.wav"); }
void draw() { background(0); stroke(255);
if ( recorder.isRecording() ) { text("Currently recording...", 5, 15); ellipse(60,60,55,55); fill(255,0,0); } else { text(" Not recording.", 5, 15); ellipse(60,60,55,55); fill(0,255,0); } }
void serialEvent (Serial myPort) { String inString = myPort.readStringUntil('\n');
if (inString != null) { inString = trim (inString);
float inByte = float(inString);
println(inByte);
if (inByte == 1){
song.loop();
song2.loop();
song3.loop();
song.rewind();
song2.rewind();
song3.rewind();
}
if (inByte == 0){
song.pause();
song2.pause();
song3.pause();
song.rewind();
song2.rewind();
song3.rewind();
}
if (inByte == 2){
if ( recorder.isRecording() )
{
recorder.endRecord();
name++;
recorder.save();
println("Done saving.");
println(name);
}
else
{
newFile();
recorder.beginRecord();
}
}
if (inByte == 3){ song.setGain(startGain++ * 2); song2.setGain(startGain++ * 2); song3.setGain(startGain++ * 2); }
if (inByte == 4){
song.setGain(startGain-- * 2);
song2.setGain(startGain-- * 2);
song3.setGain(startGain-- * 2);
}
} }
void stop() { // always close Minim audio classes when you are done with them in.close(); minim.stop();
super.stop(); }`