Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine_FM7 control rate variable crashes Crone, works as expected in scide #573

Closed
lazzarello opened this issue Oct 1, 2018 · 5 comments
Closed

Comments

@lazzarello
Copy link
Contributor

@lazzarello lazzarello commented Oct 1, 2018

I've started work on a new engine for the FM7 extension that models a DX7. It takes two arguments, which are collections of arrays. Some of the values in the arrays run at control rate.

An excerpt from my changes in dust work as expected in scide like so

{
    var ctls, mods, chans;
    var hz_;
    // this works in Crone and scide
    // hz_ = 440;
    // this fails in Crone, works in scide
    hz_ = Lag.kr(MouseX.kr(60,440), 0.01);
    ctls = [
              [ LFNoise1.kr(0.5).range(300, 310), 0,    1   ],
              [ hz_, pi/2, 1   ],
              [ 730, 0,    0.5 ],
              [ 0,   0,    0   ],
              [ 0,   0,    0   ],
              [ 0,   0,    0   ]
    ];
	
    mods = [
        [Line.kr(0, 0.001, 2), Line.kr(0.1, 0, 4), 0, MouseY.kr(0, 6), 0, 0],
        [0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0]
    ];
    chans = [0, 1];
    FM7.ar(ctls, mods).slice(chans) * -12.dbamp; // using "slice" to select specific channels
}.play;

I've commented my branch with what fails in Crone. The gist is when the value of hz_ is anything other than a static integer, the screen shows Error: Audio Engine.

@tehn
Copy link
Member

@tehn tehn commented Oct 1, 2018

you'll want to see actual crone engine errors: from an ssh session run ./stop.sh and then ./crone.sh to see the error

@lazzarello
Copy link
Contributor Author

@lazzarello lazzarello commented Oct 2, 2018

This helps, thanks.

So...SuperCollider's variable declaration rules strike again! It seems there is an order to variable declaration and dependencies.

I was declaring the the var hz_ before the var ctrls. I referenced the var hz_ inside the value of ctrls. It seems that variable declaration happens at a different time then variable assignment. So the following fails

    var hz_;
    hz_ = 440;
    var ctls = [
              [ LFNoise1.kr(0.5).range(300, 310), 0,    1   ],
              [ hz_, pi/2, 1   ],
              [ 730, 0,    0.5 ],
              [ 0,   0,    0   ],
              [ 0,   0,    0   ],
              [ 0,   0,    0   ]
    ];

With a less helpful error message. Does this mean it expects a function? Dunno.

ERROR: syntax error, unexpected VAR, expecting '}'
  in file '/home/we/.local/share/SuperCollider/Extensions/dust/sc/Engine_FM7.sc'
  line 19 char 9:

        var ctrls = [[ LFNoise1.kr(0.5).range(300, 310), 0,    1   ],
        ^^^
                     [ hz_, pi/2, 1   ],
-----------------------------------
ERROR: file '/home/we/.local/share/SuperCollider/Extensions/dust/sc/Engine_FM7.sc' parse failed
error parsing

If I declare var ctls first. Everything is fine.

    var hz_, ctls;
    hz_ = 440;
    ctls = [
              [ LFNoise1.kr(0.5).range(300, 310), 0,    1   ],
              [ hz_, pi/2, 1   ],
              [ 730, 0,    0.5 ],
              [ 0,   0,    0   ],
              [ 0,   0,    0   ],
              [ 0,   0,    0   ]
    ];

Also, the scripts ~/norns/stop.sh and ~/norns/crone.sh disable the OLED on the unit, requiring a reboot.

@tehn
Copy link
Member

@tehn tehn commented Oct 2, 2018

if the OLED is getting disabled your repo might be in weird state-- try checking out the current master?

@catfact
Copy link
Collaborator

@catfact catfact commented Oct 2, 2018

yes variables in SC need to be declared at the top of a scope, and initialization follows declaration.

@lazzarello
Copy link
Contributor Author

@lazzarello lazzarello commented Oct 2, 2018

Thanks both of you. I'll mess around with rebasing norns on master when my fork of dust is in a better place, then worry about the OLED. I just wanna get this FM engine in a state when carrier/modulator params can be controlled in realtime.

@lazzarello lazzarello closed this Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants