cmajor-lang / cmajor

The Cmajor public repository
https://cmajor.dev
Other
522 stars 31 forks source link

JS bool event handler always receives `true` with CLAP and VST generated plugins #64

Closed giohappy closed 3 months ago

giohappy commented 4 months ago

Maybe I'm doing something wrong but this is what I observe only with generated plugins (both CLAP and VST). It doesn't happen when the patch is run inside the Cmaj plugin.

MyProcessor defines an event handler for the transport state, which in turn sends out a bool to my own event:

processor MyProcessor {
    output event bool isPlaying;
    bool hostIsPLaying = false;

    event transportStateIn (std::timeline::TransportState tstate) {
        let state = (tstate.flags & 1) == 1;
        if (state != hostIsPLaying) {
            isPlaying <- state;
                        hostIsPLaying = state;
        }
    }
}

The UI defines a handler for the event:

this.patchConnection.addEndpointListener('isPlaying', (value) => {
    console.log(value);  // This is always true;
});

I've verified inside a Debug session of the plugin that the value on the C++ side is correct and reflects the transport state of the DAW, but JS always receives true.

If I turn the event to int (output event int isPlaying) the UI receives the expected value (either 0 or 1).

cesaref commented 3 months ago

Thanks for this bug report. It's the tip of the iceberg for a number of issues related to packed data types and how we were transforming (or failing to!) these to the running DSP. I've been working through these and will have an updated release shortly

giohappy commented 3 months ago

It means I'm just scratching the surface! :) Thanks @cesaref, I confirm this is fixed.