HISE Logo Forum
    • Categories
    • Register
    • Login

    How to use KeySwitch to trigger sampling?

    Scheduled Pinned Locked Moved General Questions
    31 Posts 5 Posters 512 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.
    • dannytaurusD
      dannytaurus @d.healey
      last edited by

      @d-healey said in How to use KeySwitch to trigger sampling?:

      @CatABC said in How to use KeySwitch to trigger sampling?:

      the sample of the second articulation does not start playing from the beginning

      @CatABC said in How to use KeySwitch to trigger sampling?:

      @d-healey Yes, I want each articulation to start from 0

      lol make up your mind.

      @d-healey You may have misunderstood. I think these are 2 separate things. The first is what happens when the OP tried your method, which is not what they're after. The second is the result he's actually trying to get.

      Meat Beats: https://meatbeats.com
      Klippr Video: https://klippr.video

      1 Reply Last reply Reply Quote 0
      • dannytaurusD
        dannytaurus
        last edited by dannytaurus

        Your requirements aren't very clear.

        I understand you want the original sample to play when the note is played, then when the key switch is activated you want the second sample to play from the beginning.

        But what do you want to happen when the key switch is released?

        Do you want the original sample to [1] no longer play (meaning the second sample cuts it off) (I just read in your original post you want "continue to play the sound of the original key position"), [2] the original sample continues to play form wherever it would be without the key switch interaction, or [3] the original sample plays again from the start?

        Meat Beats: https://meatbeats.com
        Klippr Video: https://klippr.video

        CatABCC 1 Reply Last reply Reply Quote 1
        • CatABCC
          CatABC @dannytaurus
          last edited by

          @dannytaurus Thanks for paying attention to my question. I am still working on it. I will break down my logic:

          1. I mapped KeySwitch to C0-B0, default key position (such as C0 Sustain)
          2. Write a note C3 in the MIDI track
          3. Start playing C3 of Sustain
          4. The C3 note continues, and I write a KeySwitch on D0 (D0 is Tremolo)
          5. The sample of Sustain fades out, and the sample of Tremolo enters
          6. All MIDI ends, and the KeySwitch stays at Tremolo of D0. When there is no new KeySwitch trigger, the notes written afterwards are all "Tremolo"

          //I am a new student at HISE._
          //Windows11 & MacOS Ventura 13.6.7_

          ulrikU 1 Reply Last reply Reply Quote 0
          • ulrikU
            ulrik @CatABC
            last edited by

            @CatABC if I understand you right, you want to fade between several sound sources.

            This snippet will show you one way to do it, however keeping several sound sources activated will produce 3 voices when pressing just 1 key (one is sounding, the other 2 has a gain of -100dB)
            I don't know if it will give you any problem doing that, I suppose it depends on how demanding you project is on the cpu?

            HiseSnippet 2419.3oc6a01aSjjDdljLrXytHX0dZWcepk08AmEiW+Rdc41EGRbfHHIdwA3PHDamYZa2Ji6dtYZmPNDRmteY7o6y2Og6mv9OfqptmwdlDmPHh2OGgbltppqt5ppt5mZhoUnzkEEICsryuygALK6u1o8gBUuU6Q4BqMVyx9pN2kcXzAbkaORGpGKx5VGFPihXdV11SeaTL6byXo+4Ot4sn9TgKaDIKqGJ4tr6w6yUin1pwc499qCpaGd+TROWiMbkhUk9xAfIMsSEq.p6dztrsnnXS4XcGZTOK6ezY9Z0cmyaQuZ0le4EboKvVtCsSmp08latEVZ4p0WlN2RKvpLuk8EZ5wUxv1JpBLd6Ytkz6v18jGHLKvC4Q7c8Y3fpVsgU1PdcouGtEQpVq1i660JwWEYYY6zZjmaZim66b1j6wGRejG7JZFjQyHsCzdprl2zYLupoMuJoLuwXR1oLoYLlzUcZ6FxCTi3f1ykb1PnXgcnPbJsoXj0x9UNqJAADpx8o6wVODFLbBEWnRkRjZUpL6M5LP3p3RAQJ1RpXaKJNa9WjOW9WlmbTVc5LVd3xDJ88YgikMlZDdZSrnXP+cYgkH6S8GvFJHr8y5ScNYeZ5PtqYWmRPoXCAWsc.SbRIBVwtJ3oGrwZTEECDwz.4BXgJNZB1qw1GNFXBK4bViEsmRF.YzqJ6GHEnFryqzb+l3f18n6x7s3Pn4xooT054oOccX5AGv8T8FR3U+qF8X7t8Rct6wMTrmCi2xY8UVqI4VM24QMatEoNo81OXq0vOu+pMaSN0eFDwEcIPQARacUAX60A1vs4+iTGj+0F8G3q39bAPzdJFDOnZWt8zVo1xesJ9niYCttujp.suCGDE24+owv3Dc.M98FuIGv+72ZDGb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Go9dG.nUMhtPM4iSk5uTZe3CwZzm5FJeV72BUr96E0T.eqP++kobNahiIUsze6ZRGv5CfNelqaVUcrIV67Nw5m2IN24chyedm3Bm2It34chK8lmH1SvJCTx9lyePuQsZp+pIYaaZKReTz5+ATu7FKB
            

            Hise Develop branch
            MacOs 15.3.1, Xcode 16.2
            http://musikboden.se

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

              @ulrik said in How to use KeySwitch to trigger sampling?:

              if I understand you right, you want to fade between several sound sources.

              Link Preview Image
              Make the Gain knob smooth the gain?

              hey guys, i want to make the value of this knob smoothly gain from -100 to 0 (-100, -99, -98...-2,-1,0) instead of going directly from -100 to 0, how should ...

              favicon

              Forum (forum.hise.audio)

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

              1 Reply Last reply Reply Quote 0
              • CatABCC
                CatABC @ulrik
                last edited by

                @ulrik Thanks for the help. I implemented this function using a timer loop, but I think the CPU pressure will be very high.😂

                //I am a new student at HISE._
                //Windows11 & MacOS Ventura 13.6.7_

                ulrikU 1 Reply Last reply Reply Quote 0
                • ulrikU
                  ulrik @CatABC
                  last edited by ulrik

                  @CatABC I fiddled some more, this is a better solution, using eventData envelopes, it's easier to set the smoothing in the fades

                  And I don't think it will consume much cpu, it's only the extra voices

                  HiseSnippet 2368.3oc6a0uaajaDeW6r4hT9n45kC28mDF8Oj6YnSe4OTSSshskuXj3OpkSRKBRSo2kRhvqHWrjxItAAsnuH8UIOB8QnOB4MncH4tRbkj84X3fbNUBAQZGx4CNyvY9MRI6Ey8IBAO1wM+AmDQbbukWqSXxtq2ESYNasgi6238XxIhWSk9cQswADAphyZmDgEBRfiq6r+jZit4tli90GVcMbHl4SFRxw4YbpO4IzdT4Pp603wzvvMAAd.sm0tq0XKeNacdHuOXTy5UxIB6eDtCYGrZay347Hrnqi6u0awJU8qErbPkJKVeIe7Rj5swsaWtZPs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I2hzid.j4KxPcDNpLQNxPcCnjIyVz268FRV65dMT9jM4w8r12MFPrhMQ35bFKBdNi91lZc09+rZSl5qhpEAN4A6J7AGiJ4z99vd8g535ujlx1LNjbEaxOBGG.AO+LYqm4vQkufCGc8ewMbzUfZRtyXYi4RswVzdQgjzonz13u1KAPTJ0rW81ly3Qc4LZl.89D.UUmNjL4OS7.A3ufACryv2mDRvBqqi+lFOAf7gi2V+sKcg7Ek+nmkchwqu2yXtH8.de16kjD19FuAC.mIx8sdiOX7EL343LwSUqPtbKE1wr0wFheNSUuLc9s.xboEGuT5yN6+2zm8rqLAsGP+hFsz24AsopfzgRzmmX4979pe8kswvEFEHUXjNC7jjuEd0.Etynf9adtTJJ2VDVf9g+K7JYwxpmcSVrb5her.ipLEXz.h2cR.it6TfQSAF8IAXTko.it5BLpxTfQSAFMEXzWt.ipd0EXDTO47ALJkTlcMAfQeX0I.LBvwLEXzTfQeB.FUcJvnqt.ip94BXDr4o.ilBLZJvnOVfQeonidX+X9q7M+T4pht2PSA7sL8+0Ix4ss5YT4Q9swU+JxPK6W46mUTiwXkKJiUunLV6hx3hWTFW5hx3xWTFW4mmQEhpG1Wx6Yt+AHK2qo9eKCttFPk5qhN+O.G6L2qA
                  

                  Hise Develop branch
                  MacOs 15.3.1, Xcode 16.2
                  http://musikboden.se

                  CatABCC 2 Replies Last reply Reply Quote 0
                  • CatABCC
                    CatABC @ulrik
                    last edited by

                    @ulrik Ah~~~, the result of this solution is pleasantly surprised. The Xfade of this solution is smoother than I thought. I combined the code of my first snippet, and this is exactly what I want to achieve. If I have a chance, I will treat you to a seafood feast!🍻

                    //I am a new student at HISE._
                    //Windows11 & MacOS Ventura 13.6.7_

                    1 Reply Last reply Reply Quote 1
                    • CatABCC
                      CatABC @ulrik
                      last edited by

                      @ulrik I found a bug during testing. For example, if the last KS is on E2 after the note is played, the next note head will have the sound of E2.

                      5fe77ca5-9904-4284-9b3a-a4ef82d51f61-QQ_1752175196021.png

                      //I am a new student at HISE._
                      //Windows11 & MacOS Ventura 13.6.7_

                      ulrikU 1 Reply Last reply Reply Quote 0
                      • ulrikU
                        ulrik @CatABC
                        last edited by

                        @CatABC I guess that's how the eventData Envelopes work, if you trigger a key switch the fade will not be applied until you play next key
                        It seems to work flawlessly when playing legato but as soon as you release a playing key, and the fade has not worked its way through, it will continue the fade as soon as you start playing a key again.
                        It would be nice if the smoothing time will elapse even if no playing key is pressed

                        Hise Develop branch
                        MacOs 15.3.1, Xcode 16.2
                        http://musikboden.se

                        ChazroxC CatABCC 2 Replies Last reply Reply Quote 0
                        • ChazroxC
                          Chazrox @ulrik
                          last edited by Chazrox

                          @CatABC @ulrik I played with the snippet. If you're not against scriptFX I think this is still a smooth way to avoid complex scripting and all you need to do is fading volume from one sample to another. I also suggested adding a ramp node with some smoothing in between the gain cables to give it the x-fade vibes.

                          ac8abb72-58ab-4050-b9cd-a84af1d32083-image.png https://forum.hise.audio/post/106218

                          change the xFader node to Switch.
                          Benefits, you can add more sources easily. Pictured are fileplayers but you can easily put a oscillator there if you need.

                          CatABCC dannytaurusD 2 Replies Last reply Reply Quote 0
                          • CatABCC
                            CatABC @Chazrox
                            last edited by

                            @Chazrox I'm not against scriptFX, but I don't know how to get started. It's a bit difficult for me. If possible, can you give me a small example?

                            //I am a new student at HISE._
                            //Windows11 & MacOS Ventura 13.6.7_

                            1 Reply Last reply Reply Quote 0
                            • dannytaurusD
                              dannytaurus @Chazrox
                              last edited by

                              @Chazrox Can this fade between sources 1 and 3? Or do the fades only work in the order of 1 fade into 2 and then 2 fade into 3?

                              Meat Beats: https://meatbeats.com
                              Klippr Video: https://klippr.video

                              ChazroxC 1 Reply Last reply Reply Quote 0
                              • ChazroxC
                                Chazrox @dannytaurus
                                last edited by Chazrox

                                @dannytaurus This set up (above) actually works in succession (didnt think about that case) but you could easily take the fader out and just smooth/ramp a gain knob for each sound source. It would be a 3-Channel Mixer with a smoothing node in between gain changes pretty much.

                                Somthing like this...
                                Screenshot 2025-07-11 at 3.00.58 PM.png

                                This with your KS code you have going already I imagine this would work. Send 0-1 value to the 3 sounrd source knobs like a radio group. The Linear ramp node with fade the gain change. One smoothing parameter knob to control them all. If you need more individual gain control per sound source, just drop another gain node at the end of each chain.

                                I only suggest this way because I imagine its less stress dealing with fade times and eventIds. I think this would work.

                                Just suggestions from my perspective. 🙏 Bless!

                                1 Reply Last reply Reply Quote 0
                                • CatABCC
                                  CatABC @ulrik
                                  last edited by

                                  @ulrik said in How to use KeySwitch to trigger sampling?:

                                  @CatABC I guess that's how the eventData Envelopes work, if you trigger a key switch the fade will not be applied until you play next key
                                  It seems to work flawlessly when playing legato but as soon as you release a playing key, and the fade has not worked its way through, it will continue the fade as soon as you start playing a key again.
                                  It would be nice if the smoothing time will elapse even if no playing key is pressed

                                  @d-healey I set the Smooth value of the EventData Envelope of the current Articulation to 1 when triggering other KS to avoid the Xfade at the beginning, but when switching the third KS on the same note, I can't set the second EventData Envelope back to its original value, or do you have any idea to solve this problem?

                                  //I am a new student at HISE._
                                  //Windows11 & MacOS Ventura 13.6.7_

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

                                    @CatABC I'm not familiar with this scriptnode network.

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

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

                                    18

                                    Online

                                    1.8k

                                    Users

                                    12.1k

                                    Topics

                                    105.5k

                                    Posts