Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling midi clock when stop message is received. #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dist/
dev
audio
midi
build
TODO.md
6 changes: 5 additions & 1 deletion isobar/io/midi/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, device_name=None, clock_target=None, virtual=False):
self.callback = None
self.estimated_tempo = None
self.last_clock_time = None
self.midi_clock_is_running = False
log.info("Opened MIDI input: %s" % self.midi.name)

@property
Expand Down Expand Up @@ -63,21 +64,24 @@ def _callback(self, message):
else:
self.last_clock_time = time.time()

if self.clock_target is not None:
if self.clock_target is not None and self.midi_clock_is_running:
self.clock_target.tick()

elif message.type == 'start':
log.info(" - MIDI: Received start message")
self.midi_clock_is_running = True
if self.clock_target is not None:
self.clock_target.start()

elif message.type == 'stop':
log.info(" - MIDI: Received stop message")
self.midi_clock_is_running = False
if self.clock_target is not None:
self.clock_target.stop()

elif message.type == 'songpos':
log.info(" - MIDI: Received songpos message")
self.midi_clock_is_running = True
if message.pos == 0:
if self.clock_target is not None:
self.clock_target.reset()
Expand Down