Skip to content

Commit

Permalink
Added a new CONFIG_MIXER_DEFAULT_CHANNEL_SAMPLERATE constant for chan…
Browse files Browse the repository at this point in the history
…nels with no defined rate to use
  • Loading branch information
JohnVidler committed Nov 13, 2023
1 parent e88cb96 commit d54ce9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion inc/Mixer2.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ DEALINGS IN THE SOFTWARE.
#define CONFIG_MIXER_DEFAULT_SAMPLERATE 44100
#endif

// The default sample rate, for when the user does not supply us with anything
// This applies to both ADC input rates and mixer output rates.
//
// This is distinct from CONFIG_MIXER_DEFAULT_SAMPLERATE which sets the mixer's absolute maximum rate
// whereas this is simply the 'normal' operating rate for audio peripherals.
#ifndef CONFIG_MIXER_DEFAULT_CHANNEL_SAMPLERATE
#define CONFIG_MIXER_DEFAULT_CHANNEL_SAMPLERATE 11000
#endif

#define DEVICE_ID_MIXER 3030

#define DEVICE_MIXER_EVT_SILENCE 1
Expand Down Expand Up @@ -156,7 +165,7 @@ class Mixer2 : public DataSource
* @param sampleRate (samples per second) - if set to zero, defaults to the output sample rate of the Mixer
* @param sampleRange (quantization levels) the difference between the maximum and minimum sample level on the input channel
*/
MixerChannel *addChannel(DataSource &stream, float sampleRate = 0, int sampleRange = CONFIG_MIXER_INTERNAL_RANGE);
MixerChannel *addChannel(DataSource &stream, float sampleRate = CONFIG_MIXER_DEFAULT_CHANNEL_SAMPLERATE, int sampleRange = CONFIG_MIXER_INTERNAL_RANGE);

/**
* Removes a channel from the mixer
Expand Down
2 changes: 1 addition & 1 deletion source/MicroBitAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ MicroBitAudio::MicroBitAudio(NRF52Pin &pin, NRF52Pin &speaker, NRF52ADC &adc, NR
synth.allowEmptyBuffers(true);

mic = adc.getChannel(microphone, false);
adc.setSamplePeriod( 1e6 / 11000 );
adc.setSamplePeriod( 1e6 / CONFIG_MIXER_DEFAULT_CHANNEL_SAMPLERATE );
mic->setGain(7, 0);

// Implementers note: The order that the pipeline comes up here is quite sensitive. If we connect up to splitters after starting to
Expand Down

0 comments on commit d54ce9b

Please sign in to comment.