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
Binary file added algorithm/signals/esp32_pd120_hot_spot.wav
Binary file not shown.
3 changes: 2 additions & 1 deletion algorithm/signalsandsettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
%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_pd120_hot_spot.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 Down
23 changes: 23 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// #define USE_SERIAL_DEBUG_PLOTTING
// #define USE_OCTAVE_SAMPLE_IMPORT_EXPORT
// #define USE_LOW_SAMPLING_RATE_SAMPLE_MONITOR
// #define USE_CAPTURE_ONE_BLOCK_OF_SAMPLES

#define VERSION_MAJOR 0
#define VERSION_MINOR 10
Expand Down Expand Up @@ -109,3 +110,25 @@ class FastWriteFIFO
#else
# define DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR()
#endif

// Debugging: capture one block of samples
#ifdef USE_CAPTURE_ONE_BLOCK_OF_SAMPLES
# undef USE_MIDI
# define DBG_FCT_CAPTURE_ONE_BLOCK_OF_SAMPLES() \
const int number_samples = 9000; \
static uint16_t s[number_samples]; \
static int cnt = 0; \
if (cnt >= 0) s[cnt] = sample_org[0][0]; \
cnt++; \
if (cnt >= number_samples) \
{ \
cnt = 0; \
Serial.println(String(0) + "\t" + String(0)); \
for (int j = 0; j < number_samples; j++) \
{ \
Serial.println(s[j]); \
} \
}
#else
# define DBG_FCT_CAPTURE_ONE_BLOCK_OF_SAMPLES()
#endif
1 change: 1 addition & 0 deletions edrumulus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void Edrumulus::process()
sample_org);

DBG_FCT_LOW_SAMPLING_RATE_SAMPLE_MONITOR();
DBG_FCT_CAPTURE_ONE_BLOCK_OF_SAMPLES();

// for load indicator we need to store current time right after blocking function
if (use_load_indicator)
Expand Down
140 changes: 140 additions & 0 deletions tools/misc/capture_samples.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
% Copyright (c) 2020-2026 Volker Fischer
% SPDX-License-Identifier: GPL-2.0-or-later

% capture samples which were recorded on the ESP32 device

close all
pkg load instrument-control


% optionally, post process recorded data
if false

load('recording2026-01-20-08-34-33.mat');
o{1} = out;
load('recording2026-01-20-08-37-55.mat');
o{2} = out;
load('recording2026-01-20-08-41-06.mat');
o{3} = out;
load('recording2026-01-20-08-42-15.mat');
o{4} = out;
load('recording2026-01-20-08-43-25.mat');
o{5} = out;
load('recording2026-01-20-08-44-28.mat');
o{6} = out;

% o1:
id{1} = [ 4, 6, 8, 9, 10];
rg{1} = {1:8426, 400:8100, 1:8000, 1:8000, 1:7800};
% o2:
id{2} = [ 5, 10];
rg{2} = {1:7400, 600:8300};
% o3:
id{3} = [ 2, 6, 7, 9, 10];
rg{3} = {1:7300, 1:8390, 1:7400, 1:7600, 1:7700};
% o4:
id{4} = [ 4, 5, 9];
rg{4} = {400:7800, 1:8400, 600:8000};
% o5:
id{5} = [ 3, 4, 5, 7, 8, 10];
rg{5} = {1000:8000, 1:8400, 1:8000, 1:8000, 1:8400, 600:8200};
% o6:
id{6} = [ 3, 4, 6, 7, 9];
rg{6} = {1:7700, 800:7900, 1:8000, 1:7300, 1:7300};

%n = 1;
%for i = 1:length(id{n})
% cur_id = id{n}(i);
% figure; plot(o{n}{cur_id}); title(num2str(cur_id));
% %figure; plot(o{n}{cur_id}(rg{n}{i})); title(num2str(cur_id));
%end

out = [];
for n = 1:length(id)
for i = 1:length(id{n})
cur_id = id{n}(i);
out = [out; o{n}{cur_id}(rg{n}{i})];
end
end
out = out(~isnan(out));
figure; plot(out);
audiowrite('testout.wav', (out - mean(out)) / 4096, 8000);

return;
end





% prepare serial port
try
a = serialport("/dev/ttyUSB0", 115200);
%set(a, 'bytesize', 8);
%set(a, 'parity', 'n');
%set(a, 'stopbits', 1);
catch
disp('error');
end


figure;

N = 3;
out = cell(N, 1);

for k = 1:N

block_end_found = false;
out{k} = [];

while ~block_end_found

% carriage return is 13 + 10 -> use 10 as start and 13 as end marker
while fread(a, 1) ~= 10
end

end_found = false;
samples = '';
while ~end_found

x = fread(a, 1);
samples = [samples, char(x)];

if x == 13
end_found = true;
end

end

% convert from string to numbers for all channels
try
y = strsplit(samples, '\t');
catch
disp(samples)
disp(test)
end_try_catch

if length(y) == 1
out{k} = [out{k}; str2double(y{1})];
else
block_end_found = true;
end

end

plot(out{k}, '.-');
drawnow;

end

%disp(out)

%fn = strcat('recording', datestr(now, 'yyyy-mm-dd-HH-MM-SS'), '.mat');
%save(fn, 'out');
%system('play -q -n synth 0.2 sine 1000');

clear a



Loading