Home › Forums › General › Programming › how to send program change with LUA
- This topic has 5 replies, 4 voices, and was last updated 2 years, 11 months ago by
drno.
-
AuthorPosts
-
December 27, 2020 at 7:35 pm #121240
hi i’m newbie to LUA,
I want to send the following midi sequence:
0xB8, 0x00, 0x7F, 0xB8, 0x20, 0x00, 0xC8, 0x05which is basically a bank change and a program change
CC 0 MSB
CC 32 LSB
Patch Change Program_numberwhere the variables are:
MSB, LSB and Program_numberthe function written in Lua only sends the first 3 bytes, does anyone know why and can help me?
patchKick = function(–[[ CtrlrModulator –]] mod, –[[ number –]] value, –[[ number –]] source)
if value==0 then
m = CtrlrMidiMessage({0xB8, 0x00, 0x7F, 0xB8, 0x20, 0x00, 0xC8, 0x05}) — PATCH
panel:sendMidiMessageNow(m) — SENDS
endend
December 27, 2020 at 11:00 pm #121244Hi drno,
Welcome….learning LUA is fun!
Looking at your sysex table there is 1 thing I notice: it does not open with 0x0F and end with 0xF7
In sysex 0F declares the beginning of a sysex message and F7 declares the end of it.
Best regards,
BAUS
-
This reply was modified 2 years, 11 months ago by
BAUS. Reason: typo
Updating a 25 year old Editor
December 28, 2020 at 12:01 am #121248I think Baus means 0XF0 instead of 0x0F 🙂
The first 3 bytes are the MSB if I’m correct. So I guess you need to shoot another two CtrlrMidiMessages for the LSB and the Program Change. Like this:
msb = CtrlrMidiMessage(0xB8, 0x00, 0x7F)
lsb = CtrlrMidiMessage(0xB8, 0x20, 0x00)
pc = CtrlrMidiMessage(0xC8, 0x05)panel:sendMidiMessageNow(msb)
panel:sendMidiMessageNow(lsb)
panel:sendMidiMessageNow(pc)There are probably better ways to do this..
If you want to send them in one message in sysex format, you need what Baus says. But you need to know the right format for your synth as well. Example, for my synth (Roland SH-201) it’s: F0 41 10 00 00 16 12 01 00 00 00 MSB LSB ProgramChange 00 F7. Where MSB, LSB, ProgramChange are the values of 7F, 00, 05 of your example. But I need to know for which synth you are developing a panel to help you any further with that.
December 28, 2020 at 9:31 am #121249Hi all,
Not sure what you are intending to do.
0xB initiates a control change message, so I guess 0xB8= control change on channel 8 followed by 2 data bytes (one with a controller number and one with a value);
So the first 6 bytes of your message seem to represent 2 control change messages each of 3 bytes.0xC initiates a program change message, so I guess your seventh byte 0xC8 is a program change on channel 8 followed by one data byte 0x05 containing the program number.
These three messages are not of the sysex type (initiated by 0xF0 and ending with 0xF7).
I don’t think you need lua to send these control change and program change messages in Ctrlr, but others on this forum are more experienced about the subtlities of this types of messages in ctrlr.
December 28, 2020 at 10:01 am #121250the function written in Lua only sends the first 3 bytes, does anyone know why and can help me?
I guess because your synth is reading the first byte 0xB8 and recognizes a control change message. Your synths brain is made to think that a control change message consists of 3 bytes, the first byte containing the identification of the message with channel, the second containing the cc number, the thirth a value. So the brain of your synth is made to be not aware of the following bytes in order not to confuse the message, already complete.
December 28, 2020 at 12:24 pm #121251thank you all for the smart responses.
the device is a Yamaha DJX II keyboard.
I have solved the bank change and patch, sent three separate messages one for the MSB, one for the LSB and one for the program change.
thank you very much to all. -
This reply was modified 2 years, 11 months ago by
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.