Ward So if I enable the audio expander cape, does that mean the samplerate of the main audio output also is lowered to 22050hz?
No. You will still have 2 channels of audio at 44100 sample rate. The analog sample rate will depend on the number of channels, the usual way. If you inspect the content of context->audioSampleRate
, context->analogSampleRate
, that should rule out any doubts.
What the audio expander settings do (if you enable them and tick the appropriate boxes in the IDE) is they enable digital DC-blocking filtering on the selected analog inputs and outputs so that they are AC-coupled and scaled between -1 and 1, just like the audio channels. See here for more details.
Last, be aware that when writing sample-by-sample, you should use analogWriteOnce()
and not analogWrite()
: see here