Skip to content

Commit 62880ce

Browse files
Merge pull request #109 from marcel-licence/108-cleanup-audio-test-integration
108 cleanup audio test integration
2 parents a4c9c01 + 13a9ad4 commit 62880ce

File tree

2 files changed

+116
-32
lines changed

2 files changed

+116
-32
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: 24 additions & 22 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

@@ -389,7 +391,7 @@ void ProcessAudio(uint16_t *buff, size_t len)
389391
}
390392
}
391393

392-
#endif
394+
#endif /* (defined ARDUINO_SEEED_XIAO_M0) || (defined SEEED_XIAO_M0) */
393395

394396
#ifdef AUDIO_PRINT_STATS
395397
#if (defined ARDUINO_RASPBERRY_PI_PICO) || (defined ARDUINO_GENERIC_RP2040)
@@ -429,10 +431,10 @@ void Audio_Output(const int16_t *samples)
429431
void Audio_OutputMono(const int32_t *samples)
430432
{
431433
#ifdef OUTPUT_SAW_TEST
432-
samples = saw_i32;
434+
samples = (const int32_t *)test_signal_saw_i32;
433435
#endif
434436
#ifdef OUTPUT_SINE_TEST
435-
samples = sine_i32;
437+
samples = (const int32_t *)test_signal_sine_i32;
436438
#endif
437439

438440
#ifdef ESP8266
@@ -529,7 +531,7 @@ void Audio_OutputMono(const int32_t *samples)
529531
memcpy(out_temp[1], sig_f, sizeof(out_temp[1]));
530532

531533
dataReady = false;
532-
#endif /* ARDUINO_DAISY_SEED */
534+
#endif /* (defined ARDUINO_DAISY_SEED) || (defined STM32H7xx) */
533535

534536
#if (defined ARDUINO_SEEED_XIAO_M0) || (defined SEEED_XIAO_M0)
535537
#ifdef CYCLE_MODULE_ENABLED
@@ -543,7 +545,7 @@ void Audio_OutputMono(const int32_t *samples)
543545
#ifdef CYCLE_MODULE_ENABLED
544546
calcCycleCount();
545547
#endif
546-
#endif /* ARDUINO_SEEED_XIAO_M0 */
548+
#endif /* (defined ARDUINO_SEEED_XIAO_M0) || (defined SEEED_XIAO_M0) */
547549

548550
#ifdef ARDUINO_DISCO_F407VGxx
549551
int16_t mono_s16[SAMPLE_BUFFER_SIZE];
@@ -866,12 +868,12 @@ void Audio_Input(float *left __attribute__((__unused__)), float *right __attribu
866868
void Audio_Output(const float *left, const float *right)
867869
{
868870
#ifdef OUTPUT_SAW_TEST
869-
left = saw_left;
870-
right = saw_right;
871+
left = (const float *)test_signal_saw_left;
872+
right = (const float *)test_signal_saw_right;
871873
#endif
872874
#ifdef OUTPUT_SINE_TEST
873-
left = sin_left;
874-
right = sin_right;
875+
left = (const float *)test_signal_sin[0];
876+
right = (const float *)test_signal_sin[1];
875877
#endif
876878

877879
#ifdef ESP32

0 commit comments

Comments
 (0)