Merge pull request #20 from ltcptgeneral/DarellsAnnex
Added Pitch Envelope, most of GUI now working except GUI and EQ.
This commit is contained in:
commit
1061dfdfd0
Binary file not shown.
57
src/DarellAnnePitchEnvelope.m
Normal file
57
src/DarellAnnePitchEnvelope.m
Normal file
@ -0,0 +1,57 @@
|
||||
%Written by Darell and Anne
|
||||
|
||||
function output = DarellAnnePitchEnvelope(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;
|
||||
while tcounter <= curr
|
||||
ncount = round(curr*log(tcounter)/log(curr)+1);
|
||||
output(tcounter) = input(ncount);
|
||||
tcounter = tcounter+1;
|
||||
end
|
||||
|
||||
%decay phase
|
||||
prevcur = curr;
|
||||
tcounter = prevcur;
|
||||
curr = decaytime;
|
||||
while tcounter <= curr
|
||||
ncount = round(sustain*curr*(1-log(tcounter)/log(prevcur)) + prevcur);
|
||||
tcounter = round(tcounter);
|
||||
output(tcounter)
|
||||
output(tcounter) = input(ncount);
|
||||
tcounter = tcounter+1;
|
||||
end
|
||||
|
||||
%sustain phase
|
||||
prevncount = ncount;
|
||||
prevcur = curr;
|
||||
tcounter = prevcur;
|
||||
curr = sustaintime;
|
||||
while tcounter <= curr
|
||||
ncount = round(sustain*(tcounter - prevcur) + prevncount);
|
||||
tcounter = round(tcounter);
|
||||
output(tcounter) = input(ncount);
|
||||
tcounter = tcounter+1;
|
||||
end
|
||||
|
||||
%release phase
|
||||
prevncount = ncount;
|
||||
prevcur = curr;
|
||||
tcounter = prevcur;
|
||||
curr = Fs;
|
||||
while tcounter <= Fs
|
||||
ncount = round(curr*(1-log(tcounter)/log(prevcur)) + prevncount);
|
||||
tcounter = round(tcounter);
|
||||
output(tcounter) = input(ncount);
|
||||
tcounter = tcounter+1;
|
||||
end
|
||||
|
||||
end
|
8
src/FilterSelect.m
Normal file
8
src/FilterSelect.m
Normal file
@ -0,0 +1,8 @@
|
||||
function output = FilterSelect(input,Fs,LOW,MED,HIGH,number)
|
||||
if(number == "Option 1")
|
||||
output = DarellbandpassFilter(input,Fs,LOW,MED,HIGH);
|
||||
else
|
||||
output = input;
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ x = x + generate_sine(amplitude, (frequency+5), phase, fs, duration, duty);
|
||||
|
||||
%play over 5 counts, should hear both frequencies, 5 beats per second between the 2 frequencies
|
||||
playtime = 5;
|
||||
play_continuous(x, fs, playtime)
|
||||
%play_continuous(x, fs, playtime)
|
||||
|
||||
LOW = 0;
|
||||
HIGH = frequency + 1;
|
||||
@ -22,7 +22,14 @@ x = DarellbandpassFilter(x,fs,LOW,MED,HIGH);
|
||||
|
||||
%play over 5 counts, should only hear 200hz
|
||||
playtime = 5;
|
||||
play_continuous(x, fs, playtime)
|
||||
%play_continuous(x, fs, playtime)
|
||||
|
||||
attack = 0.2;
|
||||
decay = 0.1;
|
||||
sustain = 0.8;
|
||||
release = 0.4;
|
||||
|
||||
x = DarellAnnePitchEnvelope(x, Fs, attack,decay,sustain,release);
|
||||
|
||||
attack = 0.2;
|
||||
decay = 0.2;
|
||||
|
@ -1,6 +1,6 @@
|
||||
function output = PitchEnvelopeSelect(input, Fs, attack,decay,sustain,release,number)
|
||||
if(number == "Option 1")
|
||||
output = DarellAmplitudeEnvelope(input, Fs, attack,decay,sustain,release);
|
||||
output = DarellAnnePitchEnvelope(input, Fs, attack,decay,sustain,release);
|
||||
else
|
||||
output = input;
|
||||
end
|
||||
|
Reference in New Issue
Block a user