HISE Logo Forum
    • Categories
    • Register
    • Login

    Is it possible to delay midi notes / sampler playback by a few ms?

    Scheduled Pinned Locked Moved General Questions
    21 Posts 4 Posters 271 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SimonS
      Simon @Morphoice
      last edited by Simon

      Have you tried in a blank project?

      HiseSnippet 932.3oc4WEraaaDDcWKwfJk1flhffbjG5Amhf.RaEYazCw1xRoBMxVvzIs2BVSNzZgI2kc4R0JTz+wdteE4OncVRYSRGFGU0lbnUGDzLyNbe6al4wUSUReHMUpHztmsHAHzO2xagPOavLFWPFeDgdOqIrTMnrKbc3hDVZJDPnzVuv3f1oMI+yae9grHlvGJcQHuVx8gWxi45RuS2+64QQiXAvY73Jqt29i8khAxHYFhmVVNjDl+krKfiYlksgE46XoyHzuwx4Y8AXmsCCBXaucP+982a285smKKzoG6b2960aqd6r0t6DRn2YX.WKUdZlFRIz1GJCV3MS9yhhM307T94Qfwvk3g6bg6Qxn.yQz7axfY7nfoWQToDB0ZZIs0pf1df0Dd.+Z+kz2WlGvtLipDHci5vqUM3499fWCPhVARsKfz8s77U7DcYDCdtq0XAVMCYXcpJTJVKg9GVCj3BD5mFytDFoPiqSXy9NNOwF+5weaXlvWykBao3XoFNQr4i69qc6LA2Hrf8z.HhsX3b7wroqiiIgt+VW6alTXXQV2HlA.JYTDnZLrooQcaItoHK9bP8D64rnL35EhDSc19NqFa6WvGUVnTLVv0mj.KsKaWban1PVRn3ud03iXZlobszGttDPo4F3POBliCKEEuNVGAoWpkI33x6TYwdJYPVDSWuQyLNtL.xG0ptlRnHkqWTcb8lcese+7gSiCGMdZWQ3deqobs+rlw6FMfWj09Xi2kyxeg0vvPvWWB11Vi9wacv8ecnbuBnbWKOt.xUjyAxCyss+A1bv9Ef.TFR08VDk+8UUTNYkEkOwWia+YJlHMQlV6A6Aw7yjBCiT57UonLB7SmZpxU8OPxTMF5sOeDdHaLGOlNSk2tbPrLSnq0dzZkqIUGuqO0TY8Mnx19ikv+mzQu+4JEsVM39AdOUmqvnGONIBFJlCQnbXNF+JT+KjkEouxa8l7IRgLYlTv8q1AbJnU7Kt.TUwdiGnCzZ7pEkddv9mBQ.qZ27Wu+KwtPlB4IXM4h+9uytw50irJfqsYxz9+FJ7s9+oB+oxLMWbwDF1n9K3EIONK1CEV8ADIBADgajEcCi3XgsiwtPYUDja7m3mkAcM1zkAcuJ3mj8Hl4qjuwu39Vld4OK2CdtE42UuC9mFPaaWR9cvpViiQUw236W+Q8NIt05l31qah8V2De15lX+0MwcV2D28Cmn4kVGjokwEirDxjoCyuzJkNTvvN97oCxeA7JjQGI
      
      MorphoiceM 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @Morphoice
        last edited by ustk

        @Morphoice probably because your script is deferred. Are you trying this in the interface script?
        You can't reserve your interface for interface stuff and ask it to deal with midi messages at the same time

        Can't help pressing F5 in the forum...

        MorphoiceM 2 Replies Last reply Reply Quote 1
        • MorphoiceM
          Morphoice @ustk
          last edited by

          @ustk it's in the onNoteOn function not the onInit... though I don't really know the difference

          https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

          1 Reply Last reply Reply Quote 0
          • MorphoiceM
            Morphoice @Simon
            last edited by

            @Simon it does work there yes. probably the deferred thing

            https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

            1 Reply Last reply Reply Quote 0
            • MorphoiceM
              Morphoice @ustk
              last edited by

              @ustk there is a Synth.deferCallbacks(true); in my main script but even if I remove that, I get the same error

              https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

              ustkU d.healeyD 2 Replies Last reply Reply Quote 0
              • ustkU
                ustk @Morphoice
                last edited by ustk

                @Morphoice remove and reload the project, this sounds familiar to me...

                onNoteOn, onNoteOff, etc... are callbacks within the interface (or other) script, not different/independent scripts, so they all "see" what is in onInit

                Can't help pressing F5 in the forum...

                MorphoiceM 1 Reply Last reply Reply Quote 0
                • MorphoiceM
                  Morphoice @ustk
                  last edited by

                  @ustk superb! quitting hise and reloading did the trick. thank you so much

                  https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

                  ustkU 2 Replies Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Morphoice
                    last edited by

                    @Morphoice said in Is it possible to delay midi notes / sampler playback by a few ms?:

                    even if I remove that

                    You should keep it, it forces good programming habits by preventing you doing real-time stuff in your ui script. You should make a secondary script for playing your notes and connect your GUI to it.

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    MorphoiceM 1 Reply Last reply Reply Quote 1
                    • ustkU
                      ustk @Morphoice
                      last edited by

                      @Morphoice When you save a script to clipboard, it shows like this:

                       function onNoteOn()
                      {
                      	
                      }
                       function onNoteOff()
                      {
                      	
                      }
                       function onController()
                      {
                      	
                      }
                       function onTimer()
                      {
                      	
                      }
                       function onControl(number, value)
                      {
                      	
                      }
                      

                      So you see they are just functions within onInit

                      Can't help pressing F5 in the forum...

                      1 Reply Last reply Reply Quote 1
                      • ustkU
                        ustk @Morphoice
                        last edited by

                        @Morphoice Dave said it, just keep it and do your MIDI things in another script 😉

                        Can't help pressing F5 in the forum...

                        1 Reply Last reply Reply Quote 0
                        • MorphoiceM
                          Morphoice @d.healey
                          last edited by

                          @d-healey this might sound like a totally stupid noob question, but how exactly do I do that? I have only ever put stuff inside the interface script or put some functions into an include which I recon are "included" so not really out of the script

                          https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @Morphoice
                            last edited by d.healey

                            @Morphoice said in Is it possible to delay midi notes / sampler playback by a few ms?:

                            but how exactly do I do that

                            This is the simple explanation, but not necessarily the best way:

                            • Add a new MIDI processor.
                            • Take all your MIDI note generating code, your button grid, etc. and copy it to this new MIDI processor.
                            • Remove the MIDI note generating code from your UI script.
                            • Connect the buttons on your UI to the buttons on the new MIDI processor.

                            A better approach would avoid duplicating the grid and would allow the new MIDI processor to handle an arbitrary number of grid buttons on the UI so that it could be reused in other projects. But this would require more work so probably not worth the trouble at this stage of your HISE journey.

                            Another, more modular approach, would have a separate MIDI processor for each of your samplers.

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            MorphoiceM 2 Replies Last reply Reply Quote 2
                            • MorphoiceM
                              Morphoice @d.healey
                              last edited by

                              @d-healey the delay needn't be on the pads, I'm fine with it on the real midi input only
                              so I created a new MidiProcessor and put the delay code in it's onNoteOn

                              function onNoteOn()
                              {
                              	Message.delayEvent(Math.randInt(0, 30000));
                              }
                              

                              that seems to do the trick and I can reenable the deferCallbacks on the interface script! Unless I'm mistaken this was an easy fix that should work

                              https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • MorphoiceM
                                Morphoice @d.healey
                                last edited by

                                @d-healey ofc the delay value is just around 300, I'm just looking for phase variance when the oneshots appear on a strict grid they sound better that way, as not every kick/snare is exactly at the same position as all the other sounds. It's what gives the organic 80s vibe ;)

                                https://instagram.com/morphoice - 80s inspired Synthwave Music, Arcade & Gameboy homebrew!

                                1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @Morphoice
                                  last edited by

                                  @Morphoice said in Is it possible to delay midi notes / sampler playback by a few ms?:

                                  so I created a new MidiProcessor and put the delay code in it's onNoteOn

                                  That should do it.

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  ustkU 1 Reply Last reply Reply Quote 1
                                  • ustkU
                                    ustk @d.healey
                                    last edited by ustk

                                    @d-healey what you suggested with duplicating the controls to pilot the other script is what I would go with as well, but... Would there be a simpler way using instead a global broadcaster of some sort?

                                    Can't help pressing F5 in the forum...

                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @ustk
                                      last edited by

                                      @ustk said in Is it possible to delay midi notes / sampler playback by a few ms?:

                                      a global broadcaster of some sort

                                      I tried adding a broadcaster to a global variable but it didn't go well. I asked Christoph about it and he says not to do it.

                                      The way I suggested is the way all the other built-in modules of HISE work, so I think it's a good way to do it.

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

                                      ustkU 1 Reply Last reply Reply Quote 1
                                      • ustkU
                                        ustk @d.healey
                                        last edited by

                                        @d-healey said in Is it possible to delay midi notes / sampler playback by a few ms?:

                                        the way all the other built-in modules of HISE work

                                        Quite a valid point!

                                        Can't help pressing F5 in the forum...

                                        1 Reply Last reply Reply Quote 0
                                        • First post
                                          Last post

                                        24

                                        Online

                                        1.7k

                                        Users

                                        11.9k

                                        Topics

                                        103.4k

                                        Posts