The following code throws a :
^^ ERROR: Message '+' not understood.
RECEIVER: nil
when I try to write it.
What is strange is that when I comment out what I write with .addMIDIEvent
(thus only with .addNote
) it is working. The file is written correclty.
Any idea what’s happening ?
~bpm=60;
(
b = SimpleMIDIFile("G:/Enregistrements/Synthèse_Supercollider/Temp/test_export midi.alavolee.mid" );
b.init1( 3, ~bpm , "4/4" ); // must be 2 for 1 musical track, because track 1 is for metaData
b.timeMode = \seconds; // IMPORTANT
d= Pwrand([1,Pseq([0.66,0.34]),Pseq([0.5,0.5])],[0.5,0.25,0.25],inf).asStream;
r = Routine({
var clock = TempoClock(~bpm/60, 0); // MANDATORY
[35,49,56,63,66,73].mirror.do{ arg nn;
var dur, startTime, event, isBar;
startTime=clock.beats/clock.tempo;
isBar=(startTime.mod(4)<0.15);
dur=d.next.postln/clock.tempo;
Synth(\organ,[\freq,nn.midicps]);
// midi - approach1
// b.addNote(nn,64,startTime,dur,track:1);
// midi - approach2 (part 1 : noteOn)
event=[2, startTime.debug("noteOn"), \nodeOn, 0, nn, 64];
b.addMIDIEvent(event);
// midi - add some extra info
if(isBar) {
"bar!".postln;
event=[1, startTime,\text,"bar!"];
b.addMetaEvent(event);
};
// timer
dur.wait;
// midi - approach2 (part 2 : noteOff)
event=[2, (startTime+dur).debug("noteOff"), \nodeOff, 0, nn, 64];
b.addMIDIEvent(event);
};
"adjusting End Of track".debug;
b.adjustEndOfTrack; // MANDATORY
"Writing the file".debug;
b.write;
}).play
)