added matlab

This commit is contained in:
2025-08-21 07:27:52 +02:00
parent fd522e1b99
commit 64c6745c76
50 changed files with 2516 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
function eval_lfo()
L = 10000;
fs = 44100;
fstart = 40;
fend = 400;
df = (fend-fstart)/L;
ip = 0 % phase of the first output sample in radians
w = freq*pi / samplerate
b1 = 2.0 * cos(w)
% Init
y1=sin(ip-w)
y2=sin(ip-2*w)
% Loop
for n=1:L,
y0 = b1*y1 - y2
y2 = y1
y1 = y0
close all
figure;
plot(1:L, vsaw, 1:L, vblit); grid;
wavwrite(0.5*vtri, fs, 'tri.wav');
wavwrite(0.5*vsqr, fs, 'sqr.wav');
wavwrite(0.5*vsaw, fs, 'saw.wav');
wavwrite(0.5*vblit, fs, 'blit.wav');
+44
View File
@@ -0,0 +1,44 @@
function eval_lfo()
L = 10000;
fs = 44100;
fstart = 44;
fend = 400;
df = (fend-fstart)/L;
ip = 0 % phase of the first output sample in radians
% Init
% Loop
f = fstart;
fchg = 1;
y1=sin(ip-f*pi / fs);
y2=sin(ip-2*f*pi / fs);
for n=1:L,
if fchg == 1,
b1 = 2.0 * cos(f*pi / fs);
fchg = 1000;
end;
y0 = b1*y1 - y2;
y2 = y1;
y1 = y0;
fchg = fchg - 1;
lfo(n) = y0;
f = f + df;
close all
end;
figure;
plot(1:L, lfo); grid;
wavwrite(0.5*lfo, fs, 'lfo.wav');
+47
View File
@@ -0,0 +1,47 @@
function eval_lfo2()
L = 80000;
fs = 48000;
fstart = 10;
fend = 1000;
df = (fend-fstart)/L;
ip = 0.0 % phase of the first output sample in radians
% Init
% Loop
f = fstart;
fchg = 0;
ylast = 0;
a = 0.5;
b = 2.0 * sin(f*pi / fs);
y0 = a*cos(2*pi*ip);
y1 = a*sin(2*pi*ip);
for n=1:L,
y0 = y0 - b*y1;
y1 = y1 + b*y0;
fchg = (mod(n, 1000) == 0);
if fchg
b = 2.0 * sin(f*pi / fs);
end
ylast = y1;
lfo(n) = y0;
f = f + df;
close all
end;
figure;
plot(1:L, lfo); grid;
wavwrite(0.5*lfo, fs, 'lfo.wav');
+47
View File
@@ -0,0 +1,47 @@
function eval_lfo2()
L = 80000;
fs = 48000;
fstart = 10;
fend = 5000;
df = (fend-fstart)/L;
ip = 0.0 % phase of the first output sample in radians
% Init
% Loop
f = fstart;
fchg = 0;
ylast = 0;
a = 0.5;
b = 2.0 * sin(f*pi / fs);
y0 = a*cos(2*pi*ip);
y1 = a*sin(2*pi*ip);
for n=1:L,
y0 = y0 - b*y1;
y1 = y1 + b*y0;
fchg = (mod(n, 1000) == 0);
if fchg
b = 2.0 * sin(f*pi / fs);
end
ylast = y1;
lfo(n) = y0;
f = f + df;
close all
end;
figure;
plot(1:L, lfo); grid;
wavwrite(0.5*lfo, fs, 'lfo.wav');
+21
View File
@@ -0,0 +1,21 @@
function eval_smooth(Ta)
fs = 10000;
b = 1;
if (abs(Ta) > 0)
b = 1/(abs(Ta)*fs);
end;
a = 1 - b;
x = [ zeros(1, 1000) ones(1, 1000) zeros(1, 1000)];
y = 0;
for i=1:length(x)
if (Ta < 0)
y = b*x(i) + a*y;
yn(i) = y;
end;
plot(yn); grid;
+34
View File
@@ -0,0 +1,34 @@
function eval_smooth(Ta)
fs = 10000;
b = 1;
if (abs(Ta) > 0)
b = 1/(abs(Ta)*fs);
end;
a = 1 - b;
x = [ zeros(1, 1000) ones(1, 1000) zeros(1, 1000)];
N = length(x);
y = 0;
y1 = 0;
for i=1:length(x)
y1 = b*x(i) + a*y1;
% if (Ta > 0)
y1n(i) = y1;
% else
y2n(i) = 2*x(i) - y1;
% end
end;
subplot(3, 1, 1)
plot(1:N, x, 'r'); grid;
xlabel('Original LFO Wellenform (Square)')
subplot(3, 1, 2)
plot(1:N, y1n, 'r'); grid;
xlabel('Positive smoothed')
subplot(3, 1, 3)
plot(1:N, y2n, 'r'); grid;
xlabel('Negative smoothed')
BIN
View File
Binary file not shown.