midiMessageRecieved values for modulators

Home Forums General Programming midiMessageRecieved values for modulators

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #623
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77

    hi,
    i’m new to LUA and it looks very easy understanding for me..all my knowledge based on existing panels and LUA codes inside them.

    my question is the values for modulators in section

    [code:hzbj6xdy]getByte(X)[/code:hzbj6xdy]

    for example
    there is a code I took from one of the panels..I guess it was Virtus TI panel

    [code:hzbj6xdy]
    function assignValues(midiMessage)
    — console ("assignValues")
    lastSavedProgram = midiMessage:getLuaData()
    programData = midiMessage:getLuaData():getRange(09,514)
    programNumber = midiMessage:getLuaData():getRange(08,1)
    PatchDataLoaded = midiMessage:getLuaData()
    — console ("RAW DATA: ")
    — console (PatchDataLoaded:toHexString(1))

    panel:getModulatorByName("FILTER Filter Link"):setModulatorValue(0, false, false, true)
    panel:getModulatorByName("Portamento"):setModulatorValue(programData:getByte(5), false, false, true)[/code:hzbj6xdy]

    Two things I would like to understand
    what are these values used for Program Data and Progam Number? are they specific for each device? I’m doing panel for Nord Lead 3 and I wish all knobs, sliders settings to be the same as on device and the panel.
    and if I want to assign value on startup of the panel for each modulator with that code
    [code:hzbj6xdy]panel:getModulatorByName("Filter Freq1"):setModulatorValue(programData:getByte([b]VALUE[/b]), false, false, true)[/code:hzbj6xdy]
    – VALUE – where I can find that byte?

    I used MIDI monitor from CtrlR
    for instance for OSC2 Coarse modulator from the Nord Lead 3 values are shown below
    [quote:hzbj6xdy]-|.0 (on LCD) Turned to left (6 hours to 12 hours) (values 0 to 11)
    [Controller] Ch:[ 1] No:[ 95] Val:[ 0] RAW:[176 095 000]
    0-9 (on LCD) (values 12 to 127)
    [Controller] Ch:[ 1] No:[ 95] Val:[ 12] RAW:[176 095 012]
    to
    [Controller] Ch:[ 1] No:[ 95] Val:[ 127] RAW:[176 095 127][/quote:hzbj6xdy]
    Could RAW information give that VALUE for getByte function?

    Thanks a lot in advance. Please help

    p.s. LUA – should I somehow enable it on startup? what is the code line for enabling LUA code within panel?

    #4419
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    You are mixing two things, program data and controller data. Program data is what you get from the device if you request a program dump, a big blob of memory that describes the device state, it’s usualy a big SysEx message, this is what’s happening on the Virus TI panel.

    You need to read the manual for the device, and find the section for Program Dumps or Bulk Dumps or something similar, and see how the data is structured there.

    #4420
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "atom":1bb7xnkh wrote:
    You are mixing two things, program data and controller data. Program data is what you get from the device if you request a program dump, a big blob of memory that describes the device state, it’s usualy a big SysEx message, this is what’s happening on the Virus TI panel.

    You need to read the manual for the device, and find the section for Program Dumps or Bulk Dumps or something similar, and see how the data is structured there.[/quote:1bb7xnkh]

    thanks Atom
    I read the manual and founf the following – Patch (Program) Dump Request. And it is devided into 2 sections:

    [quote:1bb7xnkh][b:1bb7xnkh]1. Patch Dump Request from Slot (Message Type $30)[/b:1bb7xnkh]
    And it says that when the patch request message below is recieved by Nord Lead 3, it will reply by sending a Patch Dump of Message Type $20 (from Slot). Nord Lead 3 Slots are assigned to MIDI Channel. So Nord Lead 3 has four MIDI channels on output. Total number of slot is 4

    Byte (Hex) – Description
    $F0 – System Exclusive
    $33 – Manufacture ID (Clavia)
    <Device ID> $00-$7F – selected Device ID for the specific instrument, 1 -127, All (what is that mean??)
    $09 – Model ID for Nord Lead 3
    $30 – Message Type specifies dump request source. $30 – from Slot
    $00-$04 – Message Specification specifies the requested Slot: $00-$03 = Slot A-D. $04 – Active Slot.
    $00 – Spare. Always set to $00
    $F7 – End of System Exclusive
    [b:1bb7xnkh]
    PROGRAM DUMP TO/FROM SLOT (MESSAGE TYPE $20)[/b:1bb7xnkh]
    Byte (Hex) – Description
    $F0 – System Exclusive
    $33 -Manufacturer ID (Clavia)
    <Device ID> $00-$7F – selected Device ID for the specific instrument, 1-127, All
    $09 -Model ID for Nord Lead 3
    $20 -Message Type specifies dump source. $20 = from Slot
    $00 to $04 -Specifies the source Slot: $00-$03 = Slot A-D. $04 = Active Slot.
    $00 -Spare. Always set to $00
    <Program Name> – Program Name. Max 16 characters long. Zero terminated if less than 16 char- acters.
    $00 (x 16) – 16 spare Bytes for future expansion. Always set to $00.
    <Version MSB> – Most significant 7 bits of version number.
    <Version LSB> – Least significant 7 bits of version number.
    <Patch Data 1> – See page 156. (There is a big table which shows controls like OSC, Lfo and etc – Link to PDF [url:1bb7xnkh]https://dl.dropbox.com/u/4202790/docs/Clavia_NordLead3_Manual_v1.2.pdf[/url:1bb7xnkh])
    <Patch Data 2>
    <Patch Data 3>
    :
    <Patch Data 210>
    $F7 – End Of System Exclusive

    [b:1bb7xnkh]2. Patch Dump Request from Memory Location (Message Type $31)[/b:1bb7xnkh]
    And it says that when the patch request message below is recieved by Nord Lead 3, it will reply by sending a Patch Dump of Message Type $21 (from Memory Location)

    Byte (Hex) – Description
    $F0 – System Exclusive
    $33 – Manufacturer ID (Clavia)
    <Device ID> – $00-$7F selected Device ID for the specific instrument, 1-127, All
    $09 – Model ID for Nord Lead 3
    $31 – Message Type specifies dump request source. $31= from memory location
    $00-$07 – Message Specification specifies the requested Bank (1-8)
    $00-$7F – Message Specification specifies the requested memory location (1-128)
    $F7 – End Of System Exclusive

    [b:1bb7xnkh]PROGRAM DUMP TO/FROM MEMORY LOCATION (MESSAGE TYPE $21)[/b:1bb7xnkh]
    Byte (Hex) – Description
    $F0 – System Exclusive
    $33 – Manufacturer ID (Clavia)
    <Device ID> – $00-$7F -selected Device ID for the specific instrument, 1-127, All
    $09 – Model ID for Nord Lead 3
    $21 – Message Type specifies dump source. $21= from memory location
    $00-$07 – Specifies the source Bank 0-8
    $00 to $7F – Message Specification specifies the source memory location 1-128
    <Program Name> – Program Name. Max 16 characters long. Zero terminated if less than 16 char- acters.
    $00 (x 16) – 16 spare Bytes for future expansion. Always set to $00.
    <Version MSB> – Most significant 7 bits of version number.
    <Version LSB> – Least significant 7 bits of version number.
    <Patch Data 1> – See page 156. (There is a big table which shows controls like OSC, Lfo and etc – Link to PDF [url:1bb7xnkh]https://dl.dropbox.com/u/4202790/docs/Clavia_NordLead3_Manual_v1.2.pdf[/url:1bb7xnkh])
    <Patch Data 2>
    <Patch Data 3>
    :
    <Patch Data 210>
    $F7 – End Of System Exclusive

    and in the end

    [b:1bb7xnkh]ALL CONTROLLERS REQUEST (MESSAGE TYPE $40)[/b:1bb7xnkh]

    This message instructs Nord Lead 3 to send all current MIDI Controller values for a specified Slot.
    This message can also be transmitted from the Nord Lead 3 by using the ‘Send MIDI Controllers’ function described on page 121.
    Byte (Hex) – Description
    $F0 – System Exclusive
    $33 – Manufacturer ID (Clavia)
    <Device ID> – $00-$7F selected Device ID for the specific instrument, 1-127, All
    $09 – Model ID for Nord Lead 3
    $40 – Message Type specifies All Controllers Request.
    $00-$04 – Specifies the requested Slot: $00-$03 = Slot A-D. $04 = Active Slot.
    $F7 – End Of System Exclusive
    [b:1bb7xnkh]
    PROGRAM FORMAT[/b:1bb7xnkh]
    In the Program Dump Messages, the Data Bytes contain the actual Program settings.
    • The patch data is viewed as a bit stream where the different parameters only use as many bits as necessary for their actual format. All parameters are oriented with the most significant bit first. An 8-bit checksum is calculated over the entire data block and stored as the last 8 bits of the file. The checksum is calculated by adding all data Bytes together. Since a MIDI SysEx data Byte can only contain 7 bits, the bit stream is 8 to 7 bit converted to fit the MIDI format.
    • A complete Patch (Program) Dump, including SysEx header and data, is transmitted in 261 Bytes. See page 156. (There is a big table which shows controls like OSC, Lfo and etc – Link to PDF [url:1bb7xnkh]https://dl.dropbox.com/u/4202790/docs/Clavia_NordLead3_Manual_v1.2.pdf[/url:1bb7xnkh])
    [/quote:1bb7xnkh]
    Please could you help define what actual values need to be used in midiMessageRecieved LUA script?

    Many thanks in advance
    Ilnaz

    #4421
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77

    after I finished the post and then tried to figure out again script according to Message Type $40 it works now without configuring each controller and knob.

    I created Update button and set the ‘Update’ script on it

    [code:1xfzwott]UpdatePatch = function(modulator, newValue)
    slot= panel:getModulatorByName("Slot Number")

    if program ~= nil and bank ~= nil and slot~= nil then
    m = CtrlrMidiMessage({0xF0, 0x33, 0, 0x09, 0x40, slot:getModulatorValue(), 0xF7})
    panel:sendMidiMessageNow(m)
    end

    end[/code:1xfzwott]

    midiMessageRecieved looks like
    [code:1xfzwott]–
    — Called when a panel receives a midi message (does not need to match any modulator mask)
    — @midiMessage http://ctrlr.org/api/class_ctrlr_midi_message.html

    midiMessageReceived = function(midiMessage)

    s = midiMessage:getMidiMessageType()
    if s == 7 then
    program_number = panel:getModulatorByName("Patch")
    if program_number ~= nil then
    xx = midiMessage:getValue()
    if xx ~= nil then
    program_number:setModulatorValue(xx+1,false,false,true)
    end
    end
    end

    s = midiMessage:getSize()
    if s == 524 then
    if dump_send ~= nil then
    if dump_send == 1 then
    — console("received program data")
    PatchDataLoaded = midiMessage:getLuaData()
    assignValues(midiMessage)
    dump_send = 0
    end
    end
    end
    end
    function assignValues(midiMessage)
    — console ("assignValues")
    lastSavedProgram = midiMessage:getLuaData()
    programData = midiMessage:getLuaData():getRange(09,514)
    programNumber = midiMessage:getLuaData():getRange(08,1)
    PatchDataLoaded = midiMessage:getLuaData()
    — console ("RAW DATA: ")
    — console (PatchDataLoaded:toHexString(1))

    — panel:getModulatorByName("FilterFreq1"):setModulatorValue(programData:getByte(74), false, false, true)

    symbols = {"|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|"," ","!","","#","$","%","&","’","(",")","*","+","4","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","b","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"}
    a = symbols[programData:getByte(240)]
    b = symbols[programData:getByte(241)]
    c = symbols[programData:getByte(242)]
    d = symbols[programData:getByte(243)]
    e = symbols[programData:getByte(244)]
    f = symbols[programData:getByte(245)]
    g = symbols[programData:getByte(246)]
    h = symbols[programData:getByte(247)]
    i = symbols[programData:getByte(248)]
    j = symbols[programData:getByte(249)]

    patch = programNumber:getByte(0)

    if patch ~= nil and bank_Select ~= nil and program_Select ~= nil then
    text1 = string.format("%s%s%s%s%s%s%s%s%s%s", a, b, c, d, e, f, g, h, i, j)
    patchName = panel:getModulatorByName("Patch")
    if patchName ~= nil then
    c = patchName:getComponent()
    c:setPropertyString ("Patch Name", text1)
    end
    pos = 1
    text = string.format("%s", "Patch Loaded")
    text2 = string.format("%s", text1)
    end
    redraw = panel:getPanelEditor():getCanvas()
    redraw:repaint()
    end
    [/code:1xfzwott]

    and also set prgram change know to use that script. and it works
    when I change program (patch) on panel every knob and slider lights changing to patch values. thats awesome

    The only thing I cannot realize is how to change Slot value. Is there any code how to change the MIDI channel?

    #4422
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77

    strange thing it works only specific time…dunno why..if only I re-open panel. all start works again. seems there is some caution which has limit on specific value

    #4423
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "atom":2md8iofx wrote:
    You are mixing two things, program data and controller data. Program data is what you get from the device if you request a program dump, a big blob of memory that describes the device state, it’s usualy a big SysEx message, this is what’s happening on the Virus TI panel.

    You need to read the manual for the device, and find the section for Program Dumps or Bulk Dumps or something similar, and see how the data is structured there.[/quote:2md8iofx]

    mate, could you please clarify what values should I use for that ranges?
    [code:2md8iofx]
    programData = midiMessage:getLuaData():getRange(Value01,Value02)
    programNumber = midiMessage:getLuaData():getRange(Value03,Value04)[/code:2md8iofx]

    As I’ve already posted text from manual says
    [quote:2md8iofx]PROGRAM FORMAT
    In the Program Dump Messages, the Data Bytes contain the actual Program settings.
    • The patch data is viewed as a bit stream where the different parameters only use as many bits as necessary for their actual format. All parameters are oriented with the most significant bit first. An 8-bit checksum is calculated over the entire data block and stored as the last 8 bits of the file. The checksum is calculated by adding all data Bytes together. Since a MIDI SysEx data Byte can only contain 7 bits, the bit stream is 8 to 7 bit converted to fit the MIDI format.
    • A complete Patch (Program) Dump, including SysEx header and data, is transmitted in 261 Bytes. See page 156. (There is a big table which shows controls like OSC, Lfo and etc – Link to PDF https://dl.dropbox.com/u/4202790/docs/C … l_v1.2.pdf) [/quote:2md8iofx]

    So as far as I understand I should add SysEx size 261 into code like this. am i right?
    [code:2md8iofx] s = midiMessage:getSize()
    if s == 261 then
    if dump_send ~= nil then
    if dump_send == 1 then
    — console("received program data")
    PatchDataLoaded = midiMessage:getLuaData()
    assignValues(midiMessage)
    dump_send = 0
    end
    end
    end[/code:2md8iofx]

    Now for values Program Data and Patch Data – I dunnot what values show be used there.
    pleas help!
    Ilnaz

    #4424
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    [quote:jgcnlrwj]mate, could you please clarify what values should I use for that ranges?[/quote:jgcnlrwj]

    Program data are the bytes that correspond to controllers values. So from the dump you receive from the synth, you have to count past the end of the header (value01) to the end of the controller data (value02). You have to look for it in the manual of the synth.

    programNumber is a byte from the Virus dump that corresponds to the program number of the bank in which the patch is stored. It’s possible that in the Clavia dump this data is not stored.

    As Atom said, you have to look in the manual which byte corresponds to each controller and later assign each byte to each modulator.

    #4425
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "dasfaker":2lk0n8z3 wrote:
    [quote:2lk0n8z3]mate, could you please clarify what values should I use for that ranges?[/quote:2lk0n8z3]

    Program data are the bytes that correspond to controllers values. So from the dump you receive from the synth, you have to count past the end of the header (value01) to the end of the controller data (value02). You have to look for it in the manual of the synth.

    programNumber is a byte from the Virus dump that corresponds to the program number of the bank in which the patch is stored. It’s possible that in the Clavia dump this data is not stored.

    As Atom said, you have to look in the manual which byte corresponds to each controller and later assign each byte to each modulator.[/quote:2lk0n8z3]

    Sorry, manual doesn’t say that info. Or I can’t read it properly.
    The only thing I get is that
    – a complete Patch (Program) Dump, including SysEx header and data, is transmitted in 261 Bytes
    – I guess that Patch Data could be from 1 to 210 according to "PROGRAM DUMP TO/FROM MEMORY LOCATION (MESSAGE TYPE $21)" where are the fields numbered as Patch Data 1…Patch Data 210
    – the maximum size of each parameter in Bits is 8 from the table
    – An 8-bit checksum is calculated over the entire data block and stored as the last 8 bits of the file.

    In that case as I understood
    value01 is equal 1
    value02 is equal 210

    as for
    values03 it probably goes then as 211
    value04 = 261

    I opened patch as SysEx and it has content like 10 rows with 2 columns. Each row column has 8 bits in HEX format. Totaly 261 cells

    I might be wrong..

    This is NL3 manual which has Sysex info section as well

    https://dl.dropbox.com/u/4202790/docs/C … l_v1.2.pdf

    #4426
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    The link give me an error and I can’t open the pdf.

    Anyway, I did the Virus panel withou sysex documentation. There is a way to know which byte corresponds to which parameter.

    Open an init patch in the synth and make a dump to midiox. Then change one parameter on the synth and make another dump to midiox. You can then compare the dumps and you will find that one byte is different (and maybe the checksum too, but this will be close to the end of then dump so you can forget it). Now you know the position in the dump of the parameter you changed. Go to the init patch and change another parameter…. Do this with all the parameters of a patch and you will have the position of each parameter in the dump.

    #4427
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    You are trying to fetch a byte range from a SysEx message, in case of $21 in the manual the table at page 149 states, that the program data starts at byte 41 (16 bytes for name, 16 spare bytes, 2 bytes that make the version and the message header). So the program data is at byte 41 to the end -1 (-1 cause sysex ends with F7 always and it’s not part of the data).

    [code:73duk4gu]
    programName = midiMessage:getLuaData():getRange(7,16)
    programData = midiMessage:getLuaData():getRange(41, 261-41-1)
    [/code:73duk4gu]

    AND have a look at page 155
    [quote:73duk4gu]
    The patch data is viewed as a bit stream where the different parameters only use as many bits as necessary for their actual format. All parameters are oriented with the most significant bit first. An 8-bit
    checksum is calculated over the entire data block and stored as the last 8 bits of the file. The checksum
    is calculated by adding all data Bytes together.

    [b:73duk4gu]Since a MIDI SysEx data Byte can only contain 7 bits,
    the bit stream is 8 to 7 bit converted to fit the MIDI format[/b:73duk4gu]
    [/quote:73duk4gu]

    that means that these bytes are converted to fit the 7bit format that MIDI takes, now i’m not sure what does that mean in this case, but all bytes that are longer then 7 bits will be encoded in some way.

    #4428
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "atom":9iiwtkj6 wrote:
    You are trying to fetch a byte range from a SysEx message, in case of $21 in the manual the table at page 149 states, that the program data starts at byte 41 (16 bytes for name, 16 spare bytes, 2 bytes that make the version and the message header). So the program data is at byte 41 to the end -1 (-1 cause sysex ends with F7 always and it’s not part of the data).

    [code:9iiwtkj6]
    programName = midiMessage:getLuaData():getRange(7,16)
    programData = midiMessage:getLuaData():getRange(41, 261-41-1)
    [/code:9iiwtkj6]

    AND have a look at page 155
    [quote:9iiwtkj6]
    The patch data is viewed as a bit stream where the different parameters only use as many bits as necessary for their actual format. All parameters are oriented with the most significant bit first. An 8-bit
    checksum is calculated over the entire data block and stored as the last 8 bits of the file. The checksum
    is calculated by adding all data Bytes together.

    [b:9iiwtkj6]Since a MIDI SysEx data Byte can only contain 7 bits,
    the bit stream is 8 to 7 bit converted to fit the MIDI format[/b:9iiwtkj6]
    [/quote:9iiwtkj6]

    that means that these bytes are converted to fit the 7bit format that MIDI takes, now i’m not sure what does that mean in this case, but all bytes that are longer then 7 bits will be encoded in some way.[/quote:9iiwtkj6]

    Really appreciate your help mate
    will try now to change the code

    #4429
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "atom":44n5s2n4 wrote:
    that the program data starts at byte 41 (16 bytes for name, 16 spare bytes, 2 bytes that make the version and the message header). So the program data is at byte 41 to the end -1 (-1 cause sysex ends with F7 always and it’s not part of the data).[/quote:44n5s2n4]
    Atom, didn;t noticed the calculation first time. how you get to number 41? (16+16+16+2) =50? where are my calculations goes wrong? <img loading=” title=”Smile” />
    #4430
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "Cramp":35vxwyz2 wrote:
    "atom":35vxwyz2 wrote:
    that the program data starts at byte 41 (16 bytes for name, 16 spare bytes, 2 bytes that make the version and the message header). So the program data is at byte 41 to the end -1 (-1 cause sysex ends with F7 always and it’s not part of the data).[/quote:35vxwyz2]
    Atom, didn;t noticed the calculation first time. how you get to number 41? (16+16+16+2) =50? where are my calculations goes wrong? <img loading=” title=”Smile” />[/quote:35vxwyz2]
    I’m sorry. Got it =)
    #4431
    Cramp
    Participant
    • Topics: 11
    • Replies: 66
    • Total: 77
    "dasfaker":2k60293w wrote:
    The link give me an error and I can’t open the pdf.

    Anyway, I did the Virus panel withou sysex documentation. There is a way to know which byte corresponds to which parameter.

    Open an init patch in the synth and make a dump to midiox. Then change one parameter on the synth and make another dump to midiox. You can then compare the dumps and you will find that one byte is different (and maybe the checksum too, but this will be close to the end of then dump so you can forget it). Now you know the position in the dump of the parameter you changed. Go to the init patch and change another parameter…. Do this with all the parameters of a patch and you will have the position of each parameter in the dump.[/quote:2k60293w]

    thanks for that advise. Now I faced to that Bytes issue =)

Viewing 14 posts - 1 through 14 (of 14 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 55 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr