| 1 |
declare name "Harmonic Oscillator"; |
| 2 |
declare author "James Leonard"; |
| 3 |
declare date "April 2020"; |
| 4 |
|
| 5 |
/* ========= DESCRITPION ============= |
| 6 |
|
| 7 |
The simplest mass-interaction construct: a harmonic oscillator, containing only one physical element (mi.osc). |
| 8 |
- inputs: force impulse |
| 9 |
- outputs: oscillator' position. |
| 10 |
- controls: none. |
| 11 |
|
| 12 |
Note: The routing pattern could be simplified here (cf.diagram), as the model contains no interaction elements. |
| 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.oscil(1., 0.1, 0.0003, 0, 0., 0.), |
| 23 |
par(i, nbFrcIn,_): |
| 24 |
RoutingMassToLink , |
| 25 |
par(i, nbFrcIn,_): |
| 26 |
par(i, nbOut+nbFrcIn, _): |
| 27 |
RoutingLinkToMass |
| 28 |
)~par(i, nbMass, _): |
| 29 |
par(i, nbMass, !), par(i, nbOut , _) |
| 30 |
with{ |
| 31 |
RoutingMassToLink(m0) = /* routed positions */ /* outputs */ m0; |
| 32 |
RoutingLinkToMass(p_out1, f_in1) = /* routed forces */ f_in1, /* pass-through */ p_out1; |
| 33 |
nbMass = 1; |
| 34 |
nbFrcIn = 1; |
| 35 |
nbOut = 1; |
| 36 |
}; |
| 37 |
process = in1 : model:*(OutGain); |
| 38 |
|
| 39 |
|
| 40 |
/* |
| 41 |
========= MIMS SCRIPT USED FOR MODEL GENERATION ============= |
| 42 |
|
| 43 |
# MIMS script file |
| 44 |
# Script author: James Leonard |
| 45 |
|
| 46 |
# Integrated harmonic oscillator with M = 1, K = 0.1, Z = 0.0003 |
| 47 |
@o osc 1. 0.1 0.0003 0. 0. |
| 48 |
|
| 49 |
# Add force input to the model |
| 50 |
@in1 frcInput @o |
| 51 |
|
| 52 |
# Add position output from the oscillator |
| 53 |
@out1 posOutput @o |
| 54 |
|
| 55 |
|
| 56 |
# end of MIMS script |
| 57 |
|
| 58 |
*/ |