Skip to content

Commit

Permalink
Fixes for crossplatform, unused code deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
MaurizioB committed Apr 17, 2017
1 parent 8e9513e commit 96d233f
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 124 deletions.
10 changes: 5 additions & 5 deletions bigglesworth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def __init__(self, app, args):
self.globals.buttonBox.button(QtGui.QDialogButtonBox.Reset).clicked.connect(self.globals_request)

self.librarian.show()
# if self.backend == ALSA:

self.midiwidget = MidiWidget(self)
self.mididialog = MidiDialog(self, self.editor)
self.editor.show_midi_dialog.connect(self.mididialog.show)
Expand Down Expand Up @@ -341,10 +341,10 @@ def autoconnect(self):
try:
return self._autoconnect
except:
if self.backend == RTMIDI:
self._autoconnect = self.settings.gMIDI.get_Autoconnect({INPUT: fakeSet(), OUTPUT: fakeSet()}, True)
else:
self._autoconnect = self.settings.gMIDI.get_Autoconnect({INPUT: set(), OUTPUT: set()}, True)
# if self.backend == RTMIDI:
# self._autoconnect = self.settings.gMIDI.get_Autoconnect({INPUT: fakeSet(), OUTPUT: fakeSet()}, True)
# else:
self._autoconnect = self.settings.gMIDI.get_Autoconnect({INPUT: set(), OUTPUT: set()}, True)
return self._autoconnect

@property
Expand Down
2 changes: 1 addition & 1 deletion bigglesworth/alsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, main):
# self.seq.connect_ports((self.seq.client_id, output_id), (130, 0))
# self.seq.connect_ports((self.seq.client_id, output_id), (132, 0))

self.graph = self.main.graph = AlsaGraph(self.seq)
self.graph = self.main.graph = Graph(self.seq)
# self.graph.client_start.connect(self.client_start)
# self.graph.client_exit.connect(self.client_exit)
# self.graph.port_start.connect(self.port_start)
Expand Down
21 changes: 12 additions & 9 deletions bigglesworth/dialogs/midi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# *-* coding: utf-8 *-*

from PyQt4 import QtCore, QtGui
from bigglesworth.const import ClientRole, PortRole
from bigglesworth.const import ClientRole, PortRole, ALSA
from bigglesworth.utils import setBold

class MidiWidget(QtGui.QWidget):
Expand Down Expand Up @@ -29,6 +29,7 @@ def __init__(self, main):
self.refresh_btn = QtGui.QPushButton('Refresh')
layout.addWidget(self.refresh_btn, 2, 0, 1, 3)

self.backend = self.main.backend
self.input = self.main.input
self.output = self.main.output
self.graph = self.main.graph
Expand Down Expand Up @@ -114,10 +115,11 @@ def refresh_all(self):
if port.is_input:
out_port_list.append(port)
if len(in_port_list):
in_client_item = QtGui.QStandardItem(client.name)
in_client_item.setData('<b>Client:</b> {c}<br/><b>Address:</b> {cid}'.format(c=client.name, cid=client.id), QtCore.Qt.ToolTipRole)
self.input_model.appendRow(in_client_item)
in_client_item.setEnabled(False)
if self.backend == ALSA:
in_client_item = QtGui.QStandardItem(client.name)
in_client_item.setData('<b>Client:</b> {c}<br/><b>Address:</b> {cid}'.format(c=client.name, cid=client.id), QtCore.Qt.ToolTipRole)
self.input_model.appendRow(in_client_item)
in_client_item.setEnabled(False)
for port in in_port_list:
in_item = QtGui.QStandardItem(' {}'.format(port.name))
in_item.setData('<b>Client:</b> {c}<br/><b>Port:</b> {p}<br/><b>Address:</b> {cid}:{pid}'.format(
Expand All @@ -136,10 +138,11 @@ def refresh_all(self):
in_item.setData(QtGui.QBrush(QtCore.Qt.black), QtCore.Qt.ForegroundRole)
setBold(in_item, False)
if len(out_port_list):
out_client_item = QtGui.QStandardItem(client.name)
out_client_item.setData('<b>Client:</b> {c}<br/><b>Address:</b> {cid}'.format(c=client.name, cid=client.id), QtCore.Qt.ToolTipRole)
self.output_model.appendRow(out_client_item)
out_client_item.setEnabled(False)
if self.backend == ALSA:
out_client_item = QtGui.QStandardItem(client.name)
out_client_item.setData('<b>Client:</b> {c}<br/><b>Address:</b> {cid}'.format(c=client.name, cid=client.id), QtCore.Qt.ToolTipRole)
self.output_model.appendRow(out_client_item)
out_client_item.setEnabled(False)
for port in out_port_list:
out_item = QtGui.QStandardItem(' {}'.format(port.name))
out_item.setData('<b>Client:</b> {c}<br/><b>Port:</b> {p}<br/><b>Address:</b> {cid}:{pid}'.format(
Expand Down
80 changes: 63 additions & 17 deletions bigglesworth/dialogs/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>533</width>
<height>408</height>
<width>540</width>
<height>413</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -590,20 +590,6 @@
<string>MIDI</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QGroupBox" name="midi_groupbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Current connections</string>
</property>
<layout class="QGridLayout" name="gridLayout_2"/>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand All @@ -630,7 +616,66 @@
</layout>
</widget>
</item>
<item row="0" column="0">
<item row="2" column="1">
<widget class="QGroupBox" name="groupBox_7">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Backend</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QRadioButton" name="backend_alsa_radio">
<property name="text">
<string>ALSA (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">midi_backend_group</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="backend_rtmidi_radio">
<property name="text">
<string>rtmidi</string>
</property>
<attribute name="buttonGroup">
<string notr="true">midi_backend_group</string>
</attribute>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Restart Bigglesworth to apply this setting.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="midi_groupbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Current connections</string>
</property>
<layout class="QGridLayout" name="gridLayout_2"/>
</widget>
</item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="deviceIDLabel">
Expand Down Expand Up @@ -840,5 +885,6 @@
<buttongroup name="editor_appearance_efx_arp_group"/>
<buttongroup name="editor_appearance_filter_matrix_group"/>
<buttongroup name="preset_group"/>
<buttongroup name="midi_backend_group"/>
</buttongroups>
</ui>
13 changes: 5 additions & 8 deletions bigglesworth/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ def create_layout(self):

self.edited_widget = EditedWidget(panel)
layout.addItem(self.edited_widget, 0, 2)
self.edited_widget.hide()
# self.edited_widget.hide()
self.edit_mode_label = SmallLabelTextWidget('Sound mode Edit buffer', panel)
# self.edit_mode_label.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
layout.addItem(self.edit_mode_label, 0, 3)
Expand Down Expand Up @@ -2264,10 +2264,7 @@ def __init__(self, main):
self.midi = self.main.midi
self.input = self.midi.input
self.output = self.midi.output
if self.main.backend == ALSA:
self.graph = self.main.graph
else:
self.graph = None
self.graph = self.main.graph
self.channel = 0
self.octave = 0
self.params = Params
Expand All @@ -2291,7 +2288,7 @@ def create_layout(self):
display_layout = QtGui.QGridLayout()
self.grid.addLayout(display_layout, 0, 1, 1, 2)
display_layout.addLayout(self.create_display(), 0, 0, 2, 1)
self.sound_edited.connect(lambda: [self.display.edited_widget.show(), self.display.edited_widget.setOpacity(1)])
self.sound_edited.connect(lambda: self.display.edited_widget.setOpacity(1))
display_layout.addWidget(HSpacer(max_width=8), 0, 1)

side_layout = QtGui.QGridLayout()
Expand Down Expand Up @@ -2765,7 +2762,7 @@ def randomize(self):
print e
self.reset_advanced_widgets()
self.notify = True
self.display.edited_widget.show()
# self.display.edited_widget.show()
self.display.edited_widget.setOpacity(.4)
self.edited = False

Expand All @@ -2788,7 +2785,7 @@ def _setSound(self):
self.save = old_save
self.notify = True
self.display.setSound()
self.display.edited_widget.hide()
self.display.edited_widget.setOpacity(0)

def setSound(self, bank, prog, pgm_send=False):
sound = self.blofeld_library[bank, prog]
Expand Down
64 changes: 33 additions & 31 deletions bigglesworth/midiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,25 +766,37 @@ def __init__(self, client, port_id=0):
self.exp = '{}:{}'.format(*self.addr)
self.info_dict = self.seq.get_port_info(self.id, self.client.id)
self.name = self.info_dict['name']
self.caps = get_port_caps(self.info_dict['capability'])
self.type = get_port_type(self.info_dict['type'])
if not len(self.type) or alsaseq.SEQ_PORT_CAP_NO_EXPORT in self.caps:
self.hidden = True
if self.graph.backend == ALSA:
self.caps = get_port_caps(self.info_dict['capability'])
self.type = get_port_type(self.info_dict['type'])
if not len(self.type) or alsaseq.SEQ_PORT_CAP_NO_EXPORT in self.caps:
self.hidden = True
else:
self.hidden = False
self.is_input = self.is_output = False
if alsaseq.SEQ_PORT_CAP_DUPLEX in self.caps:
self.is_input = self.is_output = True
else:
#TODO trova un modo più veloce per trovare il tipo di porta, qui generi ogni volta 2 set
if set([int(t) for t in [alsaseq.SEQ_PORT_CAP_READ, alsaseq.SEQ_PORT_CAP_SYNC_READ, alsaseq.SEQ_PORT_CAP_SUBS_READ]]) & set([int(t) for t in self.caps]):
self.is_output = True
if set([int(t) for t in [alsaseq.SEQ_PORT_CAP_WRITE, alsaseq.SEQ_PORT_CAP_SUBS_WRITE, alsaseq.SEQ_PORT_CAP_SUBS_WRITE]]) & set([int(t) for t in self.caps]):
self.is_input = True
if self.is_input and self.is_output:
self.is_duplex = True
else:
self.is_duplex = False
else:
self.caps = None
self.type = None
self.hidden = False
self.is_input = self.is_output = False
if alsaseq.SEQ_PORT_CAP_DUPLEX in self.caps:
self.is_input = self.is_output = True
else:
#TODO trova un modo più veloce per trovare il tipo di porta, qui generi ogni volta 2 set
if set([int(t) for t in [alsaseq.SEQ_PORT_CAP_READ, alsaseq.SEQ_PORT_CAP_SYNC_READ, alsaseq.SEQ_PORT_CAP_SUBS_READ]]) & set([int(t) for t in self.caps]):
self.is_output = True
if set([int(t) for t in [alsaseq.SEQ_PORT_CAP_WRITE, alsaseq.SEQ_PORT_CAP_SUBS_WRITE, alsaseq.SEQ_PORT_CAP_SUBS_WRITE]]) & set([int(t) for t in self.caps]):
self.is_input = True
if self.is_input and self.is_output:
self.is_duplex = True
else:
self.is_duplex = False
if self.info_dict['capability'] == 66:
self.is_input = True
self.is_output = False
else:
self.is_input = False
self.is_output = True
self.connections = ConnList(self)

def connect(self, dest, port=None):
Expand Down Expand Up @@ -933,21 +945,7 @@ def __repr__(self):
return 'Client "{}" ({})'.format(self.name, self.id)


class RtMidiGraph(QtCore.QObject):
graph_changed = QtCore.pyqtSignal()
client_start = QtCore.pyqtSignal(object, int)
client_exit = QtCore.pyqtSignal(object)
port_start = QtCore.pyqtSignal(object, int)
port_exit = QtCore.pyqtSignal(object)
conn_register = QtCore.pyqtSignal(object, bool)

def __init__(self, seq):
QtCore.QObject.__init__(self)
self.seq = seq
self.ports = {INPUT: [self.input_port], OUTPUT: [self.output_port]}


class AlsaGraph(QtCore.QObject):
class Graph(QtCore.QObject):
graph_changed = QtCore.pyqtSignal()
client_start = QtCore.pyqtSignal(object, int)
client_exit = QtCore.pyqtSignal(object)
Expand All @@ -958,6 +956,10 @@ class AlsaGraph(QtCore.QObject):
def __init__(self, seq):
QtCore.QObject.__init__(self)
self.seq = seq
if seq.__class__.__name__ == 'RtMidiSequencer':
self.backend = RTMIDI
else:
self.backend = ALSA
self.client_id_dict = {}
self.port_id_dict = {}
self.connections = {}
Expand Down
Loading

0 comments on commit 96d233f

Please sign in to comment.