@@ -4,9 +4,6 @@ function sepiaFW_build_audio_recorder(){
44
55 //Debug modules and interfaces?
66 AudioRecorder . debugInterfaces = false ;
7-
8- //Parameters and states
9- AudioRecorder . isRecording = false ;
107
118 //set default parameters for audio recorder
129 AudioRecorder . setup = function ( successCallback , errorCallback ) {
@@ -15,21 +12,12 @@ function sepiaFW_build_audio_recorder(){
1512
1613 //---- broadcasting -----
1714
18- function broadcastRecorderRequested ( ) {
19- //console.log('broadcastRecorderRequested');
20- }
21- function broadcastRecorderStopRequested ( ) {
22- //console.log('broadcastRecorderStopRequested');
23- }
24- function broadcastRecorderClosed ( ) {
25- //console.log('broadcastRecorderClosed');
26- }
27- function broadcastRecorderStarted ( ) {
28- //console.log('broadcastRecorderStarted');
29- }
30- function broadcastRecorderStopped ( ) {
31- //console.log('broadcastRecorderStopped');
32- }
15+ //TODO: do we still need these events? (check below: 'dispatchRecorderEvent')
16+ function broadcastRecorderRequested ( ) { }
17+ function broadcastRecorderStopRequested ( ) { }
18+ function broadcastRecorderClosed ( ) { }
19+ function broadcastRecorderStarted ( ) { }
20+ function broadcastRecorderStopped ( ) { }
3321 function broadcastRecorderError ( e ) {
3422 //console.log('broadcastRecorderError');
3523 }
@@ -39,8 +27,22 @@ function sepiaFW_build_audio_recorder(){
3927 if ( SepiaFW . webAudio . defaultProcessorOptions ) {
4028 SepiaFW . webAudio . defaultProcessorOptions . moduleFolder = "audio-modules" ;
4129 }
30+
31+ //event dispatcher
32+ function dispatchRecorderEvent ( data ) {
33+ //console.error("WebAudio recorder event", data); //DEBUG
34+ document . dispatchEvent ( new CustomEvent ( 'sepia_web_audio_recorder' , { detail : data } ) ) ;
35+ }
36+
37+ //The one and ONLY recorder instance:
4238 var sepiaWebAudioProcessor ;
4339
40+ //should run parallel to AudioPlayer output?
41+ AudioRecorder . mayMicRunParallelToAudioOut = function ( ) {
42+ return ! SepiaFW . ui . isMobile ; //mobile is ATM usually not good with Input + Output at same time
43+ //NOTE: for wake-word we check 'WakeTriggers.allowWakeWordDuringStream' and user can force this
44+ }
45+
4446 var activeAudioModules = [ ] ;
4547 var activeAudioModuleCapabilities = { } ; //e.g.: resample, wakeWordDetection, vad, waveEncoding, volume, speechRecognition
4648 AudioRecorder . webAudioHasCapability = function ( testCap ) {
@@ -131,12 +133,6 @@ function sepiaFW_build_audio_recorder(){
131133 if ( useLegacyMicInterface ) micAudioRecorderOptions . sourceType = "scriptProcessor" ;
132134 //var legacyScriptProcessorBufferSize = 512; //use 'micAudioRecorderOptions.processorBufferSize'
133135
134- //event dispatcher
135- function dispatchRecorderEvent ( data ) {
136- //console.error("WebAudio recorder event", data); //DEBUG
137- document . dispatchEvent ( new CustomEvent ( 'sepia_web_audio_recorder' , { detail : data } ) ) ;
138- }
139-
140136 function defaultOnProcessorReady ( sepiaWebAudioProcessor , msg ) {
141137 SepiaFW . debug . info ( "AudioRecorder - onProcessorReady" , sepiaWebAudioProcessor , msg ) ; //DEBUG
142138 }
@@ -167,11 +163,6 @@ function sepiaFW_build_audio_recorder(){
167163 return ( ! ! sepiaWebAudioProcessor && sepiaWebAudioProcessor . isInitialized ( ) && sepiaWebAudioProcessor . isProcessing ( ) ) ;
168164 }
169165 AudioRecorder . startWebAudioRecorder = function ( successCallback , noopCallback , errorCallback ) {
170- /*if (AudioRecorder.isRecording){
171- SepiaFW.debug.err("AudioRecorder error: Tried to capture audio but was already running!");
172- errorCallback({name: "AudioRecorder: not started!", message: "Audio capture was already running."});
173- return;
174- }*/
175166 if ( sepiaWebAudioProcessor ) {
176167 sepiaWebAudioProcessor . start ( successCallback , noopCallback , errorCallback ) ;
177168 } else {
0 commit comments