-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtremolo.m
40 lines (40 loc) · 1.2 KB
/
tremolo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
classdef tremolo < audioPlugin
properties
Depth = 1;
Rate = 1;
end
properties (Constant)
PluginInterface = ...
audioPluginInterface(...
audioPluginParameter('Depth'),...
audioPluginParameter('Rate',...
'Mapping',{'log',0.1,10}))
end
properties
currentPhase = 0;
angleChange = 0.1 * (1/44100) * 2 * pi;
end
methods
function out = process(p,in)
[numSamples,numChannels] = size(in);
out = zeros(numSamples,numChannels);
for s = 1:numSamples
amp = (p.Depth/2) * sin(p.currentPhase) + (1-(p.Depth/2));
out(s,:) = amp * in(s,:);
p.currentPhase = p.currentPhase + p.angleChange;
if p.currentPhase > 2*pi
p.currentPhase = p.currentPhase - 2*pi;
end
end
end
function reset(p)
Fs = getSampleRate(p);
p.angleChange = p.Rate * (1/Fs) * 2 * pi;
end
function set.Rate(p,Rate)
p.Rate = Rate;
Fs = getSampleRate(p);
p.angleChange = p.Rate * (1/Fs) * 2 * pi;
end
end
end