root/trunk/libffado/support/mixer-qt4/mixer_saffire_dice.py

Revision 1636, 3.0 kB (checked in by arnonym, 15 years ago)

Mix it baby!

A first matrix with dials (extra for ppalmers:-P). For screen-space its limited to 8x8 elements currently (or less, if the device has less).
Have to think about how to hide channels that aren't used. Or hide groups of channels with similar names. Hint: this would currently result in one group named "FIXME" :-)

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.column = col
29
30         self.setLineWidth(1)
31         self.setFrameStyle(QtGui.QFrame.Panel|QtGui.QFrame.Raised)
32         self.layout = QtGui.QGridLayout(self)
33         self.setLayout(self.layout)
34
35         self.lbl = QtGui.QLabel("(%i,%i)" % (row,col), self)
36         self.layout.addWidget(self.lbl, 0, 0)
37
38         self.dial = QtGui.QDial(self)
39         self.dial.setRange(0,pow(2,16-1))
40         self.connect(self.dial, QtCore.SIGNAL("valueChanged(int)"), self.valueChanged)
41         self.layout.addWidget(self.dial, 1, 0)
42
43     def valueChanged(self, n):
44         self.emit(QtCore.SIGNAL("valueChanged"), self.row, self.column, n)
45
46 class MatrixMixer(QtGui.QWidget):
47     def __init__(self,servername,basepath,parent=None):
48         QtGui.QWidget.__init__(self, parent)
49         self.bus = dbus.SessionBus()
50         self.dev = self.bus.get_object(servername, basepath)
51         self.interface = dbus.Interface(self.dev, dbus_interface="org.ffado.Control.Element.MatrixMixer")
52
53         rows = min(8, self.interface.getRowCount())
54         cols = min(8, self.interface.getColCount())
55
56         layout = QtGui.QGridLayout(self)
57         self.setLayout(layout)
58
59         for i in range(rows):
60             for j in range(cols):
61                 node = MatrixNode(i, j, self)
62                 node.dial.setValue(self.interface.getValue(i, j))
63                 self.connect(node, QtCore.SIGNAL("valueChanged"), self.valueChanged)
64                 layout.addWidget(node, i, j)
65
66     def valueChanged(self, row, column, n):
67         #print "MatrixNode.valueChanged( %i, %i, %i )" % (row,column,n)
68         self.interface.setValue(row, column, n)
69
70 class Saffire_Dice(QtGui.QWidget):
71     def __init__(self, parent=None):
72         QtGui.QWidget.__init__(self, parent)
73         self.layout = QtGui.QGridLayout(self)
74         self.setLayout(self.layout)
75
76     def buildMixer(self):
77         print self.hw
78         print self.hw.getText("/Generic/Nickname")
79         self.matrix = MatrixMixer(self.hw.servername, self.hw.basepath+"/EAP/MatrixMixer", self)
80         self.layout.addWidget(self.matrix)
81
82     def getDisplayTitle(self):
83         return "Experimental EAP Mixer"
84
85
86 #
87 # vim: et ts=4 sw=4
Note: See TracBrowser for help on using the browser.