File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/AudioTools/CoreAudio/AudioPWM Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ class PWMAudioOutput : public AudioOutput {
3636 // / updates the sample rate dynamically
3737 virtual void setAudioInfo (AudioInfo info) {
3838 TRACEI ();
39+ AudioOutput::cfg = info;
3940 PWMConfig cfg = audio_config;
4041 if (cfg.sample_rate != info.sample_rate || cfg.channels != info.channels ||
4142 cfg.bits_per_sample != info.bits_per_sample ) {
@@ -48,6 +49,12 @@ class PWMAudioOutput : public AudioOutput {
4849 }
4950 }
5051
52+ AudioInfo audioInfoOut () override {
53+ AudioInfo result = audioInfo ();
54+ result.sample_rate = pwm.effectiveOutputSampleRate ();
55+ return result;
56+ }
57+
5158 // / starts the processing using Streams
5259 bool begin (PWMConfig config) {
5360 TRACED ();
Original file line number Diff line number Diff line change @@ -232,6 +232,11 @@ class DriverPWMBase {
232232 // / on the heap and will be cleaned up by this class
233233 void setBuffer (BaseBuffer<uint8_t > *buffer) { this ->buffer = buffer; }
234234
235+ // / Provides the effective sample rate
236+ virtual int effectiveOutputSampleRate () {
237+ return audio_config.sample_rate / decimation ();
238+ }
239+
235240 protected:
236241 PWMConfig audio_config;
237242 AudioInfo actual_info;
@@ -326,11 +331,6 @@ class DriverPWMBase {
326331 return audio_config.sample_rate >= ANALOG_MAX_SAMPLE_RATE;
327332 }
328333
329- // / Provides the effective sample rate
330- virtual int effectiveOutputSampleRate () {
331- return audio_config.sample_rate / decimation ();
332- }
333-
334334 // / Decimation factor to reduce the sample rate
335335 virtual int decimation () {
336336 if (decimation_factor == 0 ){
You can’t perform that action at this time.
0 commit comments