Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions algorithm/edrumulus.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions algorithm/signalsandsettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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, :);
Expand Down Expand Up @@ -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;
Expand Down
40 changes: 40 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

#pragma once

#define USE_MIDI

// #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
Expand Down Expand Up @@ -69,3 +73,39 @@ 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() \
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()
#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
32 changes: 3 additions & 29 deletions edrumulus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,48 +104,22 @@ 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();

// Query samples -------------------------------------------------------------
// note that this is a blocking function
edrumulus_hardware.capture_samples(number_pads,
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++)
{
Expand Down
2 changes: 0 additions & 2 deletions edrumulus.ino
Original file line number Diff line number Diff line change
@@ -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).
Expand Down