ERROR: syntax error, unexpected '~'
in file '/home/we/dust/code/RX7/lib/RX7_Engine.sc'
line 3 char 5:
~mainCaller = ("/home/we/dust/code/RX7/lib/DX7.scd").load;
^
It’s strange because if I null my engine by changing the suffix to .txt and let norns boot up regularly I can run that line of code in maiden and it seems to work. I can call the DX7.scd file by running ~mainCaller.value(80, 100, 10000); in maiden and it successfully plays a note.
The error seems to suggest that for whatever reason SuperCollider is not prepared to let you declare a global variable—that’s what the tilde represents. Try removing it from all of its appearances. Global variables make sense in SCIDE and even Maiden, since they persist across calls. Global variables make less sense in norns engines, since they persist across calls.
That makes sense. I’ve tried making it a local variable but, it just does not want to bite.
Full Engine Here
Engine_RX7 : CroneEngine {
var mainCaller = ("/home/we/dust/code/RX7/lib/DX7.scd").load;
// Supercollider DX7 Clone v1.0
// Implemented by Aziz Ege Gonul for more info go to www.egegonul.com
// Under GNU GPL 3 as per SuperCollider license
// engine.NoteOn(nn,vel)
this.addCommand("NoteOn", "if", {|msg|
mainCaller.value(msg[1], msg[2], algo);
});
// engine.NoteOff(nn)
this.addCommand("NoteOff", "i", {|msg|
mainCaller.value(msg[1], 0);
});
// To change algorithm
this.addCommand("algo", "f", { arg msg;
algo = msg[1];
});
}
the basic issue is that class variables can only be initializd to literals.
(the class definition cannot directly execute any interpreted code, it can only define variables and methods. no execution context exists when the class is compiled to bytecode.)
OkClass {
var foo = 2;
var bar = "230426_084632";
}
BadClass {
var foo = 1 + 1;
var bar = Date.getDate.stamp;
}
NotBadAnymore {
var foo;
var bar;
// class method to actually construct an object with `NotBadAnymore.new`
*new { ^super.new.init; }
init {
// here a specific object is being initialized
foo = 1 + 1;
bar = Date.getDate.stamp;
}
}