Skip to content

Commit 491877b

Browse files
Merge branch 'main' into 105-fix-teensy-integration
2 parents 2df648a + 62880ce commit 491877b

File tree

2 files changed

+124
-36
lines changed

2 files changed

+124
-36
lines changed

.github/workflows/arduino-cli-ci.yml

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,30 @@ on:
66
tags: [ "v*" ]
77
pull_request:
88
branches: [ "main" ]
9+
workflow_dispatch:
10+
inputs:
11+
build_all:
12+
description: "Build heavy sketches too?"
13+
required: false
14+
default: "false"
915

1016
jobs:
1117
build:
12-
name: Build ${{ matrix.board.name }} - ${{ matrix.sketch }}
18+
name: Build ${{ matrix.board.name }} - ${{ matrix.sketch.name }}
1319
runs-on: ubuntu-latest
1420

1521
strategy:
1622
fail-fast: false
1723
matrix:
1824
sketch:
19-
- ml_audio_test
20-
- ml_midi_monitor
25+
- name: ml_audio_test
26+
manual_only: false
27+
- name: ml_midi_monitor
28+
manual_only: false
29+
# - name: ml_epiano_example
30+
# manual_only: true
31+
# - name: ml_mod_tracker
32+
# manual_only: true
2133

2234
board:
2335

@@ -159,15 +171,85 @@ jobs:
159171
exclude:
160172
- board:
161173
name: "XIAO_ESP32C3"
162-
sketch: ml_audio_test
174+
sketch:
175+
name: ml_audio_test
163176

164177
- board:
165178
name: "ESP32C3 Dev Module"
166-
sketch: ml_audio_test
179+
sketch:
180+
name: ml_audio_test
167181

168182
- board:
169183
name: "Generic STM32F4 Series - BlackPill F411CE"
170-
sketch: ml_audio_test
184+
sketch:
185+
name: ml_audio_test
186+
187+
188+
- board:
189+
name: "Teensy 4.1"
190+
sketch:
191+
name: ml_epiano_example
192+
193+
- board:
194+
name: "Generic STM32H7 Series - Daisy Seed"
195+
sketch:
196+
name: ml_epiano_example
197+
198+
- board:
199+
name: "ESP8266 Dev Module"
200+
sketch:
201+
name: ml_epiano_example
202+
203+
- board:
204+
name: "ESP32C3 Dev Module"
205+
sketch:
206+
name: ml_epiano_example
207+
208+
- board:
209+
name: "XIAO_ESP32C3"
210+
sketch:
211+
name: ml_epiano_example
212+
213+
- board:
214+
name: "Seeeduino XIAO (SAMD21)"
215+
sketch:
216+
name: ml_epiano_example
217+
218+
- board:
219+
name: "Generic STM32F4 Series - BlackPill F411CE"
220+
sketch:
221+
name: ml_epiano_example
222+
223+
224+
- board:
225+
name: "XIAO_ESP32C3"
226+
sketch:
227+
name: ml_mod_tracker
228+
229+
- board:
230+
name: "ESP32C3 Dev Module"
231+
sketch:
232+
name: ml_mod_tracker
233+
234+
- board:
235+
name: "ESP8266 Dev Module"
236+
sketch:
237+
name: ml_mod_tracker
238+
239+
- board:
240+
name: "Seeeduino XIAO (SAMD21)"
241+
sketch:
242+
name: ml_mod_tracker
243+
244+
- board:
245+
name: "Generic STM32H7 Series - Daisy Seed"
246+
sketch:
247+
name: ml_mod_tracker
248+
249+
- board:
250+
name: "Generic STM32F4 Series - BlackPill F411CE"
251+
sketch:
252+
name: ml_mod_tracker
171253

172254
steps:
173255
- uses: actions/checkout@v4
@@ -215,8 +297,8 @@ jobs:
215297
216298
arduino-cli compile \
217299
--fqbn "$FULL_FQBN" \
218-
--output-dir build/${{ matrix.board.fname }}-${{ matrix.sketch }} \
219-
examples/${{ matrix.sketch }}
300+
--output-dir build/${{ matrix.board.fname }}-${{ matrix.sketch.name }} \
301+
examples/${{ matrix.sketch.name }}
220302
221303
- name: Generate UF2 (SAMD21)
222304
if: matrix.board.family == 'SAMD21'
@@ -233,8 +315,8 @@ jobs:
233315
- name: Upload Artifact
234316
uses: actions/upload-artifact@v4
235317
with:
236-
name: firmware-${{ matrix.board.fname }}-${{ matrix.sketch }}
237-
path: build/${{ matrix.board.fname }}-${{ matrix.sketch }}
318+
name: firmware-${{ matrix.board.fname }}-${{ matrix.sketch.name }}
319+
path: build/${{ matrix.board.fname }}-${{ matrix.sketch.name }}
238320

239321
- name: Create Release
240322
if: startsWith(github.ref, 'refs/tags/')

src/audio_module.h

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,13 @@ I2S i2s(OUTPUT);
151151
#endif
152152

153153
#ifdef OUTPUT_SAW_TEST
154-
static float saw_left[SAMPLE_BUFFER_SIZE];
155-
static float saw_right[SAMPLE_BUFFER_SIZE];
156-
static int32_t saw_i32[SAMPLE_BUFFER_SIZE];
154+
static float test_signal_saw_left[SAMPLE_BUFFER_SIZE];
155+
static float test_signal_saw_right[SAMPLE_BUFFER_SIZE];
156+
static int32_t test_signal_saw_i32[SAMPLE_BUFFER_SIZE];
157157
#endif
158158
#ifdef OUTPUT_SINE_TEST
159-
static float sin_left[SAMPLE_BUFFER_SIZE];
160-
static float sin_right[SAMPLE_BUFFER_SIZE];
161-
static int32_t sine_i32[SAMPLE_BUFFER_SIZE];
159+
static float test_signal_sin[4][SAMPLE_BUFFER_SIZE];
160+
static int32_t test_signal_sine_i32[4][SAMPLE_BUFFER_SIZE];
162161
#endif
163162

164163
void Audio_Setup(void)
@@ -176,10 +175,10 @@ void Audio_Setup(void)
176175
{
177176
float saw = ((float)i * 2.0f) / ((float)SAMPLE_BUFFER_SIZE);
178177
saw -= 1.0f;
179-
saw_left[i] = saw;
180-
saw_right[i] = saw;
178+
test_signal_saw_left[i] = saw;
179+
test_signal_saw_right[i] = saw;
181180
saw *= 1073741824;
182-
saw_i32[i] = saw;
181+
test_signal_saw_i32[i] = saw;
183182
}
184183
#endif
185184
#ifdef OUTPUT_SINE_TEST
@@ -196,10 +195,13 @@ void Audio_Setup(void)
196195
w *= 1.0f / ((float)SAMPLE_BUFFER_SIZE);
197196
w *= 2.0f * M_PI;
198197
float sine = sin(w);
199-
sin_left[i] = sine;
200-
sin_right[i] = sin(w * 2.0f);
201-
sine *= 1073741824;
202-
sine_i32[i] = sine;
198+
for (int n = 0; n < 4; n++)
199+
{
200+
sine = sin(n * w * 2.0f);
201+
test_signal_sin[n][i] = sine;
202+
sine *= 1073741824;
203+
test_signal_sine_i32[n][i] = sine;
204+
}
203205
}
204206
#endif
205207

@@ -249,10 +251,10 @@ void Audio_Setup(void)
249251
#else /* #ifndef RP2350_USE_I2S_ML_LIB */
250252
rp2350_i2s_init(PICO_AUDIO_I2S_DATA_PIN, PICO_AUDIO_I2S_CLOCK_PIN_BASE);
251253
Serial.printf("rp2350_i2s_init\n");
252-
Serial.printf("\tclock_pin_base: %u (->BCK)\n", PICO_AUDIO_I2S_DATA_PIN);
253-
Serial.printf("\tdata_pin: %u (-> DIN) \n", PICO_AUDIO_I2S_CLOCK_PIN_BASE);
254-
Serial.printf("\tWCLK/LCK: %u\n", PICO_AUDIO_I2S_CLOCK_PIN_BASE + 1);
255254
#endif /* #endif RP2350_USE_I2S_ML_LIB */
255+
Serial.printf("\tclock_pin_base: %u (->BCK)\n", PICO_AUDIO_I2S_CLOCK_PIN_BASE);
256+
Serial.printf("\tdata_pin: %u (-> DIN) \n", PICO_AUDIO_I2S_DATA_PIN);
257+
Serial.printf("\tWCLK/LCK: %u\n", PICO_AUDIO_I2S_CLOCK_PIN_BASE + 1);
256258
#endif
257259

258260

@@ -268,9 +270,13 @@ void Audio_Setup(void)
268270
#ifdef RP2040_AUDIO_PWM
269271
uint8_t pwmPinNumber = RP2040_AUDIO_PWM_PIN;
270272
Serial.printf("Initialize pwm audio used without DAC pin %d + pin %d:\n", pwmPinNumber, pwmPinNumber + 1);
273+
Serial.printf(" F_CPU: %d\n", F_CPU);
271274
Serial.printf(" sample rate: %d\n", SAMPLE_RATE);
272275
Serial.printf(" buffer size: %d\n", SAMPLE_BUFFER_SIZE);
273-
RP2040_Audio_Pwm_Init(pwmPinNumber, SAMPLE_RATE, WavPwmDataBuff, WavPwmDataBuff2, SAMPLE_BUFFER_SIZE);
276+
uint64_t sampleRate_at_125MHz = SAMPLE_RATE;
277+
sampleRate_at_125MHz *= 125000000ULL;
278+
sampleRate_at_125MHz /= ((uint64_t)F_CPU);
279+
RP2040_Audio_Pwm_Init(pwmPinNumber, sampleRate_at_125MHz, WavPwmDataBuff, WavPwmDataBuff2, SAMPLE_BUFFER_SIZE);
274280
#endif
275281

276282
#if 0
@@ -385,7 +391,7 @@ void ProcessAudio(uint16_t *buff, size_t len)
385391
}
386392
}
387393

388-
#endif
394+
#endif /* (defined ARDUINO_SEEED_XIAO_M0) || (defined SEEED_XIAO_M0) */
389395

390396
#ifdef AUDIO_PRINT_STATS
391397
#if (defined ARDUINO_RASPBERRY_PI_PICO) || (defined ARDUINO_GENERIC_RP2040)
@@ -425,10 +431,10 @@ void Audio_Output(const int16_t *samples)
425431
void Audio_OutputMono(const int32_t *samples)
426432
{
427433
#ifdef OUTPUT_SAW_TEST
428-
samples = saw_i32;
434+
samples = (const int32_t *)test_signal_saw_i32;
429435
#endif
430436
#ifdef OUTPUT_SINE_TEST
431-
samples = sine_i32;
437+
samples = (const int32_t *)test_signal_sine_i32;
432438
#endif
433439

434440
#ifdef ESP8266
@@ -525,7 +531,7 @@ void Audio_OutputMono(const int32_t *samples)
525531
memcpy(out_temp[1], sig_f, sizeof(out_temp[1]));
526532

527533
dataReady = false;
528-
#endif /* ARDUINO_DAISY_SEED */
534+
#endif /* (defined ARDUINO_DAISY_SEED) || (defined STM32H7xx) */
529535

530536
#if (defined ARDUINO_SEEED_XIAO_M0) || (defined SEEED_XIAO_M0)
531537
#ifdef CYCLE_MODULE_ENABLED
@@ -539,7 +545,7 @@ void Audio_OutputMono(const int32_t *samples)
539545
#ifdef CYCLE_MODULE_ENABLED
540546
calcCycleCount();
541547
#endif
542-
#endif /* ARDUINO_SEEED_XIAO_M0 */
548+
#endif /* (defined ARDUINO_SEEED_XIAO_M0) || (defined SEEED_XIAO_M0) */
543549

544550
#ifdef ARDUINO_DISCO_F407VGxx
545551
int16_t mono_s16[SAMPLE_BUFFER_SIZE];
@@ -862,12 +868,12 @@ void Audio_Input(float *left __attribute__((__unused__)), float *right __attribu
862868
void Audio_Output(const float *left, const float *right)
863869
{
864870
#ifdef OUTPUT_SAW_TEST
865-
left = saw_left;
866-
right = saw_right;
871+
left = (const float *)test_signal_saw_left;
872+
right = (const float *)test_signal_saw_right;
867873
#endif
868874
#ifdef OUTPUT_SINE_TEST
869-
left = sin_left;
870-
right = sin_right;
875+
left = (const float *)test_signal_sin[0];
876+
right = (const float *)test_signal_sin[1];
871877
#endif
872878

873879
#ifdef ESP32

0 commit comments

Comments
 (0)