Skip to content

Commit f020620

Browse files
committed
Corrections to examples
1 parent d988917 commit f020620

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

examples-basic-api/base-i2s-a2dp/base-i2s-a2dp.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010

1111
#include "Arduino.h"
1212
#include "AudioTools.h"
13-
#include "BluetoothA2DPSource.h"
13+
#include "AudioA2DP.h"
1414

1515
using namespace audio_tools;
1616

17+
/**
18+
* @brief We use a ADS1015 I2S microphone as input and send the data to A2DP
19+
* Unfortunatly the data type from the microphone (int32_t) does not match with the required data type by A2DP (int16_t),
20+
* so we need to convert.
21+
*/
1722

1823
BluetoothA2DPSource a2dp_source;
1924
I2S<int32_t> i2s;
20-
CallbackConverter<int32_t,int16_t> converter(&convertFrom32To16);
25+
ChannelConverter<int32_t> converter(&convertFrom32To16);
2126
ConverterFillLeftAndRight<int32_t> bothChannels;
2227
const size_t max_buffer_len = 1024;
2328
int32_t buffer[max_buffer_len][2];
@@ -33,7 +38,7 @@ int32_t get_sound_data(Channels* data, int32_t len) {
3338
bothChannels.convert(buffer, result_len);
3439

3540
// convert buffer to int16 for A2DP
36-
converter.convert(buffer, (int16_t(*)[2]) data, result_len);
41+
converter.convert(buffer, data, result_len);
3742
return result_len;
3843
}
3944

examples-basic-api/base-i2s-serial/base-i2s-serial.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
/**
22
* @file i2s-serial.ino
33
* @author Phil Schatzmann
44
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/i2s-serial/README.md

examples/streams-generator-i2s/streams-generator-i2s.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* @file streams-generator-a2dp.ino
2+
* @file streams-generator-i2s.ino
33
* @author Phil Schatzmann
4-
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/streams-generator-a2dp/README.md
4+
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/streams-generator-i2s/README.md
55
* @author Phil Schatzmann
66
* @copyright GPLv3
77
*/
@@ -25,7 +25,7 @@ void setup(void) {
2525
Serial.begin(115200);
2626

2727
// start the bluetooth
28-
Serial.println("starting A2DP...");
28+
Serial.println("starting I2S...");
2929
I2SConfig config = out.defaultConfig(TX_MODE);
3030
config.sample_rate = sample_rate;
3131
config.channels = 2;

src/AudioPWM/PWMforESP32.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ struct PWMConfigESP32 {
3838
int buffer_size = 1024 * 8;
3939
int bits_per_sample = 16;
4040
int resolution = 8; // must be between 8 and 11 -> drives pwm frequency
41+
42+
int maxChannels() {
43+
return 16;
44+
}
45+
4146
} default_config;
4247

4348
typedef PWMConfigESP32 PWMConfig;

src/AudioPWM/PWMforPico.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ struct PWMConfigPico {
4343
int amplitude_out = 127; // amplitude of square wave (pwm values -amplitude to amplitude) for one byte
4444
int amplitude_in = 0;
4545
int start_pin = 2; // channel 0 will be on gpio 2, channel 1 on 3 etc
46+
47+
int maxChannels() {
48+
return 16;
49+
}
4650
} default_config;
4751

4852
typedef PWMConfigPico PWMConfig;
4953

5054
/**
51-
* @brief Audio output for the Rasperry Pico to PWM pins
55+
* @brief Audio output for the Rasperry Pico to PWM pins.
56+
The Raspberry Pi Pico has 8 PWM blocks/slices(1-8) and each PWM block provides up to two PWM outputs(A-B).
5257
* @author Phil Schatzmann
5358
* @copyright GPLv3
5459

0 commit comments

Comments
 (0)