summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
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,
+ );
+ });
+ });
});
}
}