diff --git a/mapping/Yamaha.py b/mapping/Yamaha.py new file mode 100644 index 0000000..4171ea6 --- /dev/null +++ b/mapping/Yamaha.py @@ -0,0 +1,80 @@ +from mapping.base import BasicMessageParse,BasicActions,MatchError,BasicMidiInterface +import mido +import re,configparser + +commandlist={0:"DCA",55:"IN",84:"MIX",101:"MATRICE",115:"MASTER",82:"MASTER2",51:"PAGE",53:"MUTE"} +# Doc says 11 is go_off, test says otherwise + +#A MessageParse object MUST be included in the file, the rest is implementation Specific +class MessageParse(BasicMessageParse): + """Parsing of a Yamaha SyEx message this parser is used once \ + and will return a different Action object every time it is called""" + + def __init__(self): + #The data is converted from hex to decimal for readability and usability by mido + self.typebit=0 # 6th number, usually 0. 1 is DCA and pages. 2 is second master. + self.command=None # 7th number. The command sent + self.data=None #The actual data + + self._commandlist=commandlist + + def __call__(self,message): + "Parse the message and return either a match or raise an error" + if message.type=="sysex": + message=message.data + else: + raise MatchError("Message is not sysex") + try: + self.typebit=message[5] + self.command=message[6] + self.data=message[7:] + return self + except: + raise MatchError("Can't parse the data {}".format(message)) + + def __str__(self): + return "[type:{}/cmd:{}/data:{}]".format(\ + self.typebit,self.command,self.data) + +def makeInt(table): + "Take the weird tuple from 00,00 to 6,127 and make a number from 0 to 127" + return int((table[0]*127+table[1])/8) + +# An Action object MUST be included in the file. +class Actions(BasicActions): + """The list of action to perform when a message is read""" + def __init__(self, interface): + super(Actions, self).__init__(interface) + + # This funtion is MANDATORY, it makes the link between MessageParse and Action + def __call__(self,match): + "Make the link between the regex and the action" + action=commandlist[int(match.command)] + id,value="1","1" + page=0 # Yamaha consoles don't use pages in a way that is relevant to us + #"DCA",55:"IN",84:"MIX",101:"MATRICE",115:"MASTER",82:"MASTER2",51:"PAGE" + if action in ["DCA","IN","MIX","MATRICE","MASTER","MASTER2"]: + data=match.data + #print(data[6:8],makeInt(data[6:8])) + value=makeInt(data[6:8]) + id=int(data[3]) # Just mapped from 0 to 127 + elif action=="CUE": + pass + elif action=="MUTE": + pass + elif action=="PAGE": + pass + else: + return + try: + print(action,value) + listact=self.findAction(action,id,page) + for act in listact: + act(value) + except: + # No action linked to the trigger + pass + +# Same as above, import BasicMidiInterface as MidiInterface could be used instead +# MidiInterface(config) +MidiInterface=BasicMidiInterface diff --git a/mapping/yamaha.txt b/mapping/yamaha.txt new file mode 100644 index 0000000..8fc403f --- /dev/null +++ b/mapping/yamaha.txt @@ -0,0 +1,34 @@ +IN +1:0 f0 43 10 3e 19 01 00 37 00 00 00 00 00 00 00 00 00 f7 +1:100 f0 43 10 3e 19 01 00 37 00 00 00 00 00 00 00 07 7f f7 +2:0 f0 43 10 3e 19 01 00 37 00 00 00 01 00 00 00 00 00 f7 +2:100 f0 43 10 3e 19 01 00 37 00 00 00 01 00 00 00 07 7f f7 +DCA +16:100 f0 43 10 3e 19 01 01 00 00 00 00 0f 00 00 00 07 7f f7 +MIX +1:100 f0 43 10 3e 19 01 00 54 00 00 00 00 00 00 00 07 7f f7 +MATRICE +8:100 f0 43 10 3e 19 01 00 65 00 00 00 07 00 00 00 07 7f f7 +MASTER +1 f0 43 10 3e 19 01 00 73 00 00 00 01 00 00 00 07 7f f7 +2 f0 43 10 3e 19 01 02 52 00 13 00 00 00 00 00 07 7f f7 + + + + +MUTE +OFF f0 43 10 3e 19 01 00 35 00 00 00 00 00 00 00 00 01 f7 +ON f0 43 10 3e 19 01 00 35 00 00 00 00 00 00 00 00 01 f7 + +CUE +ON f0 43 10 3e 19 01 02 09 00 00 00 00 00 00 00 00 01 f7 + f0 43 10 3e 19 01 07 04 00 00 00 00 00 00 00 00 01 f7 +OFF f0 43 10 3e 19 01 02 09 00 00 00 00 00 00 00 00 00 f7 + f0 43 10 3e 19 01 07 04 00 00 00 00 00 00 00 00 00 f7 + +PAGE +IN:1 f0 43 10 3e 19 01 01 33 00 00 00 00 00 00 00 00 00 f7 +IN:2 f0 43 10 3e 19 01 01 33 00 00 00 00 00 00 00 00 01 f7 +IN:3 f0 43 10 3e 19 01 01 33 00 00 00 00 00 00 00 00 02 f7 +DCAM:1 f0 43 10 3e 19 01 01 33 00 04 00 00 00 00 00 00 00 f7 +DCAD:1 f0 43 10 3e 19 01 01 33 00 01 00 00 00 00 00 00 01 f7 diff --git a/patch/cl5.ini b/patch/cl5.ini new file mode 100644 index 0000000..1653316 --- /dev/null +++ b/patch/cl5.ini @@ -0,0 +1,20 @@ +[interface] + input=Scarlett 6i6 USB MIDI 1 + output1=MIDI Mix MIDI 1 + output2=Scarlett 6i6 USB MIDI 1 + inputchanel = 1 + outputchannel1 = 1 + outputchannel2 = 1 + mapping = Yamaha + +[IN] + 0-99 = 2/cc/1 + #0-99/toggle = 0/127 + #0-50 = 2/cc/11 + #57-67 = 1/cc/12-32 + #56 = 1/note/127 + #56/val = lambda x: min(x,50)*2 + +[MATRICE] + 10 = 2/cc/1;2/cc/2;2/cc/3 + 10/toggle = 0/45 diff --git a/patch/test.ini b/patch/test.ini index 13f9dff..7b6e6fb 100644 --- a/patch/test.ini +++ b/patch/test.ini @@ -1,7 +1,7 @@ [interface] input=Midi Through Port-0 output1=Midi Through Port-0 - output2=KMidimon + output2=Midi Through Port-0 channelinput = 1 channelout1 = 1 channelout2 = 1 diff --git a/test.py b/test.py index 56b87c4..9f89695 100644 --- a/test.py +++ b/test.py @@ -81,6 +81,7 @@ class mappingTest(minitest.simpleTestUnit): def interfaceOut(self,nb): class EmptySender(): def __init__(self): + self.name="none:none" pass def send(self,wev,**kwargs): pass diff --git a/yamaha.txt b/yamaha.txt deleted file mode 100644 index 5f748c4..0000000 --- a/yamaha.txt +++ /dev/null @@ -1,35 +0,0 @@ -IN -1:0 f0 43 10 3e 19 01 00 37 00 00 00 00 00 00 00 00 00 f7 -1: 100 f0 43 10 3e 19 01 00 37 00 00 00 00 00 00 00 07 7f f7 -2:0 f0 43 10 3e 19 01 00 37 00 00 00 01 00 00 00 00 00 f7 -2:100 f0 43 10 3e 19 01 00 37 00 00 00 01 00 00 00 07 7f f7 -DCA -16:100 f0 43 10 3e 19 01 01 00 00 00 00 0f 00 00 00 07 7f f7 -MIX -1:100 f0 43 10 3e 19 01 00 54 00 00 00 00 00 00 00 07 7f f7 -MATRICE -8:100 f0 43 10 3e 19 01 00 65 00 00 00 07 00 00 00 07 7f f7 -MASTER -1 f0 43 10 3e 19 01 00 73 00 00 00 01 00 00 00 07 7f f7 -2 f0 43 10 3e 19 01 02 52 00 13 00 00 00 00 00 07 7f f7 - - - - -IN -OFF f0 43 10 3e 19 01 00 35 00 00 00 00 00 00 00 00 01 f7 -ON f0 43 10 3e 19 01 00 35 00 00 00 00 00 00 00 00 01 f7 - -CUE -ON f0 43 10 3e 19 01 02 09 00 00 00 00 00 00 00 00 01 f7 - f0 43 10 3e 19 01 07 04 00 00 00 00 00 00 00 00 01 f7 -OFF f0 43 10 3e 19 01 02 09 00 00 00 00 00 00 00 00 00 f7 - f0 43 10 3e 19 01 07 04 00 00 00 00 00 00 00 00 00 f7 - -PAGE -IN:1 f0 43 10 3e 19 01 01 33 00 00 00 00 00 00 00 00 00 f7 -IN:2 f0 43 10 3e 19 01 01 33 00 00 00 00 00 00 00 00 01 f7 -IN:3 f0 43 10 3e 19 01 01 33 00 00 00 00 00 00 00 00 02 f7 -DCAM:1 f0 43 10 3e 19 01 01 33 00 04 00 00 00 00 00 00 00 f7 -DCAD:1 f0 43 10 3e 19 01 01 33 00 01 00 00 00 00 00 00 01 f7 -