root/trunk/libffado/support/mixer-qt4/ffado/widgets/matrixmixer.py

Revision 1643, 4.1 kB (checked in by arnonym, 14 years ago)

Implement a very first interface for the crossbarrouter. currently its read-only.

With 81 sources and 83 destinations initialization of the mixer takes its time. Mostly because each connection is checked individually. Would be faster to use the getConnectionMap function defined in the dbus interface. Unfortunately this doesn't seem to be implemented currently.

  • Property svn:mergeinfo set to
Line 
1 #
2 # Copyright (C) 2009 by Arnold Krille
3 #
4 # This file is part of FFADO
5 # FFADO = Free Firewire (pro-)audio drivers for linux
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 2 of the License, or
10 # (at your option) version 3 of the License.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 from PyQt4 import QtGui, QtCore
22 import dbus
23
24 class MatrixNode(QtGui.QFrame):
25     def __init__(self, row, col, parent):
26         QtGui.QFrame.__init__(self,parent)
27         self.row = row
28         self.connect(self.row, QtCore.SIGNAL("hide"), self.setHidden)
29         self.column = col
30         self.connect(self.column, QtCore.SIGNAL("hide"), self.setHidden)
31
32         self.setLineWidth(1)
33         self.setFrameStyle(QtGui.QFrame.Panel|QtGui.QFrame.Raised)
34         self.layout = QtGui.QGridLayout(self)
35         self.setLayout(self.layout)
36
37         self.dial = QtGui.QDial(self)
38         self.dial.setRange(0,pow(2,16-1))
39         self.connect(self.dial, QtCore.SIGNAL("valueChanged(int)"), self.valueChanged)
40         self.layout.addWidget(self.dial, 0, 0)
41
42     def valueChanged(self, n):
43         self.emit(QtCore.SIGNAL("valueChanged"), self.row.number, self.column.number, n)
44
45     def setHidden(self, hide):
46         if not hide:
47             if self.row.hidden or self.column.hidden:
48                 return
49         QtGui.QFrame.setHidden(self, hide)
50
51 class MatrixChannel(QtGui.QWidget):
52     def __init__(self, number, parent=None):
53         QtGui.QWidget.__init__(self, parent)
54         layout = QtGui.QGridLayout(self)
55         self.number = number
56         self.btn = QtGui.QPushButton("%i" % self.number, self)
57         self.btn.setCheckable(True)
58         self.connect(self.btn, QtCore.SIGNAL("clicked(bool)"), self.hideChannel)
59         layout.addWidget(self.btn, 0, 0)
60
61         self.hidden = False
62
63     def hideChannel(self, hide):
64         #print "MatrixChannel.hideChannel( %s )" % str(hide)
65         self.hidden = hide
66         self.emit(QtCore.SIGNAL("hide"), hide)
67
68 class MatrixMixer(QtGui.QWidget):
69     def __init__(self, servername, basepath, parent=None):
70         QtGui.QWidget.__init__(self, parent)
71         self.bus = dbus.SessionBus()
72         self.dev = self.bus.get_object(servername, basepath)
73         self.interface = dbus.Interface(self.dev, dbus_interface="org.ffado.Control.Element.MatrixMixer")
74
75         #print self.palette().color( QtGui.QPalette.Window ).name()
76         self.palette().setColor( QtGui.QPalette.Window, self.palette().color( QtGui.QPalette.Window ).darker() );
77         #print self.palette().color( QtGui.QPalette.Window ).name()
78
79         rows = self.interface.getRowCount()
80         cols = self.interface.getColCount()
81
82         layout = QtGui.QGridLayout(self)
83         self.setLayout(layout)
84
85         self.columns = []
86         self.rows = []
87
88         # Add row/column headers
89         for i in range(cols):
90             ch = MatrixChannel(i, self)
91             layout.addWidget(ch, 0, i+1)
92             self.columns.append( ch )
93         for i in range(rows):
94             ch = MatrixChannel(i, self)
95             layout.addWidget(ch, i+1, 0)
96             self.rows.append( ch )
97
98         # Add node-widgets
99         for i in range(rows):
100             for j in range(cols):
101                 node = MatrixNode(self.rows[i], self.columns[j], self)
102                 node.dial.setValue(self.interface.getValue(i, j))
103                 self.connect(node, QtCore.SIGNAL("valueChanged"), self.valueChanged)
104                 layout.addWidget(node, i+1, j+1)
105
106     def valueChanged(self, row, column, n):
107         #print "MatrixNode.valueChanged( %i, %i, %i )" % (row,column,n)
108         self.interface.setValue(row, column, n)
109
110     def paintEvent(self, event):
111         p = QtGui.QPainter(self)
112         p.fillRect(event.rect(), self.palette().window())
113
114 #
115 # vim: et ts=4 sw=4
Note: See TracBrowser for help on using the browser.