Skip to content

Commit

Permalink
protect against zero frame rate, remove debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampouille committed Jul 9, 2015
1 parent 993be8e commit 930e88f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
4 changes: 3 additions & 1 deletion boucle.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def my_callback(frames):
gui.readQueueIn.emit()
midi_out.clear_buffer()

if state == 1 and 'beats_per_minute' in position:
if ((state == 1
and 'beats_per_minute' in position
and position['frame_rate'] != 0)):
frame = position['frame']
fps = position['frame_rate']
fpm = fps * 60
Expand Down
1 change: 0 additions & 1 deletion clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,4 @@ def load_song_from_file(file):
parser[section].getint('mute_group', 0))
res.addClip(clip, x, y)

print("Ports: %s" % res.outputsPorts)
return res
18 changes: 2 additions & 16 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,46 +382,31 @@ def updateJackPorts(self, song, remove_ports=True):
'''Update jack port based on clip output settings
update dict containing ports with shortname as key'''

print("---------- Port update -------------------")

current_ports = set()
print("Outputs ports : ")
for port in self._jack_client.outports:
current_ports.add(port.shortname)
print("\t%s" % port.shortname)

wanted_ports = set()
for port_basename in song.outputsPorts:
for ch in Song.CHANNEL_NAMES:
port = Song.CHANNEL_NAME_PATTERN.format(port=port_basename,
channel=ch)
wanted_ports.add(port)
print("Wanted ports : ")
for port in wanted_ports:
print("\t%s" % port)

# remove unwanted ports
if remove_ports:
port_to_remove = []
for port in self._jack_client.outports:
if port.shortname not in wanted_ports:
print("***** removing : %s *****" % port.shortname)
current_ports.remove(port.shortname)
port_to_remove.append(port)
for port in port_to_remove:
port.unregister()

# create new ports
for new_port_name in wanted_ports - current_ports:
print("***** Adding : %s *****" % new_port_name)
self._jack_client.outports.register(new_port_name)

print("Outputs ports after update : ")
for port in self._jack_client.outports:
print("\t%s" % port.shortname)

print("------------------------------------------")

self.port_by_name = {port.shortname: port
for port in self._jack_client.outports}

Expand Down Expand Up @@ -672,6 +657,8 @@ def onDeviceSelect(self):
self.redraw()

def timebase_callback(self, state, nframes, pos, new_pos):
if pos.frame_rate == 0:
return None
pos.valid = 0x10
pos.bar_start_tick = BAR_START_TICK
pos.beats_per_bar = self.beat_per_bar.value()
Expand All @@ -686,4 +673,3 @@ def timebase_callback(self, state, nframes, pos, new_pos):
(bar, beat) = divmod(beats, int(round(pos.beats_per_bar, 0)))
(pos.bar, pos.beat) = (bar + 1, beat + 1)
return None

15 changes: 5 additions & 10 deletions playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self, parent):
self.playlistList.itemDoubleClicked.connect(self.onSongDoubleClick)
self.playlistList.setDragDropMode(QAbstractItemView.InternalMove)
self.playlistList.model().rowsMoved.connect(self.onMoveRows)
self.finished.connect(self.onFinished)
self.show()

def updateList(self):
Expand Down Expand Up @@ -61,7 +60,8 @@ def onAddSongs(self):

def onLoadPlaylist(self):
file_name, a = self.gui.getOpenFileName('Open Playlist',
'Super Boucle Playlist (*.sbp)',
('Super Boucle '
'Playlist (*.sbp)'),
self)
if not file_name:
return
Expand All @@ -72,7 +72,8 @@ def onLoadPlaylist(self):

def onSavePlaylist(self):
file_name, a = self.gui.getSaveFileName('Save Playlist',
'Super Boucle Playlist (*.sbp)',
('Super Boucle '
'Playlist (*.sbp)'),
self)

if file_name:
Expand All @@ -91,10 +92,4 @@ def onSongDoubleClick(self, item):

def loadSong(self, id):
if id != -1:
print(id)
song = self.gui.playlist[id]
self.gui.initUI(song)

def onFinished(self):
pass
# self.gui.updateDevices()
self.gui.initUI(self.gui.playlist[id])

0 comments on commit 930e88f

Please sign in to comment.