def __init__(self, outport, sequence, start_time=time.time(),
allow_updates=False, channel=0, offset=0.0):
self._outport = outport
self._channel = channel
self._offset = offset
# Set of notes (pitches) that are currently on.
self._open_notes = set()
# Lock for serialization.
self._lock = threading.RLock()
# A control variable to signal when the sequence has been updated.
self._update_cv = threading.Condition(self._lock)
# The queue of mido.Message objects to send, sorted by ascending time.
self._message_queue = deque()
# An event that is set when `stop` has been called.
self._stop_signal = threading.Event()
# Initialize message queue.
# We first have to allow "updates" to set the initial sequence.
self._allow_updates = True
self.update_sequence(sequence, start_time=start_time)
# We now make whether we allow updates dependent on the argument.
self._allow_updates = allow_updates
super(MidiPlayer, self).__init__()
评论列表
文章目录