Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
finneyj committed Dec 2, 2024
1 parent cdb033a commit 8b28130
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion model/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ void MicroBit::onListenerRegisteredEvent(Event evt)
// The level detector uses lazy instantiation, we just need to read the data once to start it running.
//audio.level->getValue();
// The level detector requires that we enable constant listening, otherwise no events will be emitted.
audio.levelSPL->activateForEvents( true );
audio.levelSPL->listenerAdded();
break;

case DEVICE_ID_MICROPHONE:
Expand Down
4 changes: 3 additions & 1 deletion source/MicroBitAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ MicroBitAudio::MicroBitAudio(NRF52Pin &pin, NRF52Pin &speaker, NRF52ADC &adc, NR
adc.setSamplePeriod( 1e6 / CONFIG_MIXER_DEFAULT_CHANNEL_SAMPLERATE );
mic->setGain(7, 0);

activateMic();

// Implementers note: The order that the pipeline comes up here is quite sensitive. If we connect up to splitters after starting to
// listen for events from them, we'll see channel startup events (which are valid!) that we don't want. So roughly always follow
// the following schema:
Expand All @@ -82,7 +84,7 @@ MicroBitAudio::MicroBitAudio(NRF52Pin &pin, NRF52Pin &speaker, NRF52ADC &adc, NR

//Initilise level detector SPL and attach to splitter
//levelSPL = new LevelDetectorSPL(*rawSplitter->createChannel(), 85.0, 65.0, 16.0, 0, DEVICE_ID_MICROPHONE, false);
levelSPL = new LevelDetectorSPL(*rawSplitter->createChannel(), 85.0, 65.0, 16.0, 52.0, DEVICE_ID_SYSTEM_LEVEL_DETECTOR, false);
levelSPL = new LevelDetectorSPL(*rawSplitter->createChannel(), 85.0, 65.0, 16.0, 52.0, DEVICE_ID_SYSTEM_LEVEL_DETECTOR);

//Initilise stream splitter
splitter = new StreamSplitter(processor->output, DEVICE_ID_SPLITTER);
Expand Down

0 comments on commit 8b28130

Please sign in to comment.