-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpluck_one_string_pitch_control.mdl
103 lines (76 loc) · 4.41 KB
/
pluck_one_string_pitch_control.mdl
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# MDL file for Synth-A-Modeler
#
# (c) Edgar Berdahl, 2012
# Audio Communication Group
# Technical University of Berlin
#
# -------------------------------------------------------------------
#
# The above copyright notice including the copyright holders and this
# permission notice shall be included in all copies, substantial
# portions, or derivatives of the Software and Software portions.
#
# The end-user documentation included with the redistribution, if any,
# must include the following acknowledgment: "This software was
# developed at least in part using Synth-A-Modeler, which is a modular
# and open-source environment for designing physical models (see
# https://github.com/eberdahl/SaM)", in the same place and form as other
# third-party acknowledgments. In addition, this acknowledgment must
# appear in the software itself in the same form and location as other
# such third-party acknowledgments.
#
# Alternatively, if software is generated using Synth-A-Modeler, then
# the end-user documentation included with the generated software, if
# any, must include the following statement: "This software was generated
# using Synth-A-Modeler, which is a modular and open-source environment
# for designing physical models (see https://github.com/eberdahl/SaM)",
# in the same place and form as other third-party acknowledgments. In
# addition, this acknowledgment must appear prominently in any software
# generated by Synth-A-Modeler in the same form and location as other
# such third-party acknowledgments, and in such a manner that users
# will be aware that the software was generated by Synth-A-Modeler.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation except subject to the additional
# attribution requirements described beneath the copyright notice above.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the modified GNU General Public
# License along with this program.
# To do: Maybe make the wave impedance adjustable via the GUI ...
# To specify frequency in Hz
# faustcode: freq=hslider("Frequency [Hz]", 80.0, 20.0, 1000.0, 5.0);
# To specify frequency using MIDI note numbers
faustcode: freqMIDI=hslider("Frequency [MIDI]", 28.0, 20.0, 84.0, 0.05);
faustcode: freq = 440.0*pow(2.0,(freqMIDI-69.0)/12.0);
faustcode: k=hslider("Pluck stiffness [N/m]",750.0,50.0,1000.0,50.0);
faustcode: R=hslider("Pluck damping [N/(m/s)]",0.4,0.0,2.5,0.01);
faustcode: relPos=hslider("Pluck position along length",0.4,0.01,0.99,0.01);
faustcode: maxdisp=hslider("Pluck half-width [m]",0.006,0.001,0.01,0.001);
faustcode: bridgeAtten=hslider("Bridge attenuation",5.5,0.5,7.0,0.01);
faustcode: bridgeFc=hslider("Bridge cutoff freq [Hz]",5200.0,1000.0,fs,10.0);
faustcode: fretAtten=hslider("Fret attenuation",3.46,0.5,7.0,0.01);
faustcode: R0=hslider("String wave impedance",1.6,0.25,7.5,0.1);
faustcode: fretFc=hslider("Fret cutoff freq [Hz]",4180.0,1000.0,fs,10.0);
faustcode: moveStrings=hslider("Waveguides position adjustment",1.0,0.1,1.4,0.01);
faustcode: vol=hslider("Z Volume",0.22,0.01,1.0,0.01) : onePoleBLT(10.0); // LP filter with cutoff frequency at 10Hz smoothes volume control signal
faustcode: outputDSP=highpass(4,20.0);
port(),dev0; # pos 395,45
port(),dev1; # pos 363,277
pluck(k,R,maxdisp,0.0),p0,junct0,dev0;
# These waveguide delay lengths are NOT compensated by the delay introduced by the terminations:
# waveguide(R0,simpleString(0.027,(1.0/freq)*relPos)),wg0,bridge,junct0;
# waveguide(R0,simpleString(0.027,(1.0/freq)*(1.0-relPos))),wg1,fret,junct0;
# These waveguide delay lengths are compensated by the delay introduced by the terminations:
waveguide(R0,simpleString(0.027,(1.0/freq)*relPos-simpleStringTermDelay(bridgeFc))),wg0,bridge,junct0;
waveguide(R0,simpleString(0.027,(1.0/freq)*(1.0-relPos)-simpleStringTermDelay(fretFc))),wg1,fret,junct0;
termination(simpleStringTerm(-1.0+pow(10.0,-bridgeAtten:float), bridgeFc)),bridge; # pos 32,154
termination(simpleStringTerm(-1.0+pow(10.0,-fretAtten:float), fretFc)),fret; # pos 440,146
junction(0.0),junct0; # pos 248,96
audioout,a0,(bridge*vol):outputDSP; # pos 51,280
audioout,a1,(fret*vol):outputDSP; # pos 507,272