Merge pull request #36 from ltcptgeneral/DarellsAnnex
EQ Added and a different Pitch Envelope
This commit is contained in:
commit
69c65bbc4e
BIN
App/app.mlapp
BIN
App/app.mlapp
Binary file not shown.
88
src/DarellAnneLinearPitchEnvelope.m
Normal file
88
src/DarellAnneLinearPitchEnvelope.m
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
%Written by Darell and Anne
|
||||||
|
|
||||||
|
function output = DarellAnneLinearPitchEnvelope(input, Fs, attack,decay,sustain,release) %percentages for attack, decay, sustain, release
|
||||||
|
len = length(input);
|
||||||
|
T = (len-1)/Fs;
|
||||||
|
attacktime = attack * T * Fs;
|
||||||
|
decaytime = attacktime + decay * T * Fs;
|
||||||
|
sustaintime = (T - (release * T)) * Fs;
|
||||||
|
|
||||||
|
output = zeros([1,len]);
|
||||||
|
|
||||||
|
tcounter = 1;
|
||||||
|
%attack phase
|
||||||
|
curr = attacktime;
|
||||||
|
x = 1:len;
|
||||||
|
y = x .* 0;
|
||||||
|
g = x .* 0;
|
||||||
|
while tcounter <= curr
|
||||||
|
ncount = round((tcounter^2)/(2*curr)+ curr/2);
|
||||||
|
y(tcounter) = ncount; %For Debug Purposes
|
||||||
|
output(tcounter) = input(ncount);
|
||||||
|
tcounter = tcounter+1;
|
||||||
|
end
|
||||||
|
|
||||||
|
%decay phase
|
||||||
|
prevcur = curr;
|
||||||
|
tcounter = prevcur;
|
||||||
|
curr = decaytime;
|
||||||
|
while tcounter <= curr
|
||||||
|
|
||||||
|
t = round(tcounter-prevcur);
|
||||||
|
dur = round(curr-prevcur);
|
||||||
|
dsus = (1-sustain);
|
||||||
|
|
||||||
|
dn = (1 - (dsus)*t/(2*dur))*t;
|
||||||
|
ncount = round(prevcur + dn);
|
||||||
|
tcounter = round(tcounter);
|
||||||
|
|
||||||
|
y(tcounter) = ncount; %For Debug Purposes
|
||||||
|
output(tcounter) = input(ncount);
|
||||||
|
tcounter = tcounter+1;
|
||||||
|
end
|
||||||
|
hold on
|
||||||
|
plot(x,y)
|
||||||
|
plot(x,g)
|
||||||
|
hold off
|
||||||
|
%sustain phase
|
||||||
|
prevncount = ncount;
|
||||||
|
prevcur = curr;
|
||||||
|
tcounter = prevcur;
|
||||||
|
curr = sustaintime;
|
||||||
|
while tcounter <= curr
|
||||||
|
t = round(tcounter-prevcur);
|
||||||
|
ncount = round(sustain*(t) + prevncount);
|
||||||
|
tcounter = round(tcounter);
|
||||||
|
|
||||||
|
y(tcounter) = ncount; %For Debug Purposes
|
||||||
|
output(tcounter) = input(ncount);
|
||||||
|
tcounter = tcounter+1;
|
||||||
|
end
|
||||||
|
|
||||||
|
%release phase
|
||||||
|
prevncount = ncount;
|
||||||
|
prevcur = curr;
|
||||||
|
tcounter = prevcur;
|
||||||
|
curr = Fs;
|
||||||
|
while tcounter <= curr
|
||||||
|
t = round(tcounter-prevcur);
|
||||||
|
dur = round(curr-prevcur);
|
||||||
|
|
||||||
|
dn = (sustain - (sustain)*t/(2*dur))*t;
|
||||||
|
ncount = round(prevncount + dn);
|
||||||
|
|
||||||
|
%ncount = round(prevncount + ((curr-prevcur)*(tcounter-prevcur)/(curr))*(1-log(tcounter+1-prevcur)/log(curr-prevcur)));
|
||||||
|
|
||||||
|
%ncount = round(curr*(1-log(tcounter)/log(prevcur)) + prevncount);
|
||||||
|
|
||||||
|
tcounter = round(tcounter);
|
||||||
|
y(tcounter) = ncount; %For Debug Purposes
|
||||||
|
if ncount > len
|
||||||
|
output(tcounter) = 0;
|
||||||
|
else
|
||||||
|
output(tcounter) = input(ncount);
|
||||||
|
end
|
||||||
|
tcounter = tcounter+1;
|
||||||
|
end
|
||||||
|
plot(x,y) %For Debug Purposes
|
||||||
|
end
|
9
src/Equalizer_Darell.m
Normal file
9
src/Equalizer_Darell.m
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
function output = Equalizer_Darell(input,EQplot,Fs)
|
||||||
|
%It's an EQ written by Darell
|
||||||
|
% Split into frequencies and multiply by EQ
|
||||||
|
Mod_Freq = fftshift(fft(input));
|
||||||
|
filtered_Mod_Freq = fftshift(Mod_Freq .* EQplot);
|
||||||
|
output = real(ifft(filtered_Mod_Freq));
|
||||||
|
%plot(output);
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,8 @@
|
|||||||
function output = PitchEnvelopeSelect(input, Fs, attack,decay,sustain,release,number)
|
function output = PitchEnvelopeSelect(input, Fs, attack,decay,sustain,release,number)
|
||||||
if(number == "Option 1")
|
if(number == "Option 1")
|
||||||
output = DarellAnnePitchEnvelope(input, Fs, attack,decay,sustain,release);
|
output = DarellAnnePitchEnvelope(input, Fs, attack,decay,sustain,release);
|
||||||
|
elseif(number == "Option 2")
|
||||||
|
output = DarellAnneLinearPitchEnvelope(input, Fs, attack,decay,sustain,release);
|
||||||
else
|
else
|
||||||
output = input;
|
output = input;
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user