Page 1 of 1

Send pitch bend with lemur scripting (MIDI programming ?)

Posted: 30 Dec 2012 20:43
by Traxus
I would like to send pitch bend signals via scripting. I was able to findthis thread on another forum, which should be everything that I need spare my general ignorance towards the nuts and bolts of general midi programming. (The whole MSB/LSB thing has me confused)...

Basically, I have a pair of faders, Coarse and Fine, that combine to make a value between 0 and 1, and I want to interpolate this value (pitchControlX) into a pitch bend message.
PitchControl.png
PitchControl.png (14.45 KiB) Viewed 4067 times
I would like to cannibalize these settings into the code:
PitchBendSettings.png
PitchBendSettings.png (9.11 KiB) Viewed 4067 times
According to the thread linked above, the target for pitch bend is 224... but what do I do for x and y in this snippiet?:

Code: Select all

midiout(2,{224,x,y});
I know a quick work around would be to map pitchControlX into a third, invisible fader, and then set the pitch bend midi signal with the GUI as per the second photo, but this object is going to be re-used and I would like to be able to set a variable to control the midi channel...

Thanks

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 31 Dec 2012 00:31
by Traxus
Well, after a few hours of reading and random plug and chug this is what I ended up with... This maps it from 0-127, which is okay...

From What I understand, it is possible to use values greater than 127 (ie the 16383 in the second image of my first post) which is ideal for something as fine tuned as this. Obviously, having 16000 possible steps allots for far greater fine tuning than 127...

If anyone has further advice, let me know.

Code: Select all

//-----On Expression PitchControl.pitchControlX (any)
decl p = PitchControl.pitchControlX;
decl r = 127;
decl x = floor(range(p, 0, r));
midiout(0,{224,r,x});

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 01 Jan 2013 04:37
by Macciza
Hi
A few comments

Do you want pitch bend both up and down? Maybe use Sliders so you can go bipolar . . .
Also then the range of value is -8192 to +8192 and 0 = MSB-64 LSB 0
MSB is the coarse val and LSB is the Fine val . ..
You may also want to make it that when the MSB changes a value it reset LSB to 0
Or even work it so that when LSB is held at 0 or 127 it makes the MSB move as needed to 'scroll' the value . . .

And then the range thing as well . . .
May just need to think about it a bit more

MM

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 30 Mar 2014 17:26
by Traxus
15 months later: :roll: 127 * 127 = 16383. Now I get it.

Code: Select all

//-----x = a 0 to 1 value from a fader etc...
//-----d = a 1 to 16 value of the midi channel you wish to transmit on

decl src = range(x, 0, 127);
decl msb = floor(src);
decl lsb = range((src - msb), 0, 127);
decl msg = 224 + (d - 1);
midiout(0, {msg,lsb,msb});

LSB/MSB... makes so much sense now. MSB are the big steps, LSB are the sub steps between each big step.

Remembering that 127 * 127 = 16383,

A MSB of 10, and an LSB of 0 will output a value of 1270 via (10 * 127) + 0
A MSB of 10, and an LSB of 4 will output a value of 1274 via (10 * 127) + 4

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 31 Mar 2014 08:29
by Softcore
Traxus wrote:15 months later: :roll: 127 * 127 = 16383. Now I get it.

Code: Select all

//-----x = a 0 to 1 value from a fader etc...
//-----d = a 1 to 16 value of the midi channel you wish to transmit on

decl src = range(x, 0, 127);
decl msb = floor(src);
decl lsb = range((src - msb), 0, 127);
decl msg = 224 + (d - 1);
midiout(0, {msg,lsb,msb});

LSB/MSB... makes so much sense now. MSB are the big steps, LSB are the sub steps between each big step.

Remembering that 127 * 127 = 16383,

A MSB of 10, and an LSB of 0 will output a value of 1270 via (10 * 127) + 0
A MSB of 10, and an LSB of 4 will output a value of 1274 via (10 * 127) + 4
Great info!!!

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 31 Mar 2014 11:50
by wul
Have a look in the scaleykeypads demo template it's scripted in there

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 31 Mar 2014 12:17
by Macciza
Remembering that 127 * 127 = 16383,
Um, except 127 * 127 = 16129 . . .???
16384 is however 2^14 ! And because of the whole zero offset/off-by-one stuff you get 16383 . . .
It is also 128 * 128 - The 14 is the important bit here in terms of it be a 14 bit value . . .
Cheers
MM

Re: Send pitch bend with lemur scripting (MIDI programming ?

Posted: 31 Mar 2014 18:20
by Traxus
Macciza wrote:
Remembering that 127 * 127 = 16383,
Um, except 127 * 127 = 16129 . . .???
16384 is however 2^14 ! And because of the whole zero offset/off-by-one stuff you get 16383 . . .
It is also 128 * 128 - The 14 is the important bit here in terms of it be a 14 bit value . . .
Cheers
MM

Lol yes, 128^2 = 16484, is what i meant (probably why it didn't click for me the first time around)