Browse Source

Improve record/stop/play handling

main
Luke Murphy 4 years ago
parent
commit
ed44d61f51
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 29
      vocoder/static/vocoder.js

29
vocoder/static/vocoder.js

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

Loading…
Cancel
Save