cmajor-lang/cmajor

Casting error caused by sample rate change

Closed this issue · 1 comments

I've chased this one around a little but I've found it a bit tricky to pin down exactly what's causing it. Here's a small example which gives the error:

graph ExampleGraph [[ main ]]
{
    output stream float audioOut  [[ name: "Audio Out" ]];

    node
    {
        resonator = Resonator / 2;
    }

    connection 
    {
        resonator.audioOut[0] -> audioOut;
    }
}

processor Resonator
{

    input stream float64 audioIn[2];
    output stream float audioOut[2];

    var weights = float64 [2, 2] ((0.0, 0.0), (0.0, 0.0));

    let numInputs = 2;

    void main()
    {
        console <- "Resonator::main";

        loop
        {
            var in = float64[numInputs, 1] ((audioIn[0]), (audioIn[1]));

            let out = std::matrix::dot (weights, in);

            audioOut[0] <- float32(out[0][0]);

            advance();
        }
    }
}

Gives error:

error: Internal compiler error: "createCast:1067"

It seems some combination of altering the sample rate of the processor on the graph (resonator = Resonator / 2;) with casting the audio inputs into an array (var in = float64[numInputs, 1] ((audioIn[0]), (audioIn[1]));) causes this error. The console statement also affects whether the error occurs, though I think this might just be because the code sometimes gets optimised away without a side effect

Any advice to get around this is very welcome, or if there are better ways of doing matrix operations on arrays of inputs/outputs any tips would be gratefully received. Hope all's well with you!

Cheers Mark! Yep, that's a nice neat internal compiler error that I've reproduced here. We'll get that tracked down and fixed pronto!