Debian Codegraph @

examples/physicalModeling/mi-faust/00_BasicOscillator/harmonicOscillator3.dsp

raw
1 declare name "Harmonic Oscillator v3";
2 declare author "James Leonard";
3 declare date "April 2020";
4
5 /* ========= DESCRITPION =============
6
7 The simplest mass-interaction construct: a harmonic oscillator, built by assembling four elements:
8 a mass, a fixed point and a spring and a damper interaction.
9 The resulting model is identical to an mi.osc element (which integrates them together).
10 - inputs: force impulse
11 - outputs: oscillator' position.
12 - controls: none.
13 */
14
15 import("stdfaust.lib");
16 import("mi.lib");
17
18 in1 = button("Frc Input 1"): ba.impulsify * 0.25; //write a specific force input signal operation here
19
20 OutGain = 1;
21
22 model = (
23 mi.mass(1., 0, 0., 0.),
24 mi.ground(0.),
25 par(i, nbFrcIn,_):
26 RoutingMassToLink ,
27 par(i, nbFrcIn,_):
28 mi.spring(0.1, 0., 0.),
29 mi.damper(0.0003, 0., 0.),
30 par(i, nbOut+nbFrcIn, _):
31 RoutingLinkToMass
32 )~par(i, nbMass, _):
33 par(i, nbMass, !), par(i, nbOut , _)
34 with{
35 RoutingMassToLink(m0, m1) = /* routed positions */ m1, m0, m1, m0, /* outputs */ m0;
36 RoutingLinkToMass(l0_f1, l0_f2, l1_f1, l1_f2, p_out1, f_in1) = /* routed forces */ f_in1 + l0_f2 + l1_f2, l0_f1 + l1_f1, /* pass-through */ p_out1;
37 nbMass = 2;
38 nbFrcIn = 1;
39 nbOut = 1;
40 };
41 process = in1 : model:*(OutGain);
42
43
44 /*
45 ========= MIMS SCRIPT USED FOR MODEL GENERATION =============
46
47 # MIMS script file
48 # Script author: James Leonard
49
50 # Assembled harmonic oscillator with M = 1, K = 0.1, Z = 0.0003
51 @m mass 1. 0. 0.
52 @g ground 0.
53 @s spring @g @m 0.1
54 @d damper @g @m 0.0003
55
56 # Add force input to the model
57 @in1 frcInput @m
58
59 # Add position output from the oscillator
60 @out1 posOutput @m
61
62
63 # end of MIMS script
64
65 */