cmajor-lang/cmajor

[Feature Request] Ability to "compile" to a patch

Closed this issue · 1 comments

If I load a patch, that has some parameter inputs. For example (from Creating your first patch - Hello, World! )

graph AnnoyingBeep  [[main]]
{
    output stream float out;
    input gain.volume;
    input sine.frequencyIn;

    node sine = std::oscillators::Sine (float, 440);
    node gain = std::levels::SmoothedGain (float);

    connection sine -> gain.in;
    connection gain.out -> out;
}

Then if I load the patch and programmatically change the value using the native API, I'd like to be able to re-export or compile to the patch format to inspect. What this would look like might be if I change sine.frequencyIn to be 1000 Hz instead of 440 Hz, I should be able to compile to the patch format and the new code might be something like the following.

graph AnnoyingBeep  [[main]]
{
    output stream float out;
    input gain.volume;
    input sine.frequencyIn;

    node sine = std::oscillators::Sine (float, 1000);
    node gain = std::levels::SmoothedGain (float);

    connection sine -> gain.in;
    connection gain.out -> out;
}

For more complex patches, I think it would be fine for it to not match so exactly. For example, if comments were stripped or orders swapped or anything else as a by-product of the implementation. The goal is to be able to save state in the patch format itself.

I'm just going through some old issues, and sorry, hadn't seen this one..

I'm struggling a bit to understand what you're asking though? You seem to be asking for a way to regenerate the actual cmajor, but I can't see how that'd make any sense. And the constant that you changed has nothing to do with sine.frequencyIn...?