summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2018-03-19 22:57:01 +0100
committerDavid Runge <dave@sleepmap.de>2018-03-19 22:57:01 +0100
commit22a4418392cb8a11170ba89805bf7c92ebf767f9 (patch)
treee4a83ea89b727ba00f0553a5fcff6f85494a6e58 /classes
parentd11d37ada865ae9579c5eb0de1875e7cd77a6e02 (diff)
downloadusbmidiism-22a4418392cb8a11170ba89805bf7c92ebf767f9.tar.gz
usbmidiism-22a4418392cb8a11170ba89805bf7c92ebf767f9.tar.bz2
usbmidiism-22a4418392cb8a11170ba89805bf7c92ebf767f9.tar.xz
usbmidiism-22a4418392cb8a11170ba89805bf7c92ebf767f9.zip
classes/MIDIDevice.sc: Further specifying addSpec. Patching up connectPassThroughs (has to be moved).
Implementing connectStates.
Diffstat (limited to 'classes')
-rw-r--r--classes/MIDIDevice.sc62
1 files changed, 30 insertions, 32 deletions
diff --git a/classes/MIDIDevice.sc b/classes/MIDIDevice.sc
index f9e9372..a4bcb86 100644
--- a/classes/MIDIDevice.sc
+++ b/classes/MIDIDevice.sc
@@ -4,7 +4,7 @@ MIDIDevice{
<uid,
<inPortNum,
<outPortNum,
- <verbose,
+ <>verbose,
<>states,
<inPort,
<outPort,
@@ -51,19 +51,17 @@ MIDIDevice{
jogwheels = Array.newClear(indexedSize: jogwheelSize);
touchpads = Array.newClear(indexedSize: touchpadSize);
passThroughs = Dictionary();
- if(states.data.size>0, {
- this.connectStates();
- });
this.connectPorts();
- postln("Device '"++name++"' initialized.");
+ postln("Device '"++name++"' (uid: "++uid++") initialized.");
}
addSpec{
- arg name, type, channel, minVal=0, maxVal=127, step=1, default=0, units="";
+ arg name, type, channel, msgNum, minVal=0, maxVal=127, step=1, default=0, units="";
^Dictionary.with(*[
\name->name,
\type->type,
\channel->channel,
+ \msgNum->msgNum,
\spec->ControlSpec.new(
minval: minVal,
maxval: maxVal,
@@ -129,6 +127,7 @@ MIDIDevice{
});
}
+ // TODO: this should be handled with a type of callback in MIDIStateManager
connectPassThroughs{
if(passThroughs.notNil,{
if(verbose,{
@@ -155,8 +154,10 @@ MIDIDevice{
{type==\stop}{outPort.stop}
{type==\continue}{outPort.continue};
},
- chan: channel,
- msgType: type,
+ chan: channel.asInteger,
+// msgNum: msgNum.asInteger,
+ msgType: type.asSymbol,
+ srcID: uid.asInteger
);
});
});
@@ -177,30 +178,27 @@ MIDIDevice{
if(verbose,{
postln("Setting up states for "++name);
});
- states.keysValuesDo({|channel, type|
- MIDIdef.new(
- key: ("state_"++uid++"_"++channel).asSymbol,
- func: {arg ...args;
- if(verbose,{
- ("state_"++uid++"_"++channel++": "++args).postln;
- });
- case
- {type==\control}{outPort.control(chan: channel, val: args[0])}
- {type==\bend}{outPort.bend(chan: channel, val: args[0])}
- {type==\midiClock}{outPort.midiClock}
- {type==\bend}{outPort.bend(chan: channel, veloc: args[0])}
- {type==\noteOn}{outPort.noteOn(chan: channel, note: args[1], veloc: args[0])}
- {type==\noteOff}{outPort.noteOn(chan: channel, note: args[1], veloc: args[0])}
- {type==\polyTouch}{outPort.polyTouch(chan: channel, note: args[1], val: args[0])}
- {type==\program}{outPort.program(chan: channel, num: args[0])}
- {type==\touch}{outPort.touch(chan: channel, val: args[0])}
- {type==\start}{outPort.start}
- {type==\stop}{outPort.stop}
- {type==\continue}{outPort.continue};
- },
- chan: channel,
- msgType: type,
- );
+ Array.with(faders, potis, buttons, jogwheels, touchpads).do({|group, i|
+ group.do({|msgNum, i|
+ msgNum.do({|event, i|
+ MIDIdef.new(
+ key: ("state_"++uid++"_"++event.at(\name)++"_"
+ ++event.at(\type)).asSymbol,
+ func: {arg ...args;
+ if(verbose,{
+ ("state_"++uid++"_"++event.at(\name)++"_"++event.at(\type)++
+ ": "++args).postln;
+ });
+ states.update(event.at(\name), event.at(\type), args[0],
+ event.at(\channel), event.at(\msgNum));
+ },
+ chan: event.at(\channel).asInteger,
+ msgNum: if(event.at(\msgNum).isInteger,{event.at(\msgNum)}),
+ msgType: event.at(\type).asSymbol,
+ srcID: uid.asInteger,
+ );
+ });
+ });
});
}
}