Skip to content

Commit fab4a76

Browse files
committed
2 parents d888956 + 0f33296 commit fab4a76

File tree

14 files changed

+61496
-67
lines changed

14 files changed

+61496
-67
lines changed

docs/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<head>
2+
<meta http-equiv="refresh" content="0; URL=https://pschatzmann.github.io/arduino-audio-tools/modules.html" />
3+
</head>
4+
<body>
5+
<p>If you are not redirected, <a href="https://pschatzmann.github.io/arduino-audio-tools/modules.html">click here</a>.</p>
6+
</body>

examples/README_ESP32.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ adcConfig.adc_channels[1] = ADC_CHANNEL_5;
6969
```
7070

7171
## ADC unit 1 channels on common ESP32 boards
72-
Audio tools supports ADC Unit 1 only.
72+
Audio tools continous ADC framewaork supports ADC Unit 1 only.
7373

7474
### Sparkfun ESP32 Thing Plus (ESP32)
7575
- A2, ADC1_CH6
@@ -78,6 +78,14 @@ Audio tools supports ADC Unit 1 only.
7878
- 32, ADC1_CH4
7979
- 33, ADC1_CH5
8080

81+
### Sparkfun ESP32 Thing Plus C (ESP32)
82+
- A2, ADC1_CH6
83+
- A3, ADC1_CH3
84+
- A4, ADC1_CH0
85+
- A5, ADC1_CH7
86+
- 32/6, ADC1_CH4
87+
- 33/10, ADC1_CH5
88+
8189
### Sparkfun ESP32 Qwiic Pocket Development (ESP32C6)
8290
- 2, ADC1_CH2
8391
- 3, ADC1_CH3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @file channel-converter-avg.ino
3+
* @brief Test calculating pairwise average of channels
4+
* @author Urs Utzinger
5+
* @copyright GPLv3
6+
**/
7+
8+
#include "AudioTools.h"
9+
10+
AudioInfo info1(44100, 1, 16);
11+
AudioInfo info2(44100, 2, 16);
12+
SineWaveGenerator<int16_t> sineWave1(32000); // subclass of SoundGenerator with max amplitude of 32000
13+
SineWaveGenerator<int16_t> sineWave2(32000); // subclass of SoundGenerator with max amplitude of 32000
14+
GeneratedSoundStream<int16_t> sound1(sineWave1); // stream generated from sine wave1
15+
GeneratedSoundStream<int16_t> sound2(sineWave2); // stream generated from sine wave2
16+
InputMerge<int16_t> imerge; // merge two inputs to stereo
17+
ChannelAvg averager; // channel averager
18+
ConverterStream<int16_t> averaged_stream(imerge, averager); // pipe the sound to the averager
19+
CsvOutput<int16_t> serial_out(Serial); // serial output
20+
StreamCopy copier(serial_out, averaged_stream); // stream the binner output to serial port
21+
22+
// Arduino Setup
23+
void setup(void) {
24+
25+
// Open Serial
26+
Serial.begin(115200);
27+
while(!Serial); // wait for Serial to be ready
28+
29+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
30+
31+
// Setup sine waves
32+
sineWave1.begin(info1, N_B4);
33+
sineWave2.begin(info1, N_B5);
34+
35+
// Merge input to stereo
36+
imerge.add(sound1);
37+
imerge.add(sound2);
38+
imerge.begin(info2);
39+
40+
// Define CSV Output
41+
serial_out.begin(info1);
42+
43+
}
44+
45+
// Arduino loop - copy sound to out with conversion
46+
void loop() {
47+
copier.copy();
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @file channel-converter-avg.ino
3+
* @brief Test calculating average of two channels
4+
* @author Urs Utzinger
5+
* @copyright GPLv3
6+
**/
7+
8+
#include "AudioTools.h"
9+
10+
#define BINSIZE 4
11+
12+
AudioInfo info1(44100, 1, 16);
13+
AudioInfo info2(44100, 2, 16);
14+
AudioInfo info_out(44100/BINSIZE, 2, 16);
15+
SineWaveGenerator<int16_t> sineWave1(32000); // subclass of SoundGenerator with max amplitude of 32000
16+
SineWaveGenerator<int16_t> sineWave2(32000); // subclass of SoundGenerator with max amplitude of 32000
17+
GeneratedSoundStream<int16_t> sound1(sineWave1); // stream generated from sine wave1
18+
GeneratedSoundStream<int16_t> sound2(sineWave2); // stream generated from sine wave2
19+
InputMerge<int16_t> imerge; // merge two inputs to stereo
20+
Bin binner; // channel averager
21+
ConverterStream<int16_t> binned_stream(imerge, binner); // pipe the sound to the averager
22+
CsvOutput<int16_t> serial_out(Serial); // serial output
23+
StreamCopy copier(serial_out, binned_stream); // stream the binner output to serial port
24+
25+
// Arduino Setup
26+
void setup(void) {
27+
28+
// Open Serial
29+
Serial.begin(115200);
30+
while(!Serial); // wait for Serial to be ready
31+
32+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
33+
34+
// Setup sine waves
35+
sineWave1.begin(info1, N_B4);
36+
sineWave2.begin(info1, N_B5);
37+
38+
// Merge input to stereo
39+
imerge.add(sound1);
40+
imerge.add(sound2);
41+
imerge.begin(info2);
42+
43+
// Configure binning
44+
binner.setChannels(2);
45+
binner.setBits(16);
46+
binner.setBinSize(BINSIZE);
47+
binner.setAverage(true);
48+
49+
// Define CSV Output
50+
serial_out.begin(info_out);
51+
52+
}
53+
54+
// Arduino loop - copy sound to out with conversion
55+
void loop() {
56+
copier.copy();
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @file channel-converter-bin-diff.ino
3+
* @author Urs Utzinger
4+
* @brief On two channels reduce number of samples by binning, then compute difference between two channels
5+
* @copyright GPLv3
6+
**/
7+
8+
#include "AudioTools.h"
9+
10+
#define BINSIZE 4
11+
12+
AudioInfo info1(44100, 1, 16);
13+
AudioInfo info2(44100, 2, 16);
14+
AudioInfo info_out(44100/BINSIZE, 1, 16);
15+
SineWaveGenerator<int16_t> sineWave1(16000); // subclass of SoundGenerator with max amplitude of 32000
16+
SineWaveGenerator<int16_t> sineWave2(16000); // subclass of SoundGenerator with max amplitude of 32000
17+
GeneratedSoundStream<int16_t> sound1(sineWave1); // stream generated from sine wave
18+
GeneratedSoundStream<int16_t> sound2(sineWave2); // stream generated from sine wave
19+
InputMerge<int16_t> imerge;
20+
ChannelBinDiff bindiffer; // Binning each channel by average length, setup see below
21+
ConverterStream<int16_t> converted_stream(imerge, bindiffer); // pipe the merged sound to the converter
22+
CsvOutput<int16_t> serial_out(Serial); // serial output
23+
StreamCopy copier(serial_out, converted_stream); // stream the binner output to serial port
24+
25+
// Arduino Setup
26+
void setup(void) {
27+
// Open Serial
28+
Serial.begin(115200);
29+
while(!Serial);
30+
31+
AudioLogger::instance().begin(Serial, AudioLogger::Debug); // Info, Warning, Error, Debug
32+
33+
// Setup sine wave
34+
sineWave1.begin(info1, N_B4);
35+
sineWave2.begin(info1, N_B5);
36+
37+
// Merge input to stereo
38+
imerge.add(sound1);
39+
imerge.add(sound2);
40+
imerge.begin(info2);
41+
42+
// Setup binning
43+
bindiffer.setChannels(2);
44+
bindiffer.setBits(16);
45+
bindiffer.setBinSize(BINSIZE);
46+
bindiffer.setAverage(true);
47+
48+
// Define CSV Output
49+
serial_out.begin(info_out);
50+
51+
}
52+
53+
// Arduino loop - copy sound to out with conversion
54+
void loop() {
55+
copier.copy();
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @file channel-converter-decimate.ino
3+
* @author Urs Utzinger
4+
* @brief Reduce samples by binning; which is summing consecutive samples and optionally dividing by the number of samples summed.
5+
* @copyright GPLv3
6+
**/
7+
8+
#include "AudioTools.h"
9+
#define FACTOR 4
10+
11+
AudioInfo info1(44100, 1, 16);
12+
AudioInfo info2(44100, 2, 16);
13+
AudioInfo infoO(44100/FACTOR, 2, 16);
14+
SineWaveGenerator<int16_t> sineWave1(16000); // subclass of SoundGenerator with max amplitude of 32000
15+
SineWaveGenerator<int16_t> sineWave2(16000); // subclass of SoundGenerator with max amplitude of 32000
16+
GeneratedSoundStream<int16_t> sound1(sineWave1); // stream generated from sine wave
17+
GeneratedSoundStream<int16_t> sound2(sineWave2); // stream generated from sine wave
18+
InputMerge<int16_t> imerge;
19+
Decimate decimater; // decimate by 4 on 1 channel
20+
ConverterStream<int16_t> decimated_stream(imerge, decimater); // pipe the sound to the binner
21+
CsvOutput<int16_t> serial_out(Serial); // serial output
22+
StreamCopy copier(serial_out, decimated_stream); // stream the binner output to serial port
23+
24+
// Arduino Setup
25+
void setup(void) {
26+
27+
// Open Serial
28+
Serial.begin(115200);
29+
while(!Serial);
30+
31+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
32+
33+
//
34+
decimater.setChannels(2);
35+
decimater.setFactor(FACTOR);
36+
37+
// Merge input to stereo
38+
imerge.add(sound1);
39+
imerge.add(sound2);
40+
imerge.begin(info2);
41+
42+
// Setup sine wave
43+
sineWave1.begin(info1, N_B4);
44+
sineWave2.begin(info1, N_B5);
45+
46+
// Define CSV Output
47+
serial_out.begin(infoO);
48+
49+
}
50+
51+
// Arduino loop - copy sound to out with conversion
52+
void loop() {
53+
copier.copy();
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @file channel-converter-diff.ino
3+
* @brief Test calculating parwise difference of channels
4+
* @author Urs Utzinger
5+
* @copyright GPLv3
6+
**/
7+
8+
#include "AudioTools.h"
9+
10+
AudioInfo info1(44100, 1, 16);
11+
AudioInfo info2(44100, 2, 16);
12+
SineWaveGenerator<int16_t> sineWave1(16000); // subclass of SoundGenerator with max amplitude of 32000
13+
SineWaveGenerator<int16_t> sineWave2(16000); // subclass of SoundGenerator with max amplitude of 32000
14+
GeneratedSoundStream<int16_t> sound1(sineWave1); // stream generated from sine wave1
15+
GeneratedSoundStream<int16_t> sound2(sineWave2); // stream generated from sine wave2
16+
InputMerge<int16_t> imerge; // merge two inputs to stereo
17+
ChannelDiff differ; // channel averager
18+
ConverterStream<int16_t> diffed_stream(imerge, differ); // pipe the sound to the averager
19+
CsvOutput<int16_t> serial_out(Serial); // serial output
20+
StreamCopy copier(serial_out, diffed_stream); // stream the binner output to serial port
21+
22+
// Arduino Setup
23+
void setup(void) {
24+
25+
// Open Serial
26+
Serial.begin(115200);
27+
while(!Serial); // wait for Serial to be ready
28+
29+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
30+
31+
// Setup sine waves
32+
sineWave1.begin(info1, N_B4);
33+
sineWave2.begin(info1, N_B5);
34+
35+
// Merge input to stereo
36+
imerge.add(sound1);
37+
imerge.add(sound2);
38+
imerge.begin(info2);
39+
40+
// Define CSV Output
41+
serial_out.begin(info1);
42+
43+
}
44+
45+
// Arduino loop - copy sound to out with conversion
46+
void loop() {
47+
copier.copy();
48+
}

0 commit comments

Comments
 (0)