Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs = 44000;
- T = 1;
- t = 0 : 1/fs : T;
- t = t(1:fs * T);
- f0 = 110;
- % A = [3615 1111 2081 853 1768 600 714 603 250 98]'; % type 1
- % A = [4382 1499 823 695 958 376 317 204 271 124]'; % type 2
- A = [44 21 10 8 11 2 1 1 0]'; % type 3
- % A = [50 20 4 5 7 5 4 2 2 1]'; % type 4
- attack = 0.2;
- decay = 0.3;
- sustain_value = 0.8;
- release = 0.1;
- sustain = 1 - attack - decay - release;
- obalka = t / attack; % attack
- obalka(attack * fs : (attack + decay) * fs - 1) = 1 - (sustain_value) .* t(1:decay * fs);
- obalka((attack + decay) * fs : end - attack * fs) = sustain_value; % sustain
- obalka(end - nabeh * fs + 1:end) = fliplr(sustain_value * t(1:fs*nabeh) / nabeh);
- obalka = obalka(1:fs * T);
- tony = [0 2 4 5 7 9 11 12];
- step = 2 ^ (1 / 12);
- FV = 2 .* (step .^ tony);
- N = length(A);
- total = [];
- for i = 1:8
- F = FV(i) * f0 * [1:N]';
- vibratto = 1 + sin(2 * pi * 10 * t) / 1.2;
- signals = A .* sawtooth(2 * pi * F .* t);
- signal = vibratto .* obalka .* sum(signals);
- total = [total signal];
- end
- sound(total, fs)
Advertisement
Add Comment
Please, Sign In to add comment