summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2018-03-19 22:53:50 +0100
committerDavid Runge <dave@sleepmap.de>2018-03-19 22:53:50 +0100
commit48d9b39b92e072b09fe7110685ffed2ef97078b9 (patch)
treeb7b7964dba9095ef2dd8eb30820dc4a196a2567c /classes
parentfc36452315295b79c4b43155e228e38b47ab13e5 (diff)
downloadusbmidiism-48d9b39b92e072b09fe7110685ffed2ef97078b9.tar.gz
usbmidiism-48d9b39b92e072b09fe7110685ffed2ef97078b9.tar.bz2
usbmidiism-48d9b39b92e072b09fe7110685ffed2ef97078b9.tar.xz
usbmidiism-48d9b39b92e072b09fe7110685ffed2ef97078b9.zip
classes/MIDIState.sc: Adding update method to update data and banks (for now rudimentarily). Adding takeOver method to set takeover=true on all MIDIStateEvents.
Adding convenience methods to post data and banks. Cleaning up variables.
Diffstat (limited to 'classes')
-rw-r--r--classes/MIDIState.sc54
1 files changed, 51 insertions, 3 deletions
diff --git a/classes/MIDIState.sc b/classes/MIDIState.sc
index 2b3da3c..40c4b0f 100644
--- a/classes/MIDIState.sc
+++ b/classes/MIDIState.sc
@@ -1,21 +1,69 @@
MIDIState{
- var <name, <>uid, <>inPortNum, <>outPortNum, <data, <>connected=false;
+ var <name, <>uid, <>inPortNum, <>outPortNum, <>verbose, <data, <banks,
+ <currentBank, <>connected=false;
*new{
- arg name, uid, inPortNum, outPortNum;
+ arg name, uid, inPortNum, outPortNum, verbose;
^super.newCopyArgs(
name,
uid,
inPortNum,
- outPortNum
+ outPortNum,
+ verbose
).initState();
}
initState{
data = Dictionary();
+ banks = Dictionary();
+ currentBank = 0;
connected = true;
}
+ update{
+ arg name, type, value, chan, msgNum;
+ if(verbose,{
+ postln(name++": ["++name.asString++", "++chan.asString++
+ ", "++type.asString++", " ++value.asString++"]");
+ });
+ // TODO: check whether event is a bankUp/bankDown event
+ data.add(name -> MIDIStateEvent.new(type.asString, value, chan, msgNum));
+ // if a bank-able event is changed
+ if("(channel|fader|button|poti)[1-9]".matchRegexp(name.asString),{
+ // create current bank, if not available yet
+ if(banks.at(currentBank).isKindOf(Dictionary).not,{
+ banks.add(currentBank -> Dictionary.new());
+ });
+ banks.at(currentBank).add(name -> MIDIStateEvent.new(type.asString,
+ value, chan, msgNum));
+ });
+ }
+
+ postData{
+ data.keysValuesDo({|name,event|
+ post(name++" -> ");
+ event.postln;
+ });
+ }
+ postBanks{
+ banks.keysValuesDo({|number,bank|
+ postln("Bank "++number++":");
+ bank.keysValuesDo({|name,event|
+ post(name++" -> ");
+ event.postln;
+ });
+ });
+ }
+
+ // set takeOver to true for all available MIDIStateEvents
+ takeOver{
+ [banks, data].do({|dict|
+ dict.valuesDo({|event|
+ event.takeOver=true;
+ });
+ });
+ }
}
+