midiMessageReceived executed 2 times

Home Forums General Programming midiMessageReceived executed 2 times

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #69481
    goodweather
    Participant
      • Topics: 45
      • Replies: 550
      • Total: 595
      • ★★★

      Hi,
      I have a somewhat similar behaviour as described in http://ctrlr.org/forums/topic/large-sysex-dump-problem/ but when using Ctrlr standalone.
      Current version of Ctrlr I’m using is 5.3.174 (I will try with a more recent version to check if the problem is the same).

      The issue:

      • You select a bank and a program then press on a Load button. The Load_OnChange method is triggered and calls RequestProgramEditBufferDump
      • RequestProgramEditBufferDump method is rather simple: it builds a sysex message and sends it to the synth as:
        msg = string.format("F0 01 2C 06 F7")
        panel:sendMidiMessageNow(CtrlrMidiMessage(msg))
      • The midiMessageReceived method is associated to the panel property “Called when the panel received a midi message”. It checks the message size and acts accordingly
      • As you can see in the attached image showing the MidiMonitor window and the Console, each method is called once but MidiMessageReceived is reacting on the same message size 2 times WHILE in the output I got only the message once (and the message is correct btw)

      Any clue why midiMessageReceived could be triggered twice for only one message?

      @Atom
      : hope you’ll get a chance to lok at this 🙂

      I will use a temporary workaround to check some bytes for detecting double execution and to avoid launching all actions in midiMessageReceived twice.

      Thx in advance…

      Attachments:
      You must be logged in to view attached files.
      #69489
      goodweather
      Participant
        • Topics: 45
        • Replies: 550
        • Total: 595
        • ★★★

        OK… I’m quite sure it is a bug…

        Instead of using the workaround I mentioned when initiating the post (checking a few bytes), I did as daimondamps mentioned in its topic http://ctrlr.org/forums/topic/large-sysex-dump-problem/: resetting and restoring the Midi devices with PanelLoaded().

        So, just add the following code in PanelLoaded() and midiMessageReceived() will be only executed once:

        sDevices = panel:getProperty("panelMidiControllerDevice")
        panel:setPropertyString("panelMidiControllerDevice", "-- None")
        panel:setPropertyString("panelMidiControllerDevice", sDevices)

        Works fine 🙂

        #69554
        goodweather
        Participant
          • Topics: 45
          • Replies: 550
          • Total: 595
          • ★★★

          Well…
          It worked fine until I realized that I lost the bidirectional behaviour of my panel…

          The solution I found was to reset the Input devices at panel load and this is working fine (no double execution of MidiMessageReceived for one message and bidi is OK):

          -- Reset Midi INPUT devices to avoid having MidiMessageReceived method called twice
          -- If resetting Controller devices then the bidirectional behaviour is lost (most probably a bug)
          sMidiDevices = panel:getProperty("panelMidiInputDevice")
          panel:setPropertyString("panelMidiInputDevice", "-- None")
          panel:setPropertyString("panelMidiInputDevice", sMidiDevices)
          #69555
          Possemo
          Participant
            • Topics: 14
            • Replies: 638
            • Total: 652
            • ★★★

            Hi goodie, I finally checked this out and yes you are right and your simple workaround seems to work too. Thanks! Unfortunately there does not seem to be such an easy fix for the vstplugin version sending midi messages twice, which I think could get one into trouble, depending on the synth and the panel you are using…

            edit: I just read that you think resetting the input (or output) devices could fix this too. Well it’s worth a try. Will report if this fixes it. That would be great!

            • This reply was modified 7 years, 9 months ago by Possemo.
            #69557
            Possemo
            Participant
              • Topics: 14
              • Replies: 638
              • Total: 652
              • ★★★

              No, unfortunately this wont fix it. I tried this:

              local vstout =   panel:getProperty("panelMidiOutputToHost")
              panel:setProperty("panelMidiOutputToHost",0,false)
              panel:setProperty("panelMidiOutputToHost",vstout,false)

              It must be a bug in panelMidiOutputToHost because if you set a mididevice in panelMidiOutputDevice it will send messages three times. So panelMidiOutputToHost will always send messages twice X-(. Maybe one day I will find a workaround…

              #69558
              goodweather
              Participant
                • Topics: 45
                • Replies: 550
                • Total: 595
                • ★★★

                OK. When my Pro2 panel will be ready in standalone, for sure I’ll try the VST and I may face this issue…

              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 95 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