HISE Logo Forum
    • Categories
    • Register
    • Login

    Best practice for one shot sample playback with

    Scheduled Pinned Locked Moved General Questions
    11 Posts 5 Posters 648 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.
    • FrankbeatF
      Frankbeat
      last edited by

      I'd like to build an instrument that is going to be triggered by drum type MIDI tracks. You know – these are only sending note on messages but not the note offs.

      However, I want to add a note off signal in order make the user able to set a duration the sample gonna play for (experimental thing, bass drum / bassline hybrid).

      What would be best practice for this?

      I found a solution based on Synth.startTimer and Synth.stopTimer:

      function onNoteOn() {
      	//	If instrument receives GM Bass Drum message (Note 36), play it with a tune that was selected by the 'tuneSlider':
      	if	(Message.getNoteNumber() == 36)	{
      			Synth.playNote(tuneSlider.getValue(), Message.getVelocity());
      			Synth.startTimer(durationSlider.getValue());
      	} else {Message.ignoreEvent(true);}
      }
      

      Since the Timer repeats by default I make use of stop.Timer() in the timer callback:

       function onTimer() {
      	Synth.noteOff(tuneSlider.getValue());
      	Synth.stopTimer();
      }
      

      I have the feeling there's a better way to do it. Would you recommend a different practice?

      Using HISE from the develop branch (Feb '23)

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

        @Frankbeat I think there is a Synth.noteOffWithDelay function. You could use this immediately after your Synth.playNote call.

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

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

          @Frankbeat I'm not the midi event expert here but I'd do it this way (until someone corrects me):

          // init script
          
          reg id;
          reg delay;
          
          inline function onKnob1Control(component, value)
          {
          	delay = Engine.getSampleRate() * value / 1000;
          };
          Content.getComponent("Knob1").setControlCallback(onKnob1Control);
          
          function onNoteOn()
          {
          	id = Message.makeArtificial();
          	
          	Synth.noteOffDelayedByEventId(id,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24WV0aPSV4aPONPCK+IJhHMQltzD6SiYm.GsRK67YovcDzuYroKW1eWIQU4Pu5Q8gMYk43SzYJKcY+XYlPuD8n1J2SJKls7olRwWwcn0eScs9a0id+yUJpsZv807JjFKvnOybadOw4TNHeaw3s.85HRFWuv6xj7gRgLYpTvBJy.FS0J1jITUYrW4FZesFt0uvys8FS4TRY1787dJvBIpgVs40pV72+EYU1utCNGttlSlt+2Pgu1+OU3GKyzLwjgDfnZt8+nrXePXMfBHQHnbXgvNaXDGysaaryUVEgVi+.9LevNFam4C1YwfuUViXRfR9hf72tY3xuq0CruE1eXUC3W3A1tW7nMLt8tsgm1DxdQPfob+wP8o5b9z0HmOaMx49qQNOXMx4gqQNe9ZjyWbs4XtLZ+LsLN+nH3XTO6imcb5IH.S1x5Q+IvcsSiu
          

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

          1 Reply Last reply Reply Quote 1
          • FrankbeatF
            Frankbeat @d.healey
            last edited by

            @d-healey Cool, thanks! This seems to be exactly what I was looking for.
            It's not listed in the Docs yet, or is it?

            Using HISE from the develop branch (Feb '23)

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

              @Frankbeat https://docs.hise.audio/scripting/scripting-api/synth/index.html#noteoffdelayedbyeventid

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

              FrankbeatF 1 Reply Last reply Reply Quote 1
              • FrankbeatF
                Frankbeat @d.healey
                last edited by

                @d-healey Okay, then it is exactly what @ustk suggested. Thanks to both of you!

                Using HISE from the develop branch (Feb '23)

                gorangroovesG 1 Reply Last reply Reply Quote 0
                • gorangroovesG
                  gorangrooves @Frankbeat
                  last edited by

                  @Frankbeat Let's rewind this to the beginning, as there seems to be a fundamental misunderstanding of the MIDI drum tracks.

                  Contrary to what you wrote, MIDI drum tracks DO contain note-off and note-length data, just like any other MIDI.
                  Some DAWs (like Cubase) allow you to use a drum editor where you are primarily looking at note-on locations and velocities, but that doesn't change the fact that note-off values are also there. You can switch the views and adjust note lengths and, therefore, the note-off locations. Exported MIDI files all contain note-on and note-off data.

                  Playing or ignoring note-off values is always performed by the virtual instrument. In HISE, every sampler has settings whether to play the notes as single shots (playing the samples in their entirety irrespective of the note duration and note-off data) or to follow the note-on/note-off data fed through the MIDI input.

                  So, keeping this in mind, I suggest re-evaluating your approach as to what you want to achieve.

                  Goran Rista
                  https://gorangrooves.com

                  Handy Drums and Handy Grooves
                  https://library.gorangrooves.com

                  FrankbeatF 2 Replies Last reply Reply Quote 0
                  • FrankbeatF
                    Frankbeat @gorangrooves
                    last edited by

                    @gorangrooves I had to reinvestigate this and it seems you are right.

                    However, I remember some years ago I had an external MIDI Drum Pad instrument connected to trigger a Kontakt patch and when I hit a Pad and released my finger the samples would not decay though they had an envelope with a short release stage. IIRC a guy at Gearslutz told me this is because that type of gear doesn't send off messages. This appeared to be true at least for that one (though I don't remember what it was exactly).

                    Using HISE from the develop branch (Feb '23)

                    1 Reply Last reply Reply Quote 0
                    • FrankbeatF
                      Frankbeat @gorangrooves
                      last edited by Frankbeat

                      @gorangrooves said in Best practice for one shot sample playback with:

                      In HISE, every sampler has settings whether to play the notes as single shots (playing the samples in their entirety irrespective of the note duration and note-off data) or to follow the note-on/note-off data fed through the MIDI input.

                      Where are these settings exactly? I deleted my AHDSR envelope now and when I trigger that patch, console says:

                      ! You need at least one envelope in the gain chain
                      

                      Using HISE from the develop branch (Feb '23)

                      gorangroovesG LindonL 2 Replies Last reply Reply Quote 0
                      • gorangroovesG
                        gorangrooves @Frankbeat
                        last edited by

                        @Frankbeat said in Best practice for one shot sample playback with:

                        @gorangrooves said in Best practice for one shot sample playback with:

                        In HISE, every sampler has settings whether to play the notes as single shots (playing the samples in their entirety irrespective of the note duration and note-off data) or to follow the note-on/note-off data fed through the MIDI input.

                        Where are these settings exactly? I deleted my AHDSR envelope now and when I trigger that patch, console says:

                        ! You need at least one envelope in the gain chain
                        

                        You will find those settings under the "Sampler Settings" tab inside every sampler you add. You can set several important parameters there and you will have to experiment to fine-tune those for optimal performance.
                        You will want to set the playback to "one shot" for all those samples that you want to play fully.
                        For those you want to follow note-on/note-off, set it to "normal."

                        Even if your percussion pad would not send note-off messages, that won't matter to HISE sampler if you set the playback to One Shot. However, I don't think the guy at Gearslutz advised you properly. If that was true and your pad was not sending the note-off message, the samples would keep playing (waiting on note-off) and not just prematurely stop. The issue was not with your pad, but with the Kontakt patch, you used. The samples there were likely not set as "one shots" and would therefore play the duration until note-off was received. Your pad was, in all likelihood sending the note-off, which was cutting short the length of the samples.

                        Goran Rista
                        https://gorangrooves.com

                        Handy Drums and Handy Grooves
                        https://library.gorangrooves.com

                        1 Reply Last reply Reply Quote 1
                        • LindonL
                          Lindon @Frankbeat
                          last edited by

                          @Frankbeat said in Best practice for one shot sample playback with:

                          @gorangrooves said in Best practice for one shot sample playback with:

                          In HISE, every sampler has settings whether to play the notes as single shots (playing the samples in their entirety irrespective of the note duration and note-off data) or to follow the note-on/note-off data fed through the MIDI input.

                          Where are these settings exactly? I deleted my AHDSR envelope now and when I trigger that patch, console says:

                          ! You need at least one envelope in the gain chain
                          

                          you must have an envelope in the gain stage for every sound source, if you dont want the release to cut in then just set the release to the max.

                          HISE Development for hire.
                          www.channelrobot.com

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

                          37

                          Online

                          1.7k

                          Users

                          11.7k

                          Topics

                          101.9k

                          Posts