arduino-audio-tools
Loading...
Searching...
No Matches
I2SConfigESP32V1.h
1#pragma once
2#include "AudioToolsConfig.h"
3#include "AudioTools/CoreAudio/AudioTypes.h"
4
5#ifndef PIN_I2S_MCK
6# define PIN_I2S_MCK -1
7#endif
8
9
10namespace audio_tools {
11
13enum class I2SChannelSelect { Stereo, Left, Right, Default };
14
22 public:
23
25 channels = DEFAULT_CHANNELS;
26 sample_rate = DEFAULT_SAMPLE_RATE;
27 bits_per_sample = DEFAULT_BITS_PER_SAMPLE;
28 }
29
31 I2SConfigESP32V1(const I2SConfigESP32V1 &cfg) = default;
32
35 channels = DEFAULT_CHANNELS;
36 sample_rate = DEFAULT_SAMPLE_RATE;
37 bits_per_sample = DEFAULT_BITS_PER_SAMPLE;
38 rx_tx_mode = mode;
39 switch(mode){
40 case RX_MODE:
41 pin_data = PIN_I2S_DATA_IN;
42 break;
43 case TX_MODE:
44 pin_data = PIN_I2S_DATA_OUT;
45 break;
46 default:
47 pin_data = PIN_I2S_DATA_OUT;
48 pin_data_rx = PIN_I2S_DATA_IN;
49 break;
50 }
51 }
52
55 I2SFormat i2s_format = I2S_STD_FORMAT;
56 I2SSignalType signal_type = Digital; // e.g. the ESP32 supports analog input or output or PDM picrophones
57 bool is_master = true;
58 int port_no = 0; // processor dependent port
59 int pin_ws = PIN_I2S_WS;
60 int pin_bck = PIN_I2S_BCK;
61 int pin_data = -1; // rx or tx pin dependent on mode: tx pin for RXTX_MODE
62 int pin_data_rx = -1; // rx pin for RXTX_MODE
63 int pin_mck = PIN_I2S_MCK;
65 int buffer_count = I2S_BUFFER_COUNT;
67 int buffer_size = I2S_BUFFER_SIZE;
68 bool use_apll = I2S_USE_APLL;
69 bool auto_clear = I2S_AUTO_CLEAR;
71 I2SChannelSelect channel_format = I2SChannelSelect::Default;
73 int mclk_multiple = -1;
74
75 void logInfo(const char* source="") {
76 AudioInfo::logInfo(source);
77 LOGI("rx/tx mode: %s", RxTxModeNames[rx_tx_mode]);
78 LOGI("port_no: %d", port_no);
79 LOGI("is_master: %s", is_master ? "Master":"Slave");
80 LOGI("sample rate: %d", (int) sample_rate);
81 LOGI("bits per sample: %d", bits_per_sample);
82 LOGI("number of channels: %d", channels);
83 LOGI("signal_type: %s", i2s_signal_types[signal_type]);
84 LOGI("buffer_count:%d", buffer_count);
85 LOGI("buffer_size:%d", buffer_size);
86 LOGI("auto_clear: %s",auto_clear? "true" : "false");
87 if (signal_type==Digital){
88 LOGI("i2s_format: %s", i2s_formats[i2s_format]);
89 }
90 if (use_apll) {
91 LOGI("use_apll: %s", use_apll ? "true" : "false");
92 }
93 // LOGI("buffer_count:%d",buffer_count);
94 // LOGI("buffer_size:%d",buffer_size);
95
96 if (pin_mck!=-1){
97 LOGI("pin_mck: %d", pin_mck);
98 }
99 if (pin_bck!=-1){
100 LOGI("pin_bck: %d", pin_bck);
101 }
102 if (pin_ws!=-1){
103 LOGI("pin_ws: %d", pin_ws);
104 }
105 if (pin_data!=-1){
106 LOGI("pin_data: %d", pin_data);
107 }
108 if (pin_data_rx!=-1){
109 LOGI("pin_data_rx: %d", pin_data_rx);
110 }
111 }
112};
113
114using I2SConfig = I2SConfigESP32V1;
115
116}
117
Configuration for ESP32 i2s for IDF > 5.0.
Definition I2SConfigESP32V1.h:21
int buffer_count
not used any more
Definition I2SConfigESP32V1.h:65
RxTxMode rx_tx_mode
public settings
Definition I2SConfigESP32V1.h:54
int mclk_multiple
masterclock multiple (-1 = use default)
Definition I2SConfigESP32V1.h:73
I2SChannelSelect channel_format
Select left or right channel when channels == 1.
Definition I2SConfigESP32V1.h:71
int buffer_size
not used any more
Definition I2SConfigESP32V1.h:67
I2SConfigESP32V1(const I2SConfigESP32V1 &cfg)=default
Default Copy Constructor.
I2SConfigESP32V1(RxTxMode mode)
Constructor.
Definition I2SConfigESP32V1.h:34
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition AudioTypes.h:28
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
I2SSignalType
I2S Signal Types: Digital, Analog, PDM.
Definition AudioTypes.h:437
static const char * RxTxModeNames[4]
Text string (description) for RxTxMode.
Definition AudioTypes.h:40
I2SFormat
I2S Formats.
Definition AudioTypes.h:416
I2SChannelSelect
Select left or right channel when number of channels = 1.
Definition I2SConfigESP32V1.h:13
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:53
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:55
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:57
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:59