@@ -102,7 +102,6 @@ def start(self,
102
102
interpolate : Optional [str ] = None ) -> None :
103
103
"""
104
104
Begin executing the events on this track.
105
- Resets the track's time counter to zero.
106
105
107
106
Args:
108
107
events: A dict, a PDict, or a Pattern that generates dicts.
@@ -114,7 +113,13 @@ def start(self,
114
113
self .event_stream = events
115
114
116
115
self .is_started = True
117
- self .current_time = 0.0
116
+
117
+ # Previously, this reset the counter to zero, but when re-scheduling a track that has
118
+ # note-offs awaiting, this caused the existing notes to extend in duration.
119
+ # Arguably it is more coherent to reset the time and adjust the note-off scheduling
120
+ # accordingly, so may need to re-visit this.
121
+ # self.current_time = 0.0
122
+
118
123
self .next_event_time = self .current_time
119
124
if interpolate is not None :
120
125
self .interpolate = interpolate
@@ -123,7 +128,8 @@ def update(self,
123
128
events : Union [dict , Pattern ],
124
129
quantize : Optional [float ] = None ,
125
130
delay : Optional [float ] = None ,
126
- interpolate : Optional [str ] = None ):
131
+ interpolate : Optional [str ] = None ,
132
+ count : Optional [int ] = None ):
127
133
"""
128
134
Update the events that this Track produces.
129
135
@@ -133,13 +139,16 @@ def update(self,
133
139
quantize == 1 means that the update should happen on the next beat boundary.
134
140
delay: Optional float specifying delay time applied to quantization
135
141
interpolate: Optional interpolation mode
142
+ count: Optional max_event_count
136
143
"""
137
144
if quantize is None :
138
145
quantize = self .timeline .defaults .quantize
139
146
if delay is None :
140
147
delay = self .timeline .defaults .delay
141
148
if self .output_device is not None and self .output_device .added_latency_seconds > 0.0 :
142
149
delay += self .timeline .seconds_to_beats (self .output_device .added_latency_seconds )
150
+ if count is not None :
151
+ self .max_event_count = count
143
152
144
153
#--------------------------------------------------------------------------------
145
154
# Don't assign to events immediately, because in the case of quantized
@@ -298,7 +307,8 @@ def get_next_event(self) -> Event:
298
307
if self .event_stream is None :
299
308
raise StopIteration
300
309
301
- if self .max_event_count is not None and self .current_event_count >= self .max_event_count :
310
+ # Allow for 0 to mean infinite events, for ease of use in live coding
311
+ if self .max_event_count not in (None , 0 ) and self .current_event_count >= self .max_event_count :
302
312
raise StopIteration
303
313
304
314
#------------------------------------------------------------------------
0 commit comments