Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit 9f139ae

Browse files
authored
Merge pull request #168 from musikinformatik/topic-polymidi
stop doubling of events inferred by parameters if midicmd is set
2 parents e00f4cd + d7202e2 commit 9f139ae

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

classes/DirtEventTypes.sc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DirtEventTypes {
4141

4242
var freq, lag, sustain;
4343
var args, midiout, hasGate, midicmd, latency, chan;
44-
var sendNRPN, schedmidi, schedmidicmd;
44+
var sendNRPN, schedmidi, schedmidicmd, donecmd;
4545
var hasNote = ~n != \none;
4646

4747
midiout = ~midiout.value;
@@ -60,14 +60,17 @@ DirtEventTypes {
6060
} {
6161
{|f| thisThread.clock.sched(latency, f)}
6262
};
63+
donecmd = { |cmd|
64+
if (midicmd.notNil and: { midicmd === cmd }) {
65+
midicmd = nil
66+
}
67+
};
6368
schedmidicmd = { |cmd|
6469
var func;
6570
func = Event.default[\midiEventFunctions][cmd];
6671
args = func.valueEnvir.asCollection;
6772
schedmidi.value { midiout.performList(cmd, args) };
68-
if (midicmd.notNil && midicmd === cmd) {
69-
midicmd = nil
70-
};
73+
donecmd.value(cmd);
7174
};
7275

7376
// guess MIDI events from parameters
@@ -92,9 +95,9 @@ DirtEventTypes {
9295
});
9396
};
9497

95-
if(~progNum.notNil) { var num = ~progNum; schedmidi.value({ midiout.program(chan, num) })};
96-
if(~midibend.notNil) { var val = ~midibend; schedmidi.value({ midiout.bend(chan, val) })};
97-
if(~miditouch.notNil) { var val = ~miditouch; schedmidi.value({ midiout.touch(chan, val) })};
98+
if(~progNum.notNil) { var num = ~progNum; donecmd.value(\program); schedmidi.value({ midiout.program(chan, num) })};
99+
if(~midibend.notNil) { var val = ~midibend; donecmd.value(\bend); schedmidi.value({ midiout.bend(chan, val) })};
100+
if(~miditouch.notNil) { var val = ~miditouch; donecmd.value(\touch); schedmidi.value({ midiout.touch(chan, val) })};
98101

99102
if (hasNote) {
100103
freq = ~freq.value;

0 commit comments

Comments
 (0)