|
16 | 16 | #include "DriverPins.h" |
17 | 17 |
|
18 | 18 | namespace audio_driver { |
19 | | - |
| 19 | + |
20 | 20 | const int rate_num[8] = {8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000}; |
21 | 21 | const samplerate_t rate_code[8] = {RATE_08K, RATE_11K, RATE_16K, RATE_22K, |
22 | 22 | RATE_24K, RATE_32K, RATE_44K, RATE_48K}; |
@@ -61,6 +61,12 @@ class CodecConfig : public codec_config_t { |
61 | 61 | case 16: |
62 | 62 | i2s.bits = BIT_LENGTH_16BITS; |
63 | 63 | return bits; |
| 64 | + case 18: |
| 65 | + i2s.bits = BIT_LENGTH_18BITS; |
| 66 | + return bits; |
| 67 | + case 20: |
| 68 | + i2s.bits = BIT_LENGTH_20BITS; |
| 69 | + return bits; |
64 | 70 | case 24: |
65 | 71 | i2s.bits = BIT_LENGTH_24BITS; |
66 | 72 | return bits; |
@@ -118,21 +124,21 @@ class CodecConfig : public codec_config_t { |
118 | 124 | is_output = true; |
119 | 125 |
|
120 | 126 | if (is_input && is_output) { |
121 | | - AD_LOGD("CODEC_MODE_BOTH"); |
| 127 | + AD_LOGD("mode->CODEC_MODE_BOTH"); |
122 | 128 | return CODEC_MODE_BOTH; |
123 | 129 | } |
124 | 130 |
|
125 | 131 | if (is_output) { |
126 | | - AD_LOGD("CODEC_MODE_DECODE"); |
| 132 | + AD_LOGD("mode->CODEC_MODE_DECODE"); |
127 | 133 | return CODEC_MODE_DECODE; |
128 | 134 | } |
129 | 135 |
|
130 | 136 | if (is_input) { |
131 | | - AD_LOGD("CODEC_MODE_ENCODE"); |
| 137 | + AD_LOGD("mode->CODEC_MODE_ENCODE"); |
132 | 138 | return CODEC_MODE_ENCODE; |
133 | 139 | } |
134 | 140 |
|
135 | | - AD_LOGD("CODEC_MODE_NONE"); |
| 141 | + AD_LOGD("mode->CODEC_MODE_NONE"); |
136 | 142 | return CODEC_MODE_NONE; |
137 | 143 | } |
138 | 144 | }; |
@@ -652,7 +658,7 @@ class AudioDriverWM8994Class : public AudioDriver { |
652 | 658 | delay(10); |
653 | 659 | p_pins = &pins; |
654 | 660 | int vol = map(volume, 0, 100, DEFAULT_VOLMIN, DEFAULT_VOLMAX); |
655 | | - uint32_t freq = getFrequency(codec_cfg.i2s.rate); |
| 661 | + uint32_t freq = codecCfg.getRateNumeric(); |
656 | 662 | uint16_t outputDevice = getOutput(codec_cfg.dac_output); |
657 | 663 |
|
658 | 664 | auto i2c = pins.getI2CPins(CODEC); |
@@ -688,27 +694,6 @@ class AudioDriverWM8994Class : public AudioDriver { |
688 | 694 | return cnt == 0; |
689 | 695 | } |
690 | 696 |
|
691 | | - uint32_t getFrequency(samplerate_t rateNum) { |
692 | | - switch (rateNum) { |
693 | | - case RATE_08K: |
694 | | - return 8000; /*!< set to 8k samples per second */ |
695 | | - case RATE_11K: |
696 | | - return 11024; /*!< set to 11.025k samples per second */ |
697 | | - case RATE_16K: |
698 | | - return 16000; /*!< set to 16k samples in per second */ |
699 | | - case RATE_22K: |
700 | | - return 22050; /*!< set to 22.050k samples per second */ |
701 | | - case RATE_24K: |
702 | | - return 24000; /*!< set to 24k samples in per second */ |
703 | | - case RATE_32K: |
704 | | - return 32000; /*!< set to 32k samples in per second */ |
705 | | - case RATE_44K: |
706 | | - return 44100; /*!< set to 44.1k samples per second */ |
707 | | - case RATE_48K: |
708 | | - return 48000; /*!< set to 48k samples per second */ |
709 | | - } |
710 | | - return 44100; |
711 | | - } |
712 | 697 |
|
713 | 698 | uint16_t getOutput(dac_output_t dac_output) { |
714 | 699 | switch (dac_output) { |
|
0 commit comments