arduino-audio-tools
Loading...
Searching...
No Matches
PWMConfigSTD.h
Go to the documentation of this file.
1#pragma once
2
3namespace audio_tools {
10struct PWMConfigSTD : public AudioInfo {
12 // default basic information
13 sample_rate = 8000u; // sample rate in Hz
14 channels = 1;
15 bits_per_sample = 16;
16 }
17
22
24 uint32_t pwm_frequency = 0; // audable range is from 20 to
29
32
35
38
40 template <typename T, int N>
41 void setPins(T (&a)[N]) {
44 for (int i = 0; i < N; ++i) {
45 pins_data[i] = a[i]; // reset all elements
46 }
47 }
48
51 void setPins(Pins &pins) {
53 for (int i = 0; i < pins.size(); i++) {
55 }
56 }
57
60 if (pins_data.size() == 0) {
62 for (int j = 0; j < channels; j++) {
64 }
65 }
66 return pins_data;
67 }
68
69
70 void logConfig() {
71 LOGI("sample_rate: %d", (int) sample_rate);
72 LOGI("channels: %d", channels);
73 LOGI("bits_per_sample: %u", bits_per_sample);
74 LOGI("buffer_size: %u", buffer_size);
75 LOGI("buffer_count: %u", buffers);
76 LOGI("pwm_frequency: %u", (unsigned)pwm_frequency);
77 LOGI("resolution: %d", resolution);
78 LOGI("dead_time_us: %u", dead_time_us);
79 // LOGI("timer_id: %d", timer_id);
80 }
81
82 protected:
84};
85
87
88}
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define PWM_BUFFER_COUNT
Definition AudioToolsConfig.h:174
#define PWM_MAX_SAMPLE_RATE
Definition AudioToolsConfig.h:299
#define PIN_PWM_START
Definition PWMDriverBase.h:15
#define PWM_BUFFER_SIZE
Definition avr.h:17
void push_back(T &&value)
Definition Vector.h:182
void clear()
Definition Vector.h:176
bool resize(size_t newSize, T value)
Definition Vector.h:266
int size()
Definition Vector.h:178
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:508
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:51
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:53
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:55
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:57
Configuration data for PWM audio output.
Definition PWMConfigAVR.h:10
Configuration data for PWM audio output.
Definition PWMConfigSTD.h:10
uint8_t resolution
Only used by ESP32: must be between 8 and 11 -> drives pwm frequency // 20,000Hz (not used by ESP32)
Definition PWMConfigSTD.h:26
Pins & pins()
Determines the pins (for all channels)
Definition PWMConfigSTD.h:59
uint8_t timer_id
Timer used: Only used by ESP32 must be between 0 and 3.
Definition PWMConfigSTD.h:28
void setPins(Pins &pins)
Definition PWMConfigSTD.h:51
uint16_t start_pin
GPIO of starting pin.
Definition PWMConfigSTD.h:37
uint32_t pwm_frequency
additinal info which might not be used by all processors
Definition PWMConfigSTD.h:24
void logConfig()
Definition PWMConfigSTD.h:70
Pins pins_data
Definition PWMConfigSTD.h:83
PWMConfigSTD()
Definition PWMConfigSTD.h:11
uint16_t dead_time_us
Dead time in microseconds for symmetric PWM (ESP32 only)
Definition PWMConfigSTD.h:31
uint32_t max_sample_rate
max sample sample rate that still produces good audio
Definition PWMConfigSTD.h:34
uint16_t buffer_size
size of an inidividual buffer
Definition PWMConfigSTD.h:19
uint8_t buffers
number of buffers
Definition PWMConfigSTD.h:21
void setPins(T(&a)[N])
support assignament of int array
Definition PWMConfigSTD.h:41