@@ -40,6 +40,9 @@ def __init__(self, ctx, idx, midich):
40
40
self .initial_channel = midich
41
41
self .non_drum_channel = midich
42
42
self .reset ()
43
+ def us (self ):
44
+ # microseconds
45
+ return int (self .ctx .t )* 1000000
43
46
def reset (self ):
44
47
Lane .reset (self )
45
48
self .mode = 0 # 0 is NONE which inherits global mode
@@ -179,13 +182,14 @@ def note_on(self, n, v=-1, sustain=False):
179
182
if self .ctx .showmidi : log (FG .YELLOW + 'MIDI: NOTE ON (%s, %s, %s)' % (n ,v ,ch ))
180
183
if (not self .ctx .muted or (self .ctx .muted and self .soloed ))\
181
184
and self .enabled and self .ctx .startrow == - 1 :
182
- self .midi [ch [0 ]].note_on (n ,v ,ch [1 ])
183
185
if self .ctx .midifile :
184
186
while ch [0 ] >= len (self .ctx .midifile .tracks ):
185
187
self .ctx .midifile .tracks .append (mido .MidiTrack ())
186
188
self .ctx .midifile .tracks [ch [0 ]].append (mido .Message (
187
- 'note_on' ,velocity = v ,time = int ( self .ctx . t ),channel = ch [1 ]
189
+ 'note_on' ,note = n , velocity = v ,time = self .us ( ),channel = ch [1 ]
188
190
))
191
+ else :
192
+ self .midi [ch [0 ]].note_on (n ,v ,ch [1 ])
189
193
def note_off (self , n , v = - 1 ):
190
194
if v == - 1 :
191
195
v = self .vel
@@ -195,10 +199,21 @@ def note_off(self, n, v=-1):
195
199
# log("off " + str(n))
196
200
for ch in self .channels :
197
201
if self .ctx .showmidi : log (FG .YELLOW + 'MIDI: NOTE OFF (%s, %s, %s)' % (n ,v ,ch ))
198
- self .midi [ch [0 ]].note_on (self .notes [n ],0 ,ch [1 ])
199
- self .midi [ch [0 ]].note_off (self .notes [n ],v ,ch [1 ])
202
+ if not self .ctx .midifile :
203
+ self .midi [ch [0 ]].note_on (self .notes [n ],0 ,ch [1 ])
204
+ self .midi [ch [0 ]].note_off (self .notes [n ],v ,ch [1 ])
200
205
self .notes [n ] = 0
201
206
self .sustain_notes [n ] = 0
207
+ if self .ctx .midifile :
208
+ while ch [0 ] >= len (self .ctx .midifile .tracks ):
209
+ self .ctx .midifile .tracks .append (mido .MidiTrack ())
210
+ self .ctx .midifile .tracks [ch [0 ]].append (mido .Message (
211
+ 'note_on' ,note = n ,velocity = 0 ,time = self .us (),channel = ch [1 ]
212
+ ))
213
+ self .ctx .midifile .tracks [ch [0 ]].append (mido .Message (
214
+ 'note_off' ,note = n ,velocity = v ,time = self .us (),channel = ch [1 ]
215
+ ))
216
+
202
217
self .cc (MIDI_SUSTAIN_PEDAL , True )
203
218
def release_all (self , mute_sus = False , v = - 1 ):
204
219
if v == - 1 :
0 commit comments