diff --git a/App/app.mlapp b/App/app.mlapp index 60f0bbc..143c11f 100644 Binary files a/App/app.mlapp and b/App/app.mlapp differ diff --git a/src/DarellAnneLinearPitchEnvelope.m b/src/DarellAnneLinearPitchEnvelope.m new file mode 100644 index 0000000..4cf61f6 --- /dev/null +++ b/src/DarellAnneLinearPitchEnvelope.m @@ -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 \ No newline at end of file diff --git a/src/Equalizer_Darell.m b/src/Equalizer_Darell.m new file mode 100644 index 0000000..1d9e5df --- /dev/null +++ b/src/Equalizer_Darell.m @@ -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 + diff --git a/src/PitchEnvelopeSelect.m b/src/PitchEnvelopeSelect.m index 91bc91c..7cd04c5 100644 --- a/src/PitchEnvelopeSelect.m +++ b/src/PitchEnvelopeSelect.m @@ -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