Improve record/stop/play handling
This commit is contained in:
parent
97179dfff8
commit
ed44d61f51
@ -10,33 +10,37 @@
|
|||||||
var serverUrl = 'http://localhost:5000';
|
var serverUrl = 'http://localhost:5000';
|
||||||
var archiveUrl = serverUrl + '/add-to-archive/';
|
var archiveUrl = serverUrl + '/add-to-archive/';
|
||||||
|
|
||||||
function setupRecording(){
|
var mic, recorder, soundFile;
|
||||||
var mic, recorder, soundFile;
|
var state = 0;
|
||||||
var state = 0;
|
|
||||||
|
|
||||||
|
// 30 seconds (in milliseconds)
|
||||||
|
var recordingTimeout = 30000;
|
||||||
|
|
||||||
|
function setupRecording(){
|
||||||
mic = new p5.AudioIn();
|
mic = new p5.AudioIn();
|
||||||
mic.start();
|
mic.start();
|
||||||
|
|
||||||
recorder = new p5.SoundRecorder();
|
recorder = new p5.SoundRecorder();
|
||||||
recorder.setInput(mic);
|
recorder.setInput(mic);
|
||||||
|
|
||||||
soundFile = new p5.SoundFile();
|
soundFile = new p5.SoundFile();
|
||||||
|
|
||||||
function doRecording(){
|
function doRecording(){
|
||||||
// TODO: handle timing out if no stopping happens
|
|
||||||
if (mic.enabled){
|
if (mic.enabled){
|
||||||
recorder.record(soundFile);
|
setTimeout(recorder.record(soundFile), recordingTimeout);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function doStopping(){
|
function doStopping(){
|
||||||
// TODO: only stop if playing/recording otherwise:
|
if (recorder.recording) {
|
||||||
// "NotSupportedError: Operation is not supported"
|
recorder.stop();
|
||||||
recorder.stop();
|
}
|
||||||
|
|
||||||
// TODO: handle the generation of shapes from here
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function doPlaying(){
|
function doPlaying(){
|
||||||
soundFile.play();
|
if (soundFile.isLoaded()){
|
||||||
|
soundFile.play();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function doArchiving(){
|
function doArchiving(){
|
||||||
@ -80,4 +84,5 @@ function setup(){
|
|||||||
setupRecording();
|
setupRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(){}
|
function draw(){
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user