Skip to content

Commit 8283a56

Browse files
cleanup audio test arrays
add manual builds
1 parent a4c9c01 commit 8283a56

File tree

2 files changed

+52
-32
lines changed

2 files changed

+52
-32
lines changed

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,33 @@ 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+
if: github.event_name != 'workflow_dispatch' ||
19+
github.event.inputs.build_all == 'true' ||
20+
matrix.sketch.manual_only == false
21+
name: Build ${{ matrix.board.name }} - ${{ matrix.sketch.name }}
1322
runs-on: ubuntu-latest
1423

1524
strategy:
1625
fail-fast: false
1726
matrix:
1827
sketch:
19-
- ml_audio_test
20-
- ml_midi_monitor
28+
- name: ml_audio_test
29+
manual_only: false
30+
- name: ml_midi_monitor
31+
manual_only: false
32+
- name: ml_epiano_example
33+
manual_only: true
34+
- name: ml_mod_tracker
35+
manual_only: true
2136

2237
board:
2338

@@ -159,15 +174,18 @@ jobs:
159174
exclude:
160175
- board:
161176
name: "XIAO_ESP32C3"
162-
sketch: ml_audio_test
177+
sketch:
178+
name: ml_audio_test
163179

164180
- board:
165181
name: "ESP32C3 Dev Module"
166-
sketch: ml_audio_test
182+
sketch:
183+
name: ml_audio_test
167184

168185
- board:
169186
name: "Generic STM32F4 Series - BlackPill F411CE"
170-
sketch: ml_audio_test
187+
sketch:
188+
name: ml_audio_test
171189

172190
steps:
173191
- uses: actions/checkout@v4
@@ -215,8 +233,8 @@ jobs:
215233
216234
arduino-cli compile \
217235
--fqbn "$FULL_FQBN" \
218-
--output-dir build/${{ matrix.board.fname }}-${{ matrix.sketch }} \
219-
examples/${{ matrix.sketch }}
236+
--output-dir build/${{ matrix.board.fname }}-${{ matrix.sketch.name }} \
237+
examples/${{ matrix.sketch.name }}
220238
221239
- name: Generate UF2 (SAMD21)
222240
if: matrix.board.family == 'SAMD21'
@@ -233,8 +251,8 @@ jobs:
233251
- name: Upload Artifact
234252
uses: actions/upload-artifact@v4
235253
with:
236-
name: firmware-${{ matrix.board.fname }}-${{ matrix.sketch }}
237-
path: build/${{ matrix.board.fname }}-${{ matrix.sketch }}
254+
name: firmware-${{ matrix.board.fname }}-${{ matrix.sketch.name }}
255+
path: build/${{ matrix.board.fname }}-${{ matrix.sketch.name }}
238256

239257
- name: Create Release
240258
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)