// title: SimpleMIDIFile help // author: Wingel Pérez Mendoza // description: // Dear friends, // I am trying to manipulate different aspects in a midi file, so far, I am having problems with 2 particular aspects. I want to control my midi file with a slider, but I don´t know why is not working, another problem is that my code doesn´t play the rhythm, could you help me, please??? // // Greetings, // code: ( m = SimpleMIDIFile.read("C:/Users/WM/Documents/Peter code/Midi/Croatia.mid"); m.timeMode_('seconds'); // convert ticks to seconds ); ( MIDIClient.init; // check list for available devices MIDIClient.destinations; a = MIDIOut(2); //Midi number of destination ); ( ~cont = 0; ~tiempo = 0.2; ~transpose = 12; t = Task({ e = m.noteSustainEvents(nil, nil); // get notes from track 1 e.do{arg event; a.noteOn(1, e[~cont][4] + ~transpose, e[~cont][5]); e[~cont][6]*~tiempo.wait; // durations, you can scale this number to change the durations a.noteOff(1, e[~cont][4] + ~transpose, e[~cont][5]); ~cont=~cont+1; ~cont.postln; }; }); ); //Gui ( var window, button, fader; window = Window("Peter´s Code", Rect(100, 100, 400, 500)).front; button = Button(window, Rect(30, 380, 150, 100)); fader = Slider(window, Rect(30, 40, 50, 320)); fader.action_({|obj| var tr; tr = obj.value.linlin(0,1,-12,12).postln; tr + ~transpose; {a.allNotesOff}; }); button.states = [["Off", Color.white, Color.black], ["On", Color.black, Color.red]]; button.action = {|val| if(val.value == 1, {t.play; "Task On".postln}, {t.stop; "Task Off".postln})}; );