forked from eberdahl/SaM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpluck_six_half_strings.mdl
130 lines (107 loc) · 6.96 KB
/
pluck_six_half_strings.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# 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.
port(),dev0; # pos 869,78
port(),dev1; # pos 817,371
pluck(k*plSc,R*plSc,maxdisp,0.025*moveStrings),p0,junct0,dev0;
pluck(k*plSc,R*plSc,maxdisp,0.015*moveStrings),p1,junct0cpy2,dev0;
pluck(k*plSc,R*plSc,maxdisp,0.005*moveStrings),p2,junct0cpy3,dev0;
pluck(k*plSc,R*plSc,maxdisp,-0.005*moveStrings),p3,junct0cpy4,dev0;
pluck(k*plSc,R*plSc,maxdisp,-0.015*moveStrings),p4,junct0cpy5,dev0;
pluck(k*plSc,R*plSc,maxdisp,-0.025*moveStrings),p5,junct0cpy6,dev0;
# Calculate bridge cutoff frequencies by linearly interpolating between bridgeFcLow and bridgeFcHigh as a function of the frequency
faustcode: bridgeFc1 = (maxFreq-freq1)/(maxFreq-minFreq)*bridgeFcLow + (freq1-minFreq)/(maxFreq-minFreq)*bridgeFcHigh;
faustcode: bridgeFc2 = (maxFreq-freq2)/(maxFreq-minFreq)*bridgeFcLow + (freq2-minFreq)/(maxFreq-minFreq)*bridgeFcHigh;
faustcode: bridgeFc3 = (maxFreq-freq3)/(maxFreq-minFreq)*bridgeFcLow + (freq3-minFreq)/(maxFreq-minFreq)*bridgeFcHigh;
faustcode: bridgeFc4 = (maxFreq-freq4)/(maxFreq-minFreq)*bridgeFcLow + (freq4-minFreq)/(maxFreq-minFreq)*bridgeFcHigh;
faustcode: bridgeFc5 = (maxFreq-freq5)/(maxFreq-minFreq)*bridgeFcLow + (freq5-minFreq)/(maxFreq-minFreq)*bridgeFcHigh;
faustcode: bridgeFc6 = (maxFreq-freq6)/(maxFreq-minFreq)*bridgeFcLow + (freq6-minFreq)/(maxFreq-minFreq)*bridgeFcHigh;
waveguide(waveImp,simpleString(1.0/minFreq/2.0,1.0/freq1/2.0-simpleStringTermDelay(bridgeFc1))),wg0,term0,junct0;
waveguide(waveImp,simpleString(1.0/minFreq/2.0,1.0/freq2/2.0-simpleStringTermDelay(bridgeFc2))),wg0cpy2,term0cpy2,junct0cpy2;
waveguide(waveImp,simpleString(1.0/minFreq/2.0,1.0/freq3/2.0-simpleStringTermDelay(bridgeFc3))),wg0cpy3,term0cpy3,junct0cpy3;
waveguide(waveImp,simpleString(1.0/minFreq/2.0,1.0/freq4/2.0-simpleStringTermDelay(bridgeFc4))),wg0cpy4,term0cpy4,junct0cpy4;
waveguide(waveImp,simpleString(1.0/minFreq/2.0,1.0/freq5/2.0-simpleStringTermDelay(bridgeFc5))),wg0cpy5,term0cpy5,junct0cpy5;
waveguide(waveImp,simpleString(1.0/minFreq/2.0,1.0/freq6/2.0-simpleStringTermDelay(bridgeFc6))),wg0cpy6,term0cpy6,junct0cpy6;
termination(simpleStringTerm(-1.0*pow(0.001,1.0/freq1/T60), bridgeFc1)),term0;
termination(simpleStringTerm(-1.0*pow(0.001,1.0/freq2/T60), bridgeFc2)),term0cpy2;
termination(simpleStringTerm(-1.0*pow(0.001,1.0/freq3/T60), bridgeFc3)),term0cpy3;
termination(simpleStringTerm(-1.0*pow(0.001,1.0/freq4/T60), bridgeFc4)),term0cpy4;
termination(simpleStringTerm(-1.0*pow(0.001,1.0/freq5/T60), bridgeFc5)),term0cpy5;
termination(simpleStringTerm(-1.0*pow(0.001,1.0/freq6/T60), bridgeFc6)),term0cpy6;
junction(0.0),junct0; # pos 313,156
junction(0.0),junct0cpy2; # pos 403,166
junction(0.0),junct0cpy3; # pos 483,166
junction(0.0),junct0cpy4; # pos 563,166
junction(0.0),junct0cpy5; # pos 663,166
junction(0.0),junct0cpy6; # pos 763,166
faustcode: minNote = 16.0;
faustcode: maxNote = 96.0;
faustcode: mtof = _:-(69.0):/(12.0) <: (2.0,_) : pow : *(440.0) : _;
faustcode: minFreq = mtof(minNote);
faustcode: maxFreq = mtof(maxNote);
faustcode: freq1 = hslider("Note1", 50.0, minNote, maxNote, 0.05):mtof;
faustcode: freq2 = hslider("Note2", 52.0, minNote, maxNote, 0.05):mtof;
faustcode: freq3 = hslider("Note3", 55.0, minNote, maxNote, 0.05):mtof;
faustcode: freq4 = hslider("Note4", 59.0, minNote, maxNote, 0.05):mtof;
faustcode: freq5 = hslider("Note5", 64.0, minNote, maxNote, 0.05):mtof;
faustcode: freq6 = hslider("Note6", 76.0, minNote, maxNote, 0.05):mtof;
faustcode: avgFreq = (freq1+freq2+freq3+freq4+freq5+freq6)/6.0;
faustcode: T60=hslider("T60 [sec]",16.0,0.1,50.0,0.05);
faustcode: bridgeFcLow=hslider("Bridge cutoff freq for low notes [Hz]",6500.0,1000.0,fs,10.0);
faustcode: bridgeFcHigh=hslider("Bridge cutoff freq for high notes [Hz]",13000.0,1000.0,fs,10.0);
faustcode: k=hslider("Pluck stiffness [N/m]",250.0,0.0,1000.0,50.0);
faustcode: R=hslider("Pluck damping [N/(m/s)]",0.02,0.0,3.0,0.01);
faustcode: maxdisp=hslider("Pluck half-width [m]",0.004,0.001,0.01,0.001);
faustcode: moveStrings=hslider("Waveguides position adjustment",1.0,0.1,1.4,0.01);
faustcode: vol=hslider("Z Volume",0.15,0.01,1.0,0.01);
faustcode: waveImp=hslider("Wave impedance [N/(m/s)]",0.8,0.1,10.0,0.1);
faustcode: plSc=hslider("Pluck impedance scaler",1.0,0.0,3.0,0.01);
# This one causes the lower notes to be a little bit louder
#faustcode: nlScaleOutput = sqrt;
# This one causes the lower notes to be a lot louder
#faustcode: nlScaleOutput = _;
# This one causes no frequency-dependent scaling of note volumes
faustcode: nlScaleOutput = *(0.0):+(1.0);
audioout,a0,(term0*nlScaleOutput(avgFreq/freq1)+term0cpy2*nlScaleOutput(avgFreq/freq2)+term0cpy4*nlScaleOutput(avgFreq/freq4)):*(vol):highpass(4,80.0); # pos 117,334
audioout,a1,(term0cpy6*nlScaleOutput(avgFreq/freq6)+term0cpy3*nlScaleOutput(avgFreq/freq3)+term0cpy5*nlScaleOutput(avgFreq/freq5)):*(vol):highpass(4,80.0); # pos 572,327