Skip to content

Commit 1cb09ae

Browse files
committed
I2S buffer size as parameter
1 parent df1cdd3 commit 1cb09ae

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

examples/examples-stream/streams-i2s-filter-i2s/streams-i2s-filter-i2s.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void setup(void) {
4343
config_in.pin_bck = 15;
4444
config_in.pin_data = 16;
4545
// config_in.fixed_mclk = sample_rate * 256
46-
// config_in.pin_mck = 2
46+
// config_in.pin_mck = 3
4747

4848
in.begin(config_in);
4949

examples/examples-stream/streams-i2s-i2s/streams-i2s-i2s.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void setup(void) {
3232
config.pin_data = 16;
3333
config.pin_data_rx = 17;
3434
//config.fixed_mclk = sample_rate * 256;
35-
// config.pin_mck = 2; // must be 0,1 or 2 - only for ESP_IDF_VERSION_MAJOR >= 4
35+
// config.pin_mck = 3; // must be 0,1 or 3 - only for ESP_IDF_VERSION_MAJOR >= 4
3636
i2s.begin(config);
3737

3838
Serial.println("I2S started...");

src/AudioI2S/I2SConfig.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ class I2SConfig : public AudioBaseInfo {
7272
I2SFormat i2s_format = I2S_STD_FORMAT;
7373

7474
#ifdef ESP32
75+
int buffer_count = I2S_BUFFER_COUNT;
76+
int buffer_size = I2S_BUFFER_SIZE;
77+
7578
bool is_digital = true; // e.g. the ESP32 supports analog input or output
7679
bool auto_clear;
7780
bool use_apll = I2S_USE_APLL;
7881
uint32_t fixed_mclk = 0;
82+
7983
#if ESP_IDF_VERSION_MAJOR >= 4
8084
int pin_mck = -1;
8185
#endif
@@ -90,14 +94,16 @@ class I2SConfig : public AudioBaseInfo {
9094
LOGI("number of channels: %d", channels);
9195
LOGI("i2s_format: %s", i2s_formats[i2s_format]);
9296
#ifdef ESP32
93-
LOGI("I2S_AUTO_CLEAR=%d",auto_clear);
94-
97+
LOGI("auto_clear:%d",auto_clear);
9598
if (use_apll) {
9699
LOGI("use_apll: %s", use_apll ? "true" : "false");
97100
}
98101
if (fixed_mclk){
99102
LOGI("fixed_mclk: %d", fixed_mclk);
100103
}
104+
LOGI("buffer_count:%d",buffer_count);
105+
LOGI("buffer_size:%d",buffer_size);
106+
101107
#endif
102108

103109
LOGI("pin_bck: %d", pin_bck);

src/AudioI2S/I2SESP32.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,15 @@ class I2SBase {
136136
this->i2s_num = (i2s_port_t) cfg.port_no;
137137
setChannels(cfg.channels);
138138

139-
LOGI("I2S_BUFFER_COUNT=%d",I2S_BUFFER_COUNT);
140-
LOGI("I2S_BUFFER_SIZE=%d",I2S_BUFFER_SIZE);
141-
142139
i2s_config_t i2s_config_new = {
143140
.mode = toMode(cfg),
144141
.sample_rate = (eps32_i2s_sample_rate_type)cfg.sample_rate,
145142
.bits_per_sample = (i2s_bits_per_sample_t) cfg.bits_per_sample,
146143
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
147144
.communication_format = toCommFormat(cfg.i2s_format),
148145
.intr_alloc_flags = 0, // default interrupt priority
149-
.dma_buf_count = I2S_BUFFER_COUNT,
150-
.dma_buf_len = I2S_BUFFER_SIZE,
146+
.dma_buf_count = cfg.buffer_count,
147+
.dma_buf_len = cfg.buffer_size,
151148
.use_apll = (bool) cfg.use_apll,
152149
.tx_desc_auto_clear = cfg.auto_clear,
153150
.fixed_mclk = (int) (cfg.fixed_mclk>0 ? cfg.fixed_mclk : 0 )

0 commit comments

Comments
 (0)