mi-creative / MIMS

PyQt application for creating mass interaction models and compiling them into Faust dsp code, or ~gen objects (for Max/MSP)
GNU General Public License v3.0
25 stars 0 forks source link

RoutingMassToLink must be equal to the number of inputs [2] of B #2

Closed smrg-lm closed 3 years ago

smrg-lm commented 3 years ago

Hi

I was reading the papers and following the tutorials, code for max works fine but I can't compile the generated faust dsp files (neither the examples from rmichon/mi_faust). I don't really know much about faust but looks weird that no example can compile, an example of the issue:

--- MIMS file

@M param 1.
@K param 0.1
@Z param 0.001

@m mass M 0. 0.
@g ground 0.

@spr springDamper @m @g K Z

@in1 frcInput @m

@out1 posOutput  @m

---- FAUST file

import("stdfaust.lib");
import("mi.lib");

in1 = 0;

OutGain = 0.5;

M = 1.;
K = 0.1;
Z = 0.001;

model = (
RoutingLinkToMass : ground(0.), mass(M, 0., 0.) :
RoutingMassToLink : spring(K, Z, 0., 0.), par(i, 1, _)
)

~par(i, 2, _) : par(i, 2, !), par(i,  1, _)

with {
    RoutingLinkToMass(l0_f1, l0_f2, f_in1) = l0_f2, f_in1+l0_f1;
    RoutingMassToLink(m0, m1) = m1, m0, m1;
};

process = in1 : model : *(OutGain);

--- compile output

$ faust2dummy mitut.dsp
ERROR in sequential composition RoutingMassToLink:B
The number of outputs [3] of RoutingMassToLink must be equal to the number of inputs [2] of B

Here  RoutingMassToLink = \(x7).(\(x8).(x8,x7,x8));
has 3 outputs

while B = \(x9).(0.10000000000000001f,(0.0f,x9 : -) : *<:(_,-1 : *),_),_;
has 2 inputs
jameslnrd commented 3 years ago

Hi, Sorry for not getting back to you sooner. That does seem strange indeed. We are porting the MIMS system to a javascript web-app (you can find the current prototype here: http://mi-creative.eu/tool_MIMS_online.html), so support for the Python version will decrease over time. I can reproduce the bug with the Python MIMS so I'll try to fix it ASAP, however I'd recommend using the web tool above, as the code generation has been fully reworked and debugged quite a bit, and your model description compiles into correct Faust code that runs without error in the Faust Web IDE.

jameslnrd commented 3 years ago

Changes in the "mi.lib" API that had broken the old MIMS code generator have been reported into the MIMS main branch, and examples that were using obsolete scripts have been updated (in MIMS and in the mi_faust repo examples). As far as I can tell everything seems to run OK. It may still present bugs and will still be limited in regards to newer additions to mi.lib, so you'd be better off using the web-based version in any case. Also, a more comprehensive list of examples for mi.lib (including MIMS scripts) can be found here: https://github.com/grame-cncm/faust/tree/master-dev/examples/physicalModeling/mi-faust With a full tutorial on getting started in Faust here: http://mi-creative.eu/tutos/introduction.html

smrg-lm commented 3 years ago

Thank you, I'll try the javascript version better. By the way, love the interface for modeling.