Skip to content

Commit

Permalink
Remove legacy code relater to runtime reconfiguration of audio pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
finneyj committed Nov 1, 2024
1 parent 6ac8666 commit ea1d2e1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
6 changes: 0 additions & 6 deletions inc/MicroBitAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ namespace codal
*/
static void requestActivation();

/**
* Catch events from the splitter
* @param MicroBitEvent
*/
void onSplitterEvent(MicroBitEvent);

/**
* Activate Mic
*/
Expand Down
18 changes: 0 additions & 18 deletions source/MicroBitAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,8 @@ MicroBitAudio::MicroBitAudio(NRF52Pin &pin, NRF52Pin &speaker, NRF52ADC &adc, NR
//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);

// Connect to the rawSplitter. This must come AFTER the processor, to prevent the processor's channel activation starting the microphone
if(EventModel::defaultEventBus)
EventModel::defaultEventBus->listen(rawSplitter->id, DEVICE_EVT_ANY, this, &MicroBitAudio::onSplitterEvent, MESSAGE_BUS_LISTENER_IMMEDIATE);

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

// Connect to the splitter - this COULD come after we create it, before we add any stages, as these are dynamic and will only connect on-demand, but just in case
// we're going to follow the schema set out above, to be 100% sure.
if(EventModel::defaultEventBus) {
EventModel::defaultEventBus->listen(DEVICE_ID_SPLITTER, DEVICE_EVT_ANY, this, &MicroBitAudio::onSplitterEvent, MESSAGE_BUS_LISTENER_IMMEDIATE);
EventModel::defaultEventBus->listen(DEVICE_ID_NOTIFY, mic->output.emitFlowEvents(), this, &MicroBitAudio::onSplitterEvent, MESSAGE_BUS_LISTENER_IMMEDIATE);
}
}

void MicroBitAudio::onSplitterEvent(MicroBitEvent e){

This comment has been minimized.

Copy link
@microbit-carlos

microbit-carlos Nov 18, 2024

Collaborator

@finneyj Is this going the affect the microphone automatically turning on and off when datasinks start or stop consuming its data?

if( mic->output.isFlowing() || (e.value == SPLITTER_ACTIVATE || e.value == SPLITTER_CHANNEL_CONNECT) )
activateMic();
else
deactivateMic();
}

void MicroBitAudio::activateMic(){
Expand Down

0 comments on commit ea1d2e1

Please sign in to comment.