I’m a beginner, so I hope this is simple and doesn’t take much of your time.
I’m working on a simple program to route keyboard inputs to specific notes and midi controls (octave, volume, etc.).
The notes themselves register just fine, but when I try to give it any other type of input, it gives an error.
Now that I’ve changed the code a little bit more, I managed to get both not working.
I get: ERROR: binary operator ‘+’ failed.
////1 Creates the keyboard -> midi from keyboard codes
(
e = Dictionary.new;
~midi = Dictionary.new;
~keyBoard = [
[ $z, 122 ],
[ $s, 115 ],
[ $x , 120 ],
[ $d , 100 ],
[ $c , 99 ],
[ $v ,118 ],
[ $g ,103 ],
[ $b ,98 ],
[ $h ,104 ],
[ $n ,110 ],
[ $j ,106 ],
[ $m ,109 ],
[ $q ,113 ],
[ $2 ,50 ],
[ $w ,119 ],
[ $3 ,51 ],
[ $e ,101 ],
[ $r ,114 ],
[ $5 ,53 ],
[ $t ,116 ],
[ $6 ,54 ],
[ $y ,121 ],
[ $7 ,55 ],
[ $u ,117 ],
[ $i ,105 ],
[ $9 ,57 ],
[ $o ,111 ],
[ $0 ,48 ],
[ $p ,112 ]]
;
~midiBtns = Dictionary.newFrom(List["l" ,[-1,"control"], "l" ,[1,"control"]]);
~interval=0;
~keyBoard.do{
arg i;
i[0].postln;
~interval.postln;
~midi.put(i[0].asString, [~interval, "note"]);
~interval = ~interval+1;
};
~oct = 0;
~synth = \default;
~currentNote = 0;
)
~midi["z"][0] + 10
(
w = Window.new("I catch keystrokes");
~oct = 0;
w.view.keyDownAction_({ arg view, char;
var type=~midi[char.asString][1], key=~midi[char.asString][0];
type.postln;
key.postln;
if( type == "note", {
var sig,env, note;
note = 12*~oct + ~midi[key] + 60 ;
sig = LFTri.ar(note.midicps)!2;
env = EnvGen.kr(Env.perc, doneAction:2);
sig = sig*env;
}.play);
if( type == "control" , {~oct = ~oct + ~midi[char.asString][0]});
});
w.front;
)
Any input is appreciated.