Forum
    • Categories
    • Register
    • Login

    Fade out and numPressedKeys

    Scheduled Pinned Locked Moved Bug Reports
    13 Posts 3 Posters 2.5k 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.
    • David HealeyD
      David Healey
      last edited by

      I thought events created with Syth.playNote() are artificial by default...
      This may sound a bit dumb but when there are no keys pressed the on-screen keyboard shows no keys are pressed, couldn't the same mechanism behind this also work for Synth.getNumPressedKeys()?

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - HISE tutorials
      My Patreon - More HISE tutorials

      A 1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        You mean don't increase the counter for artificial notes? This could make sense, but I'll have to think a little bit about side effects.

        1 Reply Last reply Reply Quote 1
        • David HealeyD
          David Healey
          last edited by

          Yeah I think that would make more sense since the only thing getNumPressedKeys() should care about is the number of physical keys that have been pressed. Perhaps another counter could be used for counting the number of note ons and offs.

          Free HISE Bootcamp Full Course for beginners.
          YouTube Channel - HISE tutorials
          My Patreon - More HISE tutorials

          1 Reply Last reply Reply Quote 0
          • David HealeyD
            David Healey
            last edited by

            As a temporary solution I'm using this script in the master container and checking the value of Globals.keyCount rather than using numPressedKeys().

            <?xml version="1.0" encoding="UTF-8"?>
            
            <Processor Type="ScriptProcessor" ID="KeyCounter" Bypassed="0" Script="Globals.keyCount = 0;function onNoteOn()&#10;{&#10;&#9;Globals.keyCount++;&#10;}&#10;function onNoteOff()&#10;{&#10;&#9;Globals.keyCount--;&#10;}&#10;function onController()&#10;{&#10;&#9;&#10;}&#10;function onTimer()&#10;{&#10;&#9;&#10;}&#10;function onControl(number, value)&#10;{&#10;&#9;&#10;}&#10;">
              <EditorStates BodyShown="1" Visible="1" Solo="0" contentShown="1" onInitOpen="0"
                            onNoteOnOpen="0" onNoteOffOpen="1" onControllerOpen="0" onTimerOpen="0"
                            onControlOpen="0"/>
              <ChildProcessors/>
              <Content/>
            </Processor>
            

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - HISE tutorials
            My Patreon - More HISE tutorials

            1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart
              last edited by

              I'll try to add a fix ASAP.

              1 Reply Last reply Reply Quote 1
              • David HealeyD
                David Healey
                last edited by

                Was this ever implemented? I just ran into the lying numPressedKeys function again.

                With this example script I'm using a button on the UI to generate notes. The second script just outputs the numPressedKeys in its note off callback. Obviously a button on the UI triggering notes should = zero pressed keys, but it doesn't.

                Press the button a few times to play some notes. Then recompile the Interface script, press the button a few more times. Keep repeating and each time the numPressedKeys from the second script will increase.

                HiseSnippet 1154.3oc4Ws0aaaCElxNpX1cIXcnXXOpUrGb.RCr6sMfggl3Koyq0IFwoc6sBFoirIhDoFIU1LBxuk8qYuseD6mP+GrcntDI2pl4Iz0AzwWr34BOemCOWnmJEtfRIjDqVmrLBHVer8rkb8hAKnLNY7Ph0V1SnJMHcRI0eYDUo.OhkUymXHX0ZCRx5UOtOMfxcgBRDxKDLW3YrPltf5z8dJKH3.pGbBKrjzOXuwtB9.QfHFwSS6tjHp6Yz4vgTiXMrIV2XjGSKjyzTMnHVazW3sb1BwOySk+ELE6z.vroGYFdPojOPD3YPr4axfEr.uo49shPrrmVDEZlFEts8DlG6J5EQiOIggSgFkiGVMtN30qlvypD71HEd2xdlqjEoK3Xv1MsGywKJeJdETFVoxRZrSC6ABTBtd2P5YvARbyUZz4Qc6tiyC61c6uYy1a1NIIXWOvGjCnAAmhWDpNZYLjxVBycXdNeqyc6krmwCXbvwOl6pYBtif2OVqE7dFCJEAcbEgQBNZ5cbNmFfGylsuXy1sX9Ncx26fqKR+wrLrPS7EFarcA4RRXVo3jKzvQ998WN5bzDi8PEM3rrf4n8JhWVvujQMRkdlQAzkGhmKFX1w49XXoclVWl3w4Qx4fdPtu04NYd8c1dWkgdhumG+575AECDKEwLF6HdmsaeQ6Vsursyqyx2uRdYGV.HqjsoDSdcJ1gGGdJHyuWxEDy0VMY9FqWxraZbojfB9XNSeTDjsuHcuWEo6jr.K90yGOjpolJfLZnbQfTyLvwZHbN1ZIsdnk8PPclVDkHa1sABYcB2sxpVRi9DlmQgrqBxuf0+V+NZsklOlhennmCi4Sk.dEZJeXpIhP77nRTDqFj2rbDaJH7hCn5U6TXZOlw.i3qTRZJ63JldY41m+CZezsx1GUFOWS3dK6oLs6hpwaiJvKdu7uMdyZFuo8HeevUW.1MrO3Gqam25AksRgxMsmg84RZPj.jOKYuyOfoLNOA3fzDT681FR9Ge+28qq6Pxn0dH4QtZz7mHobUjPsxAOCBYmfECpxDetBa8C+zwla4xzGHnxJY8pGe.5jUpyLpNVljtrenHlqWI8nYslFtZUSI4qXz3FefL49Syn9VPW1.bqey1oFyKvlmJQ.rajjginRGtgSsNLNzziCMwSgkpNaiC39uYvR62MCV5RxCIuAEe+hoOk8qxBl3NkIjIVAo24ypd+MIo450N7uIEtUNFmwBiBfQ7yg.zIyxfGB9z3.cN06sBJmH3hnEBNysbGhiAsjMeNHKi8Jcn80Z7ETETt8dGCA.sb2tubumgconRLNA0LVza8iEW280mamBWGSNkyGFu.n4+OeAvwhXMiOeBESTMuTDaZNCG75BHR3bHPYdzXCSmfz8cM6Sm7x8R17m3JiYOydqLl8xY9dwFgTWo3ktoszL4xeTBEzu4I+25V3exG26zijzrF0yt6tcIg3DyW55ZB22EiOUqy8pgN2uF57fZnyCqgNOpF57U0Pmu9Z0w7Xk8i0hvzRQjvzQIiXrrFwoXlbRVO4u.bjWHSJ
                

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - HISE tutorials
                My Patreon - More HISE tutorials

                1 Reply Last reply Reply Quote 0
                • David HealeyD
                  David Healey
                  last edited by

                  My old nemesis strikes again! This thing gets me every time. Still waiting for the fix :D

                  Free HISE Bootcamp Full Course for beginners.
                  YouTube Channel - HISE tutorials
                  My Patreon - More HISE tutorials

                  1 Reply Last reply Reply Quote 0
                  • A
                    andioak @David Healey
                    last edited by

                    @d-healey said in Fade out and numPressedKeys:

                    I thought events created with Syth.playNote() are artificial by default...
                    This may sound a bit dumb but when there are no keys pressed the on-screen keyboard shows no keys are pressed, couldn't the same mechanism behind this also work for Synth.getNumPressedKeys()?

                    @Christoph-Hart

                    This will be an uneducated input (hise wise :smiling_face_with_open_mouth_cold_sweat: ), but what is the point of Synth.getNumPressedKeys() if not to simply get the amount of current actually pressed keys? I mean it will of course include the stuff played back by both DAWs and midi-inputs of all kinds. But artificial is not supposed to be included in such a feature, I would think.

                    But what´s the way to get the total amount of active note-on events? (normal and artificial, everything playing) That´s a different thing. That would have to include all things playing, all event-id:s including the artificially made ones, like in a polyphony script where we want to determine the current ones in need of fading out.

                    I need that. But for each key mostly. Like saying "for each key, fade out the oldest event-ids first and let only 1-2 remain ringing". For keys, like a piano, that would be key. 😄

                    @d-healey said in Fade out and numPressedKeys:

                    With this example script I'm using a button on the UI to generate notes. The second script just outputs the numPressedKeys in its note off callback. Obviously a button on the UI triggering notes should = zero pressed keys, but it doesn't.

                    I am not sure about that. Perhaps button or a script could need the feedback of the keys being pressed to be visible on the UI. For many reasons. Musical ones, educational ones. One would definitely expect that to be included in the normal flow of notes.

                    If that button was to create a lot of notes artificially, and that was not treated as active keys, and one wanted to create a polyphony-script using Synth.getNumPressedKeys() , it could end up creating a higher polyphony than intended. For cpu:s not able to handle it and where we would need to restrict that, like with a "eco" button. I mean if we are using that to handle polyphony at all, and not the event-ids themselves.

                    Of course, the button could end up only making new MIDI-note events, that then create normal note-on events in the engine, non-artificial ones. Perhaps better. (if that´s not the same thing :( haha)

                    My opinion is that there is a list of on-off switches needed for some of these features. I don´t see where one option here is the only one needed for all projects. A JSON settings file for events and other deterministic stuff, for example. Also perhaps a solution to changes in different versions, like if someone is moving from one version to another or from one branch to another branch, should the coder be stuck with a non functioning instrument and a long fix? The whole script could be centered around very basic 0 and 1:s. 😟

                    I figure, if a flip-switch in a settings file were to incorporate these details, they would only affect the amount of events in a return, so flip the TRUE to FALSE. Nothing else. (famous last words 😬 ..)

                    Sorry if this is too noob.

                    1 Reply Last reply Reply Quote 0
                    • David HealeyD
                      David Healey
                      last edited by David Healey

                      Digging up this dinosaur. Synth.getNumPressedKeys still doesn't show the number of pressed keys. And Synth.isLegatoInterval() doesn't always return the truth.

                      If I have script A that makes the note artificial then those two functions will report incorrectly in script B.

                      Free HISE Bootcamp Full Course for beginners.
                      YouTube Channel - HISE tutorials
                      My Patreon - More HISE tutorials

                      1 Reply Last reply Reply Quote 0
                      • David HealeyD
                        David Healey
                        last edited by

                        Just giving this one a bump. Same problem as before.

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - HISE tutorials
                        My Patreon - More HISE tutorials

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

                        22

                        Online

                        2.4k

                        Users

                        13.8k

                        Topics

                        120.6k

                        Posts