Merge pull request #36 from ltcptgeneral/DarellsAnnex

EQ Added and a different Pitch Envelope
This commit is contained in:
darrll27 2021-12-09 13:23:06 -08:00 committed by GitHub
commit 69c65bbc4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 0 deletions

Binary file not shown.

View 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
View 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

View File

@ -1,6 +1,8 @@
function output = PitchEnvelopeSelect(input, Fs, attack,decay,sustain,release,number)
if(number == "Option 1")
output = DarellAnnePitchEnvelope(input, Fs, attack,decay,sustain,release);
elseif(number == "Option 2")
output = DarellAnneLinearPitchEnvelope(input, Fs, attack,decay,sustain,release);
else
output = input;
end