Skip to content

Commit

Permalink
audio recording: Set recording splitter channel rate during setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-carlos committed Aug 8, 2024
1 parent 0813331 commit f918c4b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions libs/audio-recording/recording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ static MixerChannel *channel = NULL;
#endif


void checkEnv(int sampleRate = -1) {
void checkEnv() {
#if MICROBIT_CODAL
if (recording == NULL) {
if (sampleRate == -1)
sampleRate = 11000;
int defaultSampleRate = 11000;
MicroBitAudio::requestActivation();

splitterChannel = uBit.audio.splitter->createChannel();
splitterChannel->requestSampleRate( defaultSampleRate );

recording = new StreamRecording(*splitterChannel);

channel = uBit.audio.mixer.addChannel(*recording, sampleRate);
channel = uBit.audio.mixer.addChannel(*recording, defaultSampleRate);

channel->setVolume(75.0);
uBit.audio.mixer.setVolume(1000);
Expand Down Expand Up @@ -187,11 +187,8 @@ void setInputSampleRate(int sampleRate) {
//%
void setOutputSampleRate(int sampleRate) {
#if MICROBIT_CODAL
if (recording == NULL) {
checkEnv(sampleRate);
} else {
channel->setSampleRate(sampleRate);
}
checkEnv();
channel->setSampleRate(sampleRate);
#else
target_panic(PANIC_VARIANT_NOT_SUPPORTED);
#endif
Expand Down

0 comments on commit f918c4b

Please sign in to comment.