musikinformatik / SuperDirt

Tidal Audio Engine
GNU General Public License v2.0
520 stars 74 forks source link

stop doubling of events inferred by parameters if midicmd is set #168

Closed yaxu closed 4 years ago

telephon commented 4 years ago

Although I think that now you can't send two commands in one event, right? Not sure what was intended. It is slightly messy in terms of functionality. Maybe you could add an explanation in a longer comment in the file?

yaxu commented 4 years ago

@telephon Unless I've made a mistake, you can send multiple commands in one event, but only one of each type.

yaxu commented 4 years ago

(The purpose of this bit of code was to make sure that a command is only sent once if its 'midicmd' is inferred from its parameters, as well as being set explicitly)

telephon commented 4 years ago

Ok, I just don't get what donecmd is doing.

yaxu commented 4 years ago

It unsets midicmd if its action has already been inferred and done.

telephon commented 4 years ago

Ah I see. But wouldn't it have been easier to write instead of:

if(~progNum.notNil)   { var num = ~progNum;   donecmd.value(\program); schedmidi.value({ midiout.program(chan, num) })};

simply

if(~progNum.notNil or: { midicmd === \program })   { var num = ~progNum;  schedmidi.value({ midiout.program(chan, num) })};
yaxu commented 4 years ago

But then there's a bit later on that deals with the midicmd variable in a generic way, so it needs to be unset.