Debian Codegraph @

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

raw
1 declare name "Harmonic Oscillator v2";
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 three elements:
8 a mass, a fixed point and a spring-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
17 in1 = button("Frc Input 1"): ba.impulsify * 0.25; //write a specific force input signal operation here
18
19 OutGain = 1;
20
21 model = (
22 mi.mass(1., 0, 0., 0.),
23 mi.ground(0.),
24 par(i, nbFrcIn,_):
25 RoutingMassToLink ,
26 par(i, nbFrcIn,_):
27 mi.springDamper(0.1, 0.0003, 0., 0.),
28 par(i, nbOut+nbFrcIn, _):
29 RoutingLinkToMass
30 )~par(i, nbMass, _):
31 par(i, nbMass, !), par(i, nbOut , _)
32 with{
33 RoutingMassToLink(m0, m1) = /* routed positions */ m1, m0, /* outputs */ m0;
34 RoutingLinkToMass(l0_f1, l0_f2, p_out1, f_in1) = /* routed forces */ f_in1 + l0_f2, l0_f1, /* pass-through */ p_out1;
35 nbMass = 2;
36 nbFrcIn = 1;
37 nbOut = 1;
38 };
39 process = in1 : model:*(OutGain);
40
41
42 /*
43 ========= MIMS SCRIPT USED FOR MODEL GENERATION =============
44
45 # MIMS script file
46 # Script author: James Leonard
47
48 # Assembled harmonic oscillator with M = 1, K = 0.1, Z = 0.0003
49 @m mass 1. 0. 0.
50 @g ground 0.
51 @sp springDamper @g @m 0.1 0.0003
52
53 # Add force input to the model
54 @in1 frcInput @m
55
56 # Add position output from the oscillator
57 @out1 posOutput @m
58
59
60 # end of MIMS script
61
62 */