5
5
#include " AudioTools/AudioLogger.h"
6
6
#include " AudioTools/Vector.h"
7
7
#include " Stream.h"
8
- #include < math.h> /* pow */
8
+ #include < math.h>
9
9
10
10
namespace audio_tools {
11
11
12
12
// forward declaration
13
- class AudioPWM ;
13
+ class PWMAudioStreamESP32 ;
14
+ typedef PWMAudioStreamESP32 AudioPWM;
14
15
void defaultPWMAudioOutputCallback ();
15
- static AudioPWM *accessAudioPWM = nullptr ;
16
+ static PWMAudioStreamESP32 *accessAudioPWM = nullptr ;
16
17
17
18
/* *
18
19
* @brief Configuration for PWM output
@@ -30,7 +31,7 @@ static AudioPWM *accessAudioPWM = nullptr;
30
31
31
32
*/
32
33
33
- struct PWMConfig {
34
+ struct PWMConfigESP32 {
34
35
int sample_rate = 10000 ; // sample rate in Hz
35
36
int channels = 2 ;
36
37
int start_pin = 3 ;
@@ -39,28 +40,33 @@ struct PWMConfig {
39
40
int resolution = 8 ; // must be between 8 and 11 -> drives pwm frequency
40
41
} default_config;
41
42
43
+ typedef PWMConfigESP32 PWMConfig;
44
+
42
45
/* *
43
46
* @brief Information for a PIN
44
47
* @author Phil Schatzmann
45
48
* @copyright GPLv3
46
49
*/
47
- struct PINInfo {
50
+ struct PinInfoESP32 {
48
51
int pwm_channel;
49
52
int gpio;
50
53
};
51
54
55
+ typedef PinInfoESP32 PinInfo;
56
+
57
+
52
58
/* *
53
59
* @brief Audio output to PWM pins for the ESP32. The ESP32 supports up to 16 channels.
54
60
* @author Phil Schatzmann
55
61
* @copyright GPLv3
56
62
*/
57
63
58
- class PWMAudioStream : public Stream {
59
- friend void defaultAudioOutputCallback ();
64
+ class PWMAudioStreamESP32 : public Stream {
65
+ friend void defaultPWMAudioOutputCallback ();
60
66
61
67
public:
62
68
63
- PWMAudioStream (){
69
+ PWMAudioStreamESP32 (){
64
70
accessAudioPWM = this ;
65
71
}
66
72
@@ -167,7 +173,7 @@ class PWMAudioStream : public Stream {
167
173
168
174
protected:
169
175
PWMConfig audio_config;
170
- Vector<PINInfo > pins;
176
+ Vector<PinInfo > pins;
171
177
NBuffer<uint8_t > buffer = NBuffer<uint8_t >(PWM_BUFFER_SIZE, PWM_BUFFERS);
172
178
hw_timer_t * timer = nullptr ;
173
179
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
0 commit comments