Index: /trunk/libffado/support/mixer/mixer_phase88.ui =================================================================== --- /trunk/libffado/support/mixer/mixer_phase88.ui (revision 459) +++ /trunk/libffado/support/mixer/mixer_phase88.ui (revision 459) @@ -0,0 +1,711 @@ + +Phase88Control +Python: +Python:# Import the OSC module +Python:import osc + + + + Phase88Control + + + + 0 + 0 + 682 + 439 + + + + Terratec Phase 88 Control + + + + textLabel1 + + + + 10 + 10 + 160 + 30 + + + + Mixer bus output: + + + + + textLabel1_2_2 + + + + 10 + 310 + 190 + 30 + + + + In 7/8 Input Select + + + + + + Front + + + + + Back + + + + comboFrontBack + + + + 201 + 310 + 100 + 30 + + + + + + textLabel1_2 + + + + 10 + 270 + 190 + 30 + + + + Waveplay Channel Source + + + + + textLabel1_2_3 + + + + 10 + 390 + 190 + 30 + + + + External Sync Source + + + + + + S/PDIF + + + + + WordClock + + + + comboExtSync + + + + 200 + 390 + 100 + 31 + + + + + + textLabel1_2_3_2 + + + + 10 + 350 + 190 + 30 + + + + Sync Source + + + + + + S/PDIF + + + + + CH 1/2 + + + + + CH 3/4 + + + + + CH5/6 + + + + + CH7/8 + + + + comboInAssign + + + + 200 + 270 + 100 + 31 + + + + + + + Internal + + + + + External + + + + comboSyncSource + + + + 200 + 350 + 100 + 31 + + + + + + + S/PDIF Out + + + + + Line Out 1/2 + + + + + Line Out 3/4 + + + + + Line Out 5/6 + + + + + Line Out 7/8 + + + + + None + + + + comboOutAssign + + + + 180 + 10 + 160 + 30 + + + + + + groupBox1 + + + + 10 + 50 + 400 + 181 + + + + Hardware Mixer + + + + textLabel2 + + + + 20 + 20 + 22 + 21 + + + + 1/2 + + + + + textLabel2_2 + + + + 60 + 20 + 22 + 21 + + + + 3/4 + + + + + textLabel2_3 + + + + 100 + 20 + 22 + 21 + + + + 5/6 + + + + + textLabel2_4 + + + + 140 + 20 + 22 + 21 + + + + 7/8 + + + + + textLabel2_4_2 + + + + 180 + 20 + 41 + 21 + + + + S/PDIF + + + + + textLabel2_4_2_2_2 + + + + 340 + 20 + 50 + 21 + + + + Master + + + + + sldInput12 + + + + 20 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + sldInput34 + + + + 60 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + sldInput56 + + + + 100 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + sldInput78 + + + + 140 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + sldInputSPDIF + + + + 190 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + sldInputWavePlay + + + + 260 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + sldInputMaster + + + + 350 + 50 + 24 + 120 + + + + 0 + + + 32767 + + + 10000 + + + 1000 + + + Vertical + + + Both + + + 10000 + + + + + textLabel2_4_2_2 + + + + 240 + 20 + 70 + 21 + + + + WavePlay + + + + + + + comboOutAssign + activated(int) + Phase88Control + switchOutAssign(int) + + + comboFrontBack + activated(int) + Phase88Control + switchFrontState(int) + + + comboInAssign + activated(int) + Phase88Control + switchWaveInAssign(int) + + + comboSyncSource + activated(int) + Phase88Control + switchSyncSource(int) + + + comboExtSync + activated(int) + Phase88Control + switchExtSyncSource(int) + + + sldInput12 + valueChanged(int) + Phase88Control + setVolume12(int) + + + sldInput34 + valueChanged(int) + Phase88Control + setVolume34(int) + + + sldInput56 + valueChanged(int) + Phase88Control + setVolume56(int) + + + sldInput78 + valueChanged(int) + Phase88Control + setVolume78(int) + + + sldInputMaster + valueChanged(int) + Phase88Control + setVolumeMaster(int) + + + sldInputSPDIF + valueChanged(int) + Phase88Control + setVolumeSPDIF(int) + + + sldInputWavePlay + valueChanged(int) + Phase88Control + setVolumeWavePlay(int) + + + + mixer_phase88.ui.h + + + switchFrontState( int ) + switchOutAssign( int ) + switchWaveInAssign( int ) + switchSyncSource( int ) + switchExtSyncSource( int ) + setVolume12( int ) + setVolume34( int ) + setVolume56( int ) + setVolume78( int ) + setVolumeSPDIF( int ) + setVolumeWavePlay( int ) + setVolumeMaster( int ) + + + Index: /trunk/libffado/support/mixer/mixer_phase88.ui.h =================================================================== --- /trunk/libffado/support/mixer/mixer_phase88.ui.h (revision 459) +++ /trunk/libffado/support/mixer/mixer_phase88.ui.h (revision 459) @@ -0,0 +1,102 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you want to add, delete, or rename functions or slots, use +** Qt Designer to update this file, preserving your code. +** +** You should not define a constructor or destructor in this file. +** Instead, write your code in functions called init() and destroy(). +** These will automatically be called by the form's constructor and +** destructor. +*****************************************************************************/ + + +void Phase88Control::switchFrontState( int ) +{ + + if a0 == 0: + state=0 + else : + state=1 + + print "switching front/back state to %d" % state + + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "selector", 10, state]).sendlocal(17820) +} + +void Phase88Control::switchOutAssign( int ) +{ + print "switching out assign to %d" % a0 + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "selector", 6, a0]).sendlocal(17820) +} + +void Phase88Control::switchWaveInAssign( int ) +{ + print "switching input assign to %d" % a0 + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "selector", 7, a0]).sendlocal(17820) +} + +void Phase88Control::switchSyncSource( int ) +{ + print "switching sync source to %d" % a0 + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "selector", 9, a0]).sendlocal(17820) +} + +void Phase88Control::switchExtSyncSource( int ) +{ + print "switching external sync source to %d" % a0 + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "selector", 8, a0]).sendlocal(17820) +} + + +void Phase88Control::setVolume12( int ) +{ + vol = -a0 + print "setting volume for 1/2 to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 2 , 0, vol]).sendlocal(17820) +} + + +void Phase88Control::setVolume34( int ) +{ + vol = -a0 + print "setting volume for 3/4 to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 3 , 0, vol]).sendlocal(17820) +} + + +void Phase88Control::setVolume56( int ) +{ + vol = -a0 + print "setting volume for 5/6 to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 4 , 0, vol]).sendlocal(17820) + +} + +void Phase88Control::setVolume78( int ) +{ + vol = -a0 + print "setting volume for 7/8 to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 5 , 0, vol]).sendlocal(17820) +} + +void Phase88Control::setVolumeSPDIF( int ) +{ + vol = -a0 + print "setting volume for S/PDIF to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 6 , 0, vol]).sendlocal(17820) +} + +void Phase88Control::setVolumeWavePlay( int ) +{ + vol = -a0 + print "setting volume for WavePlay to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 1 , 0, vol]).sendlocal(17820) +} + +void Phase88Control::setVolumeMaster( int ) +{ + vol = -a0 + print "setting master volume to %d" % vol + osc.Message("/devicemanager/dev0/GenericMixer", ["set", "volume", 7 , 0, vol]).sendlocal(17820) +} Index: /trunk/libffado/support/mixer/mixer_phase88.py =================================================================== --- /trunk/libffado/support/mixer/mixer_phase88.py (revision 459) +++ /trunk/libffado/support/mixer/mixer_phase88.py (revision 459) @@ -0,0 +1,12 @@ +#!/usr/bin/python +# + +from qt import * +from mixer_phase88ui import * +import sys +if __name__ == "__main__": + app = QApplication(sys.argv) + f = Phase88Control() + f.show() + app.setMainWidget(f) + app.exec_loop() Index: /trunk/libffado/support/mixer/osc.py =================================================================== --- /trunk/libffado/support/mixer/osc.py (revision 459) +++ /trunk/libffado/support/mixer/osc.py (revision 459) @@ -0,0 +1,236 @@ +# ====================================================================== +# file: OSC.py +# author: stefan kersten +# contents: OSC client module for python +# license: public domain +# ====================================================================== +# $Id: osc.py,v 1.1 2005/03/01 14:36:21 nebogeo Exp $ +# ====================================================================== +# copyright (c) 2000 stefan kersten +# ====================================================================== +# this module provides simple OSC client functionality +# usage examples down at the end of the file +# ====================================================================== + +__revision__ = "$Revision: 1.1 $" + +# ====================================================================== +# imports + +import cStringIO, exceptions, math, socket, struct, time, types + +# ====================================================================== +# constants + +SECONDS_UTC_TO_UNIX_EPOCH = 2208988800.0 +FLOAT_TO_INT_SCALE = pow(2.0, 32.0) + +# ====================================================================== +# types + +class Value: + """Abstract OSC value.""" + def __init__(self, value): + self.value = value + + def binary_value(self): + pass + + def type_tag(self): + pass + +class Int(Value): + """32 bit integer value.""" + def __init__(self, value): + Value.__init__(self, long(value)) + + def binary_value(self): + return struct.pack('!l', self.value) + + def type_tag(self): + return 'i' + +class Float(Value): + """32 bit floating point value.""" + def __init__(self, value): + Value.__init__(self, float(value)) + + def binary_value(self): + return struct.pack('!f', self.value) + + def type_tag(self): + return 'f' + +class String(Value): + """Null-terminated string padded to multiples of 4 byte.""" + def __init__(self, value): + Value.__init__(self, str(value)) + + def binary_value(self): + v = self.value + l = len(v) + return struct.pack('%ds%dx' % (l, self.pad_amount(l)), v) + + def type_tag(self): + return 's' + + def pad_amount(self, len): + return 4 - (len % 4) + +class Time(Value): + """64 bit timetag in NTP format.""" + def __init__(self, value): + Value.__init__(self, float(value)) + + def __add__(self, time): + return Time(float(self.value + time.value)) + + def binary_value(self): + t = self.value + # FIXME: how to convert without overflows? + s = long(t) + f = long(math.fmod(t, 1.0)*FLOAT_TO_INT_SCALE) + return struct.pack('!LL', s, f) + +# ====================================================================== +# utilities + +time_module = time +def time(): + """Return current time as float in OSC format.""" + return SECONDS_UTC_TO_UNIX_EPOCH + time_module.time() + +# ====================================================================== +# classes + +class Packet: + """Abstract base class for all OSC-related containers. + + Has methods for retrieving the proper binary representation + and its size. + """ + def __init__(self, packets): + stream = cStringIO.StringIO() + self._write_contents(packets, stream) + self._data = stream.getvalue() + + def get_packet(self): + """Return the binary representation of the receiver's contents. + + This data is in the proper OSC format and can be sent over a + socket. + """ + return self._data + + def get_size(self): + """Return the size of the receiver's binary data.""" + return len(self._data) + + def _write_contents(self, packets, stream): + """Write packets on stream. + + Private. + + Override in subclasses for specific behavior. + """ + pass + + def __repr__(self): + return '<' + \ + str(self.__class__.__name__) + \ + ' instance, size=' + \ + str(self.get_size()) + \ + '>' + + def sendto(self, host, port): + """Send the receiver's data through a UDP socket.""" + s = socket.socket(socket.SOCK_DGRAM, socket.AF_INET) + packet = self.get_packet() + s.sendto(packet, (host, port)) + s.close() + + def sendlocal(self, port): + """Send the receiver's data through a UDP socket locally.""" + self.sendto('localhost', port) + +def _value(x): + """Convert x(int, float or string) to an OSC object.""" + t = type(x) + if t == types.FloatType: + return Float(x) + if t == types.IntType or t == types.LongType: + return Int(x) + # return string representation as default + return String(str(x)) + +class Message(Packet): + """Single OSC message with arguments. + + Message(address, *args) -> Message + + address -- OSC address string + *args -- message argument list + """ + def __init__(self, address, args=[]): + Packet.__init__(self, [String(address)] + map(lambda x: _value(x), args)) + + def _write_contents(self, args, stream): + t_stream = cStringIO.StringIO() # tag stream + v_stream = cStringIO.StringIO() # value stream + # open signature string + t_stream.write(',') + # collect tags and arguments + for v in args[1:]: + t_stream.write(v.type_tag()) + v_stream.write(v.binary_value()) + # write address + stream.write(args[0].binary_value()) + # write signature + stream.write(String(t_stream.getvalue()).binary_value()) + # write arguments + stream.write(v_stream.getvalue()) + +class Bundle(Packet): + """OSC container type with timing information. + + Bundle(time, packets) -> Bundle + + time -- floating point timetag in OSC units + packets -- array of Packet(s) + """ + def __init__(self, time, packets): + Packet.__init__(self, [Time(time)] + packets) + + def _write_contents(self, args, stream): + # write '#bundle' preamble + stream.write(String('#bundle').binary_value()) + # write timetag + stream.write(args[0].binary_value()) + # write packets, prefixed with a byte count + for packet in args[1:]: + data = packet.get_packet() + size = len(data) + stream.write(Int(size).binary_value()) + stream.write(data) + +def test(port): + """Some example messages and bundles, sent to port.""" + Message("/filter/cutoff", [145.1232]).sendlocal(port) + Message("/http", ["www dot k-hornz dot de", 12, 3.41, "bulb"]).sendlocal(port) + # print Int(len(Message("/msg").get_packet())).binary_value() + Bundle(0.1, [Message("/fubar")]).sendlocal(port) + Bundle(time(), [Message("/msg", [1.0, "+", 1, 61, "0"]), Message("/bang!")]).sendlocal(port) + +def test2(): + """Some example messages and bundles, sent to port.""" + Message("/noisepattern/start", ["hello"]).sendlocal(9898989) + Message("/noisepattern/modify", [1, "hello", "two"]).sendlocal(9898989) + print("/noisepattern/start") + +if __name__ == "__main__": + """Run dump on port 10000.""" + #test(10000) + test2() + +# EOF +# ======================================================================