Refined the Class implementation of messages/parsing

This commit is contained in:
Maximilien Rigaut 2019-05-01 16:54:48 +02:00
parent 67d80e5980
commit 65aee17e60
3 changed files with 21 additions and 21 deletions

View File

@ -2,4 +2,4 @@
Get/send midi commands to a GrandMA will be configured to remap all custom messages in a near future
# Depends
Mostly mido (pip install mido) blessing/curses in a near future
Mostly mido (pip install mido) blessing for the testing (pip install belssings)

View File

@ -1,20 +1,18 @@
class BasicMessageParse(object):
"""Classic System Specific Midi Message as Hex (BasicSyHexParse).
Uses one method, parseMidi to parse the message and return a BasicMapping object with the mapping of the message inside"""
from mapping import BasicMessageParse,BasicAction
import mido
def __init__(self):
'''Basic init'''
self.mapping={"value":None,"type":None} # A barebone initialisation, unusable, it will need to be overridden to work
self.value=None
self.
#A MessageParse object MUST be included in the file, the rest is implementation Specific
class MessageParse(BasicMessageParse):
"""Parsing of a gma SyEx message"""
def parseMidi(self,message):
"""Take a midi SyxEx message and return a BasicMapping"""
pass
def __init__(self, arg):
#super(Parse, self).__init__() #The init here is irrelevant
self._mapping = arg
class BasicMapping(object):
"""A basic reading of the message, propreties are initialised depending on the way the SyEx message is formed,
this objet will need the configuration to read and understand the message
"""
class Action(BasicAction):
"""The list of action to perform when a message is read"""
def __init__(self):
pass
def resolve(self,config):
pass

View File

@ -7,15 +7,17 @@ class BasicMessageParse(object):
self._mapping={"value":None,"type":None} # A barebone initialisation, unusable, it will need to be overridden to work
def parseMidi(self,message):
"""Take a midi SyxEx message and return a BasicMapping (there can be many children of BasicMapping to take more properly care of the cases)"""
"""Take a midi SyxEx message and return a BasicAction (there can be many children of BasicAction to take more properly care of the cases)"""
return BasicMapping(self._mapping)
class BasicMapping(object):
class BasicAction(object):
"""A basic reading of the message, propreties are initialised depending on the way the SyEx message is formed,
this objet will need the configuration to read and understand the message
"""
this objet will need the configuration to read and understand the message"""
def __init__(self,dictmapping):
'Barebone init'
self._mapping=dictmapping
def
def resolve(self,config):
"Resolve the current action, all actions will be performed depending on what's inside the mapping and the config"
pass