root/trunk/libffado/support/mixer/ffadomixer.in

Revision 973, 10.5 kB (checked in by ppalmers, 15 years ago)

make quatafire mixer more useful

  • Property svn:executable set to *
Line 
1 #!/usr/bin/python
2 #
3 # Copyright (C) 2005-2007 by Pieter Palmers
4 #               2007-2008 by Arnold Krille
5 #
6 # This file is part of FFADO
7 # FFADO = Free Firewire (pro-)audio drivers for linux
8 #
9 # FFADO is based upon FreeBoB.
10 #
11 # This program is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 #
24
25 import sys
26 # Add the path of the installed ffado-mixer-modules
27 sys.path.append( "$PYTHONDIR" )
28
29 import os
30 import time
31 import dbus
32 from qt import *
33
34 from mixer_phase88 import *
35 from mixer_phase24 import *
36 from mixer_saffirepro import *
37 from mixer_saffire import *
38 from mixer_saffirele import *
39 from mixer_af2 import *
40 from mixer_bcoaudio5 import *
41 from mixer_edirolfa66 import *
42 from mixer_mackie_generic import *
43 from mixer_quatafire import *
44
45 SupportedDevices=[
46     [(0x000aac, 0x00000003),'Phase88Control'],
47     [(0x000aac, 0x00000004),'PhaseX24Control'],
48     [(0x000aac, 0x00000007),'PhaseX24Control'],
49     [(0x00130e, 0x00000003),'SaffireProMixer'],
50     [(0x00130e, 0x00000006),'SaffireProMixer'],
51     [(0x00130e, 0x00000000),'SaffireMixer'],
52     [(0x001486, 0x00000af2),'AudioFire2Mixer'],
53     [(0x0007f5, 0x00010049),'BCoAudio5Control'],
54     [(0x0040AB, 0x00010049),'EdirolFa66Control'],
55     [(0x00000f, 0x00010067),'MackieGenericControl'],
56     [(0x000f1b, 0x00010064),'QuataFireMixer'],
57     ]
58
59 class ControlInterface:
60     def __init__(self, servername, basepath):
61         self.basepath=basepath
62         self.servername=servername
63         self.bus=dbus.SessionBus()
64
65     def setContignuous(self, subpath, v, idx=None):
66         try:
67             path = self.basepath + subpath
68             dev = self.bus.get_object(self.servername, path)
69             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous')
70             if idx == None:
71                 dev_cont.setValue(v)
72             else:
73                 dev_cont.setValueIdx(idx,v)
74         except:
75             print "Failed to set Continuous %s on server %s" % (path, self.servername)
76
77     def getContignuous(self, subpath, idx=None):
78         try:
79             path = self.basepath + subpath
80             dev = self.bus.get_object(self.servername, path)
81             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous')
82             if idx == None:
83                 return dev_cont.getValue()
84             else:
85                 return dev_cont.getValueIdx(idx)
86         except:
87             print "Failed to get Continuous %s on server %s" % (path, self.servername)
88             return 0
89
90     def setDiscrete(self, subpath, v):
91         try:
92             path = self.basepath + subpath
93             dev = self.bus.get_object(self.servername, path)
94             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete')
95             dev_cont.setValue(v)
96         except:
97             print "Failed to set Discrete %s on server %s" % (path, self.servername)
98
99     def getDiscrete(self, subpath):
100         try:
101             path = self.basepath + subpath
102             dev = self.bus.get_object(self.servername, path)
103             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete')
104             return dev_cont.getValue()
105         except:
106             print "Failed to get Discrete %s on server %s" % (path, self.servername)
107             return 0
108
109     def setText(self, subpath, v):
110         try:
111             path = self.basepath + subpath
112             dev = self.bus.get_object(self.servername, path)
113             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Text')
114             dev_cont.setValue(v)
115         except:
116             print "Failed to set Text %s on server %s" % (path, self.servername)
117
118     def getText(self, subpath):
119         try:
120             path = self.basepath + subpath
121             dev = self.bus.get_object(self.servername, path)
122             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Text')
123             return dev_cont.getValue()
124         except:
125             print "Failed to get Text %s on server %s" % (path, self.servername)
126             return 0
127
128     def setMatrixMixerValue(self, subpath, row, col, v):
129         try:
130             path = self.basepath + subpath
131             dev = self.bus.get_object(self.servername, path)
132             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.MatrixMixer')
133             dev_cont.setValue(row, col, v)
134         except:
135             print "Failed to set MatrixMixer %s on server %s" % (path, self.servername)
136
137     def getMatrixMixerValue(self, subpath, row, col):
138         try:
139             path = self.basepath + subpath
140             dev = self.bus.get_object(self.servername, path)
141             dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.MatrixMixer')
142             return dev_cont.getValue(row, col)
143         except:
144             print "Failed to get MatrixMixer %s on server %s" % (path, self.servername)
145             return 0
146
147 class DeviceManagerInterface:
148     def __init__(self, servername, basepath):
149         self.basepath=basepath + '/DeviceManager'
150         self.servername=servername
151         self.bus=dbus.SessionBus()
152         self.dev = self.bus.get_object(self.servername, self.basepath)
153         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.Container')
154            
155     def getNbDevices(self):
156         return self.iface.getNbElements()
157     def getDeviceName(self, idx):
158         return self.iface.getElementName(idx) 
159
160 class ConfigRomInterface:
161     def __init__(self, servername, devicepath):
162         self.basepath=devicepath + '/ConfigRom'
163         self.servername=servername
164         self.bus=dbus.SessionBus()
165         self.dev = self.bus.get_object(self.servername, self.basepath)
166         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.ConfigRomX')
167     def getGUID(self):
168         return self.iface.getGUID()
169     def getVendorName(self):
170         return self.iface.getVendorName()
171     def getModelName(self):
172         return self.iface.getModelName()
173     def getVendorId(self):
174         return self.iface.getVendorId()
175     def getModelId(self):
176         return self.iface.getModelId()
177
178 class ClockSelectInterface:
179     def __init__(self, servername, devicepath):
180         self.basepath=devicepath + '/Generic/ClockSelect'
181         self.servername=servername
182         self.bus=dbus.SessionBus()
183         self.dev = self.bus.get_object(self.servername, self.basepath)
184         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.AttributeEnum')
185     def count(self):
186         return self.iface.count()
187     def select(self, idx):
188         return self.iface.select(idx)
189     def selected(self):
190         return self.iface.selected()
191     def getEnumLabel(self, idx):
192         return self.iface.getEnumLabel(idx)
193     def attributeCount(self):
194         return self.iface.attributeCount()
195     def getAttributeValue(self, idx):
196         return self.iface.getAttributeValue(idx)
197     def getAttributeName(self, idx):
198         return self.iface.getAttributeName(idx)
199
200 if __name__ == "__main__":
201    
202     server='org.ffado.Control'
203     basepath='/org/ffado/Control'
204    
205     app = QApplication(sys.argv)
206    
207     msg = QMessageBox()
208
209     repeat = 1
210     while repeat > 0:
211         try:
212             devmgr=DeviceManagerInterface(server, basepath)
213             repeat -= 1
214         except dbus.DBusException, ex:
215             print "\n"
216             print "==========================================================="
217             print "ERROR: Could not communicate with the FFADO DBus service..."
218             print "==========================================================="
219             print "\n"
220             tmp = msg.question( msg, "FFADO-DBus not found", "<qt><b>The connection to FFADOs DBus service could not be established.</b><p>Probably you didn't start the ffado-dbus-server. Should I try this now?</qt>", QMessageBox.Yes, QMessageBox.No )
221             if tmp == 4:
222                 sys.exit(-1)
223             else:
224                 os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" )
225                 nb_checks = 10
226                 while nb_checks > 0:
227                     nb_checks = nb_checks - 1
228                     try:
229                         devmgr=DeviceManagerInterface(server, basepath)
230                         nb_checks = 0
231                         repeat = 0
232                     except dbus.DBusException, ex:
233                         time.sleep( 1 )
234
235     nbDevices=devmgr.getNbDevices()
236    
237     forms=[];
238     for idx in range(nbDevices):
239         path=devmgr.getDeviceName(idx)
240         print "Found device %d: %s" % (idx, path)
241        
242         cfgrom = ConfigRomInterface(server, basepath+'/DeviceManager/'+path)
243         vendorId = cfgrom.getVendorId()
244         modelId = cfgrom.getModelId()
245         GUID = cfgrom.getGUID()
246         print " Found (%s, %X, %X) %s %s" % (str(GUID), vendorId, modelId, cfgrom.getVendorName(), cfgrom.getModelName())
247        
248         thisdev=(vendorId, modelId);
249        
250         for dev in SupportedDevices:
251             if dev[0] == thisdev:
252                 mixerapp = dev[1]
253                
254                 # hack for the focusrite devices
255                 # Saffire:        0x130e010001????
256                 # SaffireLE:    0x130e010004????
257                 if thisdev == (0x00130e, 0x00000000):
258                     if int(GUID, 16) < 0x130e0100040000:
259                         mixerapp = "SaffireMixer"
260                     else:
261                         mixerapp = "SaffireLEMixer"
262
263                 print mixerapp
264                 exec('forms.append('+mixerapp+'())')
265                 forms[idx].hw = ControlInterface(server, basepath+'/DeviceManager/'+path)
266                 forms[idx].clockselect = ClockSelectInterface(server, basepath+'/DeviceManager/'+path)
267                 forms[idx].initValues()
268                 forms[idx].show()
269                 app.setMainWidget(forms[idx])
270
271     if forms:
272         QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
273
274         app.exec_loop()
275     else:
276         print "No supported device found..."
277         msg.information( msg, "No mixer found", "Your device doesn't seem to have a supported mixer." )
Note: See TracBrowser for help on using the browser.