Help implementing a midi channel switcher?

sacrebleu

2015-07-27 22:23:01

Greetings. I'm trying to use BMT to implement a midi channel switcher using a Korg Nano Kontrol. I'm brand new to this program. I've had some basic programming experience, tho long ago. What I'd like to do is use 2 buttons on the nano to increment and decrement the midi channel for the messages coming from the nano before going on to my software. As far as I can remember, I need to set up a basic counter in BMT, to count the number of button presses that have occurred. I would then have a translator looking for the correct type of message that I want to rechannelize check the counter and use the counters value for the new channel, i.e. replace the value of the incoming message's midi channel data with the value of the counter, and then pass that on to whatever program I have hooked up to receive from BMT.

Right now, assuming my logic so far is correct, I'm stuck on implementing the counter part, which is making me feel rather small, actually...ha ha. I know I need to set up a variable to be incremented or decremented by the value of 1, and not let it go greater than 16 or less than 1 (or 15 and 0, probably more precise to say). I feel like this is a very basic thing, but for whatever reason, my brain is farting out on me and I'm stumped so far. Can anyone help me out here?

Also, I was thinking a good book on this type of basic coding my be a great refresher/tool for me. Gonna do a google search on this shortly, but if anyone has a recommendation along this line that would be greatly appreciated as well.

Thanks much,

Dan

DvlsAdvct

2015-07-27 22:30:06

Hi Dan

This is a lot easier than it seems. You want to have two translators, one for up and one for down. They would look something like this:

Code: Select all

Translator 1: Channel Up
Incoming Message: 90 30 7F
Rules: g0=g0+1
if g0>15 then g0=0
Outgoing Message: None

Translator 2: Channel Down
90 31 7F
Rules: g0=g0-1
if g0<0 then g0=15
Outgoing Message: None

Translator 3: Message Passthrough
Incoming Message: pp qq rr
Rules: pp=pp+g0
Outgoing Message: pp qq rr
That last translator creates a passthrough which adds the extra channel value.

Make sense?
Jared

sacrebleu

2015-07-27 23:58:48

Jared,

Thx for the quick reply. Awesome! I figured out what my hangup was, and I got part of it working. I didn't get the counting limit part right, so I'll check out that part of your code it a second. But I got the thing incrementing, and I did exactly the same as you posted for that part. I was stuck, if you're interested, on how to initialize the variable. I didn't think i could initialize it in the translator, it would just keep getting reset every time the thing executed. I felt sure there had to be away to do that, and after thinking and poking around a bit more it occurred to me to read the manual section on variables (again), where lo and behold I discovered that the global var's are all set to 0 when the program starts. Problem solved!

Still, man I was racking my brains last night for way to long. Classic. Finally told myself to put it down, and post a question on the forum, and see if my subconscious might sort it out in the meantime. That seemed to happen, sort of! Should've just posted my question sooner, but I was in a stubborn mood apparently.

Anyways thanks very much. Been a long long time since I did any coding. Hoping to do do st least a bit of cool stuff with this program.

Cheers,
Dan

DvlsAdvct

2015-07-28 20:03:52

Glad to hear, Dan.

Don't hesitate to bring your questions to the forums. There are some really talented users here who put me to shame.

Jared