From 7f5d793c1d82fbbeef811d2642eac996f25217f9 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 14 Jan 2026 18:08:15 +0100 Subject: [PATCH 1/4] create macro DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT --- algorithm/edrumulus.m | 9 ++++++--- common.h | 22 ++++++++++++++++++++++ edrumulus.cpp | 14 +------------- edrumulus.ino | 2 -- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/algorithm/edrumulus.m b/algorithm/edrumulus.m index ef93cd5..b0e64f0 100644 --- a/algorithm/edrumulus.m +++ b/algorithm/edrumulus.m @@ -93,12 +93,15 @@ function edrumulus(x, pad_input) % prepare serial port pkg load instrument-control try - a = serialport("/dev/ttyACM0", 115200); + a = serialport("/dev/ttyUSB0", 115200); catch end flush(a); % send the input data vector for i = 1:length(x) + if mod(i, 100) == 0 + disp(i); + end % write sample write(a, sprintf('%.5f\n', x(i, 1)), 'char'); if ( size(x, 2) > 1 ) @@ -116,8 +119,8 @@ function edrumulus(x, pad_input) y(i) = str2double(char(bytearray)); end %figure; plot(10 * log10(abs(circshift(y, -27)))+40,'*'); grid on; -%figure; plot(10 * log10(y)); grid on; -figure; plot(10 * log10(y),'*'); grid on; +figure; plot(10 * log10(y)); grid on; +%figure; plot(10 * log10(y),'*'); grid on; %figure; plot(20 * log10(abs(y))); grid on; %figure; plot(y+40, '*'); grid on; %figure; plot(y, '*'); grid on; diff --git a/common.h b/common.h index 58d11e8..20809ba 100644 --- a/common.h +++ b/common.h @@ -3,7 +3,10 @@ #pragma once +#define USE_MIDI + // #define USE_SERIAL_DEBUG_PLOTTING +// #define USE_OCTAVE_SAMPLE_IMPORT_EXPORT #define VERSION_MAJOR 0 #define VERSION_MINOR 10 @@ -69,3 +72,22 @@ class FastWriteFIFO int pointer; int fifo_length; }; + +// Debugging functions --------------------------------------------------------- +// Debugging: take samples from Octave, process and return result to Octave +#ifdef USE_OCTAVE_SAMPLE_IMPORT_EXPORT +# undef USE_MIDI +# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad) \ + if (Serial.available() > 0) \ + { \ + static int m = micros(); \ + if (micros() - m > 500000) pad[0].set_velocity_threshold(14.938); \ + m = micros(); \ + float fIn = Serial.parseFloat(); \ + float y = pad[0].process_sample(&fIn, 1, overload_detected, peak_found[0], midi_velocity[0], midi_pos[0], rim_state[0], is_choke_on[0], is_choke_off[0]); \ + Serial.println(y, 7); \ + } \ + return; +#else +# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad) +#endif diff --git a/edrumulus.cpp b/edrumulus.cpp index e8307cb..eefba76 100644 --- a/edrumulus.cpp +++ b/edrumulus.cpp @@ -104,19 +104,7 @@ void Edrumulus::setup(const int conf_num_pads, void Edrumulus::process() { - /* - // TEST for debugging: take samples from Octave, process and return result to Octave - if (Serial.available() > 0) - { - static int m = micros(); if (micros() - m > 500000) pad[0].set_velocity_threshold(14.938); m = micros(); // 17 dB threshold - float fIn[2]; fIn[0] = Serial.parseFloat(); fIn[1] = 0.0f;//Serial.parseFloat(); - bool peak_found_debug, is_rim_shot_debug, is_choke_on_debug, is_choke_off_debug; - int midi_velocity_debug, midi_pos_debug; - float y = pad[0].process_sample(fIn, false, peak_found_debug, midi_velocity_debug, midi_pos_debug, is_rim_shot_debug, is_choke_on_debug, is_choke_off_debug); - Serial.println(y, 7); - } - return; - */ + DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad); // Query samples ------------------------------------------------------------- // note that this is a blocking function diff --git a/edrumulus.ino b/edrumulus.ino index 072e6a0..d857803 100644 --- a/edrumulus.ino +++ b/edrumulus.ino @@ -1,8 +1,6 @@ // Copyright (c) 2020-2026 Volker Fischer // SPDX-License-Identifier: GPL-2.0-or-later -#define USE_MIDI - // ESP32 default pin definition ("-1" means that this channel is unused): // For older prototypes or custom implementations, simply change the GPIO numbers in the table below // to match your hardware (note that the GPIO assignment of Prototype 2 is the same as Prototype 4). From b264fb16e88cccdb726b5bce44f4745e76cbc225 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 14 Jan 2026 18:16:28 +0100 Subject: [PATCH 2/4] add macro DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR --- common.h | 15 +++++++++++++++ edrumulus.cpp | 18 ++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common.h b/common.h index 20809ba..eddf65d 100644 --- a/common.h +++ b/common.h @@ -7,6 +7,7 @@ // #define USE_SERIAL_DEBUG_PLOTTING // #define USE_OCTAVE_SAMPLE_IMPORT_EXPORT +// #define USE_LOW_SAMPLING_RATE_SAMPLE_MONITOR #define VERSION_MAJOR 0 #define VERSION_MINOR 10 @@ -91,3 +92,17 @@ class FastWriteFIFO #else # define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad) #endif + +// Debugging: for plotting all captures samples in the serial plotter (but with low sampling rate) +#ifdef USE_LOW_SAMPLING_RATE_SAMPLE_MONITOR +# undef USE_MIDI +# define DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR() String serial_print; \ + for (int i = 0; i < number_pads; i++) { \ + for (int j = 0; j < number_inputs[i]; j++) { \ + serial_print += String(sample_org[i][j]) + "\t"; \ + } \ + } \ + Serial.println(serial_print); +#else +# define DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR() +#endif diff --git a/edrumulus.cpp b/edrumulus.cpp index eefba76..a47fb84 100644 --- a/edrumulus.cpp +++ b/edrumulus.cpp @@ -112,28 +112,14 @@ void Edrumulus::process() number_inputs, sample_org); + DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR(); + // for load indicator we need to store current time right after blocking function if (use_load_indicator) { load_indicator_prev_micros = micros(); } - /* - // TEST for plotting all captures samples in the serial plotter (but with low sampling rate) - String serial_print; - for (int i = 0; i < number_pads; i++) - { - //if (!pad[i].get_is_control()) - { - for (int j = 0; j < number_inputs[i]; j++) - { - serial_print += String(sample_org[i][j]) + "\t"; - } - } - } - Serial.println(serial_print); - */ - // Process samples ----------------------------------------------------------- for (int i = 0; i < number_pads; i++) { From 129093ece641a25e450bda707d06a3fcd71dea3c Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 14 Jan 2026 18:22:32 +0100 Subject: [PATCH 3/4] small fix --- algorithm/signalsandsettings.m | 6 +++--- common.h | 4 ++-- edrumulus.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/algorithm/signalsandsettings.m b/algorithm/signalsandsettings.m index c78e8dd..1674faf 100644 --- a/algorithm/signalsandsettings.m +++ b/algorithm/signalsandsettings.m @@ -17,7 +17,7 @@ %x = audioread("signals/teensy4_0_pd80r.wav");x=(x-mean(x))*4;padtype='pd80r';%x = x(1:390000, :);% %x = audioread("signals/teensy4_0_pd80r_hot_spot.wav");x=(x-mean(x))*4;padtype='pd80r'; %x = audioread("signals/teensy4_0_pd120_hot_spot.wav");x=(x-mean(x))*4; -%x = audioread("signals/esp32_pd120.wav");x=x/8; +x = audioread("signals/esp32_pd120.wav");x=x/8; %x = audioread("signals/esp32_pd8.wav");x=x/8;padtype='pd8'; %x = audioread("signals/pd120_pos_sense.wav");%x=x(10600:15000);%x = x(2900:10000, :);%x = x(55400:58000, :);% %x = audioread("signals/pd120_pos_sense2.wav"); @@ -32,7 +32,7 @@ %x = audioread("signals/pd80r_hot_spot.wav");padtype='pd80r';%x = x(191700:192400, :);% %x = audioread("signals/pd80r_no_hot_spot.wav");padtype='pd80r'; %x = audioread("signals/pd80r_rimshot_issue.wav");padtype='pd80r'; -x = audioread("signals/pd85rimshotpossense.wav");padtype='pd80r'; +%x = audioread("signals/pd85rimshotpossense.wav");padtype='pd80r'; %x = audioread("signals/hd120.wav");padtype='hd120';x = x(1:75500, :);%x = x(75500:end, :); %x = audioread("signals/pda120ls.wav");x=x(:,1);padtype='pda120ls';x = x(1:630000, :);%x = x(1.06e6:end, :);%x = x(840000:930000, :);% %x = audioread("signals/pda120ls_2.wav");x=x(:,1);padtype='pda120ls';x = x(1:210000, :); @@ -70,7 +70,7 @@ x = x * 25000; - + % pad PRESET settings first, then overwrite these with pad specific properties pad.threshold_db = 17; pad.mask_time_ms = 6; diff --git a/common.h b/common.h index eddf65d..37f8e39 100644 --- a/common.h +++ b/common.h @@ -78,7 +78,7 @@ class FastWriteFIFO // Debugging: take samples from Octave, process and return result to Octave #ifdef USE_OCTAVE_SAMPLE_IMPORT_EXPORT # undef USE_MIDI -# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad) \ +# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT() \ if (Serial.available() > 0) \ { \ static int m = micros(); \ @@ -90,7 +90,7 @@ class FastWriteFIFO } \ return; #else -# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad) +# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT() #endif // Debugging: for plotting all captures samples in the serial plotter (but with low sampling rate) diff --git a/edrumulus.cpp b/edrumulus.cpp index a47fb84..113537c 100644 --- a/edrumulus.cpp +++ b/edrumulus.cpp @@ -104,7 +104,7 @@ void Edrumulus::setup(const int conf_num_pads, void Edrumulus::process() { - DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(pad); + DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT(); // Query samples ------------------------------------------------------------- // note that this is a blocking function From b942a9ea98301bc53f2f2b63be375c1d0c25f48e Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 14 Jan 2026 18:24:22 +0100 Subject: [PATCH 4/4] clang format --- common.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/common.h b/common.h index 37f8e39..64e7fc0 100644 --- a/common.h +++ b/common.h @@ -78,7 +78,7 @@ class FastWriteFIFO // Debugging: take samples from Octave, process and return result to Octave #ifdef USE_OCTAVE_SAMPLE_IMPORT_EXPORT # undef USE_MIDI -# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT() \ +# define DBG_FCT_OCTAVE_SAMPLE_IMPORT_EXPORT() \ if (Serial.available() > 0) \ { \ static int m = micros(); \ @@ -96,12 +96,15 @@ class FastWriteFIFO // Debugging: for plotting all captures samples in the serial plotter (but with low sampling rate) #ifdef USE_LOW_SAMPLING_RATE_SAMPLE_MONITOR # undef USE_MIDI -# define DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR() String serial_print; \ - for (int i = 0; i < number_pads; i++) { \ - for (int j = 0; j < number_inputs[i]; j++) { \ +# define DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR() \ + String serial_print; \ + for (int i = 0; i < number_pads; i++) \ + { \ + for (int j = 0; j < number_inputs[i]; j++) \ + { \ serial_print += String(sample_org[i][j]) + "\t"; \ - } \ - } \ + } \ + } \ Serial.println(serial_print); #else # define DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR()