Load and Save SysEx methods

Home Forums General Programming Load and Save SysEx methods

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

      hi,
      it is about a month i’m doing Nord Lead 3 panel. And yesterday I realized how to do LOAD SysEx data from the file into Nord Memory without any assignments to modulators ( i mean a long code with a list of modulators and assigned bytes to each modulator).
      The thing is that Nord Lead 3 has the following SysEx command under the Message Type #40
      This message instructs Nord Lead 3 to send all current MIDI Controller values for a specified Slot.

      [b:29767wz3]Byte (Hex) – Description[/b:29767wz3]
      $F0 – System Exclusive
      $33 – Manufacturer ID (Clavia)
      $7F – selected Device ID
      $09 – Model ID for Nord Lead 3
      [b:29767wz3]$40 – Message Type specifies All Controllers Request.[/b:29767wz3]
      $04 – Specifies the requested Slot: $04 = Active Slot.
      $F7 – End Of System Exclusive

      so it looks like [b:29767wz3]F0 33 7F 09 40 04 F7[/b:29767wz3]
      I used that SysEx message from the beginnig by just as tool to set up my modulators visiually by their positions according to selected patch (program) on device or from panel.
      I’m not sure if any devices has this message type – number 40. But who knows

      The Load SysEx script on my pabel initially was based on Virus Ti panel method assigning each byte of sysex data to modulators/knobs and etc. That didn’t work for me because of misunderstanding the SysEx data =)
      So what I did is:
      1. Created method and assigned to LOAD button on panel
      2. Put this code
      [code:29767wz3]LoadPatch = function(modulator, newValue)

      if newValue == 1 then
      f = utils.openFileWindow ("Open Patch", File(""), "*.syx", true)
      if f:existsAsFile() then
      PatchDataLoaded = f:loadFileAsData()

      lastSavedProgram = PatchDataLoaded
      programName = PatchDataLoaded:getRange(7,16)
      programData = PatchDataLoaded:getRange(41,219)
      programCategory = PatchDataLoaded:getRange(17,16)
      programFullData = PatchDataLoaded:getRange(0,261)
      programSize = PatchDataLoaded:getSize()

      if programSize == 261 then
      loaddata(PatchDataLoaded)
      panel:getModulatorByName("StatusBox"):setPropertyString ("uiLabelText", "SysEx file has been Loaded")
      else
      panel:getModulatorByName("StatusBox"):setPropertyString ("uiLabelText", "Invalid File")
      end
      end

      end [/code:29767wz3]

      The[b:29767wz3] Loaddata[/b:29767wz3] function called by this code
      [code:29767wz3]– LOAD DATA AND SET SYSEX VALUES TO MODULATORS

      — some code here for text info

      — Send SysEx information to Nord Lead 3

      if patchName ~= nil and sound_category ~= nil then
      m = CtrlrMidiMessage(programFullData)
      panel:sendMidiMessageNow(m)
      end

      — Request Update data by SysEx – Function calls method running Message code F0 33 7F 09 40 04 F7
      UpdatePatch()

      — UPDATE PANEL CANVAS
      redraw = panel:getPanelEditor():getCanvas()
      redraw:repaint()

      end[/code:29767wz3]

      Update patch function
      [code:29767wz3]UpdatePatch = function(modulator, newValue)

      — some code here

      — Send SysEx Message 40 equal to F0 33 7F 09 40 04 F7 to set up all parameters

      m = CtrlrMidiMessage(recall_data_msg40)
      panel:sendMidiMessageNow(m)

      end[/code:29767wz3]

      So that looks great indeed. I did dump of some of the patches from Nord to SysEx librarian and saved them as separate Syx files.
      So if I’m loading Syx file from panel – the code above reads SysEx file with data and sends to device with
      [code:29767wz3]
      m = CtrlrMidiMessage(programFullData)
      panel:sendMidiMessageNow(m)[/code:29767wz3]

      Data arrives to Nord, I can see it on device and then Message 40 put modulators on my panel as they should be according to loaded patch.

      Now I faced to few issues and have questions:
      1. Load SysEx on this works only with SysEx files made on Nord Lead 3 OS version 1.20. But I think it can be resolved.

      2. How to load a big SysEx file (includes 127 patches) – the whole bank. That is why I was asking about the Browser component. Clicking on sysex file and panel shows all contents. The idea is to load bank and ability to select the Patch names withing that file and to apply them to device memory.

      3. There is a[b:29767wz3] SysEx Message type #30[/b:29767wz3] which request patch/dump info from the device [b:29767wz3]F0 33 7F 09 30 04 00 F7[/b:29767wz3] which should be used when requesting Nord Lead 3 to transmit one Program Dump. When the Patch Request message below is received by Nord Lead 3, it will reply by sending a PatchDump of Message Type $20.

      The question is the code what I used to send Midi data to device by [b:29767wz3]panel:sendMidiMessageNow(m)[/b:29767wz3] – is there command like maybe[b:29767wz3] panel:recieveMidiMessageNow(m)[/b:29767wz3]?
      So the idea is – for instance I created new patch via panel and wnat to save on my hard drive.
      Theoreticaly I want step by step
      1. Send MIDI Message #30 to request the modulators position on device (patch dump) – somehow to recieve that info as HEX string value (SysEx bytes) and assign to [b:29767wz3]PatchDataLoaded[/b:29767wz3] vairable
      2. Save the information to file on the disk using the command

      [code:29767wz3]f = utils.saveFileWindow ("Save Patch", File(patchnametext..extension_format), "*.syx", true)
      f:create()
      if f:existsAsFile() then

      lastSavedProgram = PatchDataLoaded
      programName = PatchDataLoaded:getRange(7,16)
      programData = PatchDataLoaded:getRange(41,219)
      savedata(PatchDataLoaded)
      f:replaceFileContentWithData(PatchDataLoaded)

      b = panel:getModulatorByName("StatusBox"):getComponent()
      b:setPropertyString ("uiLabelText","The patch SysEX Data has been saved.")
      end[/code:29767wz3]

      On oanel itslf I have method[b:29767wz3] DefineValuesData[/b:29767wz3] which has PatchDataLoaded variable with Init Dump value.
      [code:29767wz3]function DefineValuesData ()
      — INIT SOUND SYSEX DATA
      init_patch = {0xf0, 0x33, 0x7f, 0x09, 0x20, 0x00..... bla bla bla, 0xf7}

      — RECALL ALL MODULATORS SYSEX INFO – MESSAGE 40

      recall_data_msg40 = {0xF0, 0x33, 0x7F, 0x09, 0x40, 0x04, 0xF7}

      tt = CtrlrLuaObjectWrapper(init_patch)
      PatchDataLoaded = CtrlrLuaMemoryBlock()
      PatchDataLoaded:append(tt)
      end[/code:29767wz3]

      I think this is possible but need your help cause I do not have a big background coding with LUA. Any ideas?

      p.s. attached manual if needed for details

      Cheers, Ilnaz

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

        hi,
        seems nobody knows answer to my question?

        The question is the code what I used to send Midi data to device by[code:22ax6tb2] panel:sendMidiMessageNow(m)[/code:22ax6tb2]

        – is there command like maybe [code:22ax6tb2]panel:recieveMidiMessageNow(m)[/code:22ax6tb2]?

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

          There is now receiveMidiMessage method, there is a Panel callback that gets triggerd everytime a midi message is received (it’s one of the panel properties). You need to decide based on the message length and contents what the message is for, use it or ignore it.

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

            There is no receiveMidiMessageNow.

            But in the midiMessageReceived method you can check if a received midi message match what you need.

            #4543
            Cramp
            Participant
              • Topics: 11
              • Replies: 66
              • Total: 77
              "atom":1higrai9 wrote:
              There is now receiveMidiMessage method, there is a Panel callback that gets triggerd everytime a midi message is received (it’s one of the panel properties). You need to decide based on the message length and contents what the message is for, use it or ignore it.[/quote:1higrai9]

              Thanks Atom for pointing my noise into that..i’m blind person

              I see now … midiMessageReceived = function(midiMessage)

              in case of midiMessage – can I use for example this value

              [code:1higrai9]

              dump_request_msg30 = {0xF0, 0x33, 0x7F, 0x09, 0x30, 0x04, 0x00, 0xF7}
              — When the Patch Request message below is received by Nord Lead 3, it will reply by sending a PatchDump of Message Type $20.
              m = CtrlrMidiMessage(dump_request_msg30)
              panel:sendMidiMessageNow(m)

              [/code:1higrai9]

              and then call the function

              [code:1higrai9]midiMessageReceived = function(midiMessage)
              s = midiMessage:getMidiMessageType()
              if s==20 then
              — call the SysEx message 40 – request all sliders and knobs value on the synth and make automaticly changes on panel // recall_data_msg40 = {0xF0, 0x33, 0x7F, 0x09, 0x40, 0x04, 0xF7}
              UpdatePatch()
              end

              s = midiMessage:getSize()
              if s == 261 then
              PatchDataLoaded = midiMessage:getLuaData()
              end

              end[/code:1higrai9]

              and then using Save button I can call the code like this

              [code:1higrai9] f = utils.saveFileWindow ("Save Patch", File(patchnametext..extension_format), "*.syx", true)
              f:create()
              if f:existsAsFile() then

              lastSavedProgram = PatchDataLoaded
              f:replaceFileContentWithData(lastSavedProgram)

              end
              [/code:1higrai9]

              am I right or I need do to this process by another way?

              Also can I use code to check MidiMessageType this way?

              [code:1higrai9]m = CtrlrMidiMessage(dump_request_msg30)
              panel:MidiMessageRecieved(m)[/code:1higrai9]

              #4544
              Cramp
              Participant
                • Topics: 11
                • Replies: 66
                • Total: 77
                "dasfaker":shppbksc wrote:
                There is no receiveMidiMessageNow.

                But in the midiMessageReceived method you can check if a received midi message match what you need.[/quote:shppbksc]

                thanks mate.

                I think that should work then.

              Viewing 6 posts - 1 through 6 (of 6 total)
              • The forum ‘Programming’ is closed to new topics and replies.
              There is currently 0 users and 53 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