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 {
36
36
// / updates the sample rate dynamically
37
37
virtual void setAudioInfo (AudioInfo info) {
38
38
TRACEI ();
39
+ AudioOutput::cfg = info;
39
40
PWMConfig cfg = audio_config;
40
41
if (cfg.sample_rate != info.sample_rate || cfg.channels != info.channels ||
41
42
cfg.bits_per_sample != info.bits_per_sample ) {
@@ -48,6 +49,12 @@ class PWMAudioOutput : public AudioOutput {
48
49
}
49
50
}
50
51
52
+ AudioInfo audioInfoOut () override {
53
+ AudioInfo result = audioInfo ();
54
+ result.sample_rate = pwm.effectiveOutputSampleRate ();
55
+ return result;
56
+ }
57
+
51
58
// / starts the processing using Streams
52
59
bool begin (PWMConfig config) {
53
60
TRACED ();
Original file line number Diff line number Diff line change @@ -232,6 +232,11 @@ class DriverPWMBase {
232
232
// / on the heap and will be cleaned up by this class
233
233
void setBuffer (BaseBuffer<uint8_t > *buffer) { this ->buffer = buffer; }
234
234
235
+ // / Provides the effective sample rate
236
+ virtual int effectiveOutputSampleRate () {
237
+ return audio_config.sample_rate / decimation ();
238
+ }
239
+
235
240
protected:
236
241
PWMConfig audio_config;
237
242
AudioInfo actual_info;
@@ -326,11 +331,6 @@ class DriverPWMBase {
326
331
return audio_config.sample_rate >= ANALOG_MAX_SAMPLE_RATE;
327
332
}
328
333
329
- // / Provides the effective sample rate
330
- virtual int effectiveOutputSampleRate () {
331
- return audio_config.sample_rate / decimation ();
332
- }
333
-
334
334
// / Decimation factor to reduce the sample rate
335
335
virtual int decimation () {
336
336
if (decimation_factor == 0 ){
You can’t perform that action at this time.
0 commit comments