HISE Logo Forum
    • Categories
    • Register
    • Login

    How to get event ids for artificial events?

    Scheduled Pinned Locked Moved Scripting
    28 Posts 3 Posters 1.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.
    • B
      benosterhouse
      last edited by benosterhouse

      Hi,

      I have quick question: this might be obvious, but I'm wondering, in the onNoteOff callback, how do you get event ids for artificial events? Message.getEventId() just returns real note off event ids.

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

        You should be able to record the ID when you generate the event.

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

        1 Reply Last reply Reply Quote 0
        • B
          benosterhouse
          last edited by benosterhouse

          Do you have any suggestions for how to record the ID's polyphonically? Here is what I was thinking:

          function onNoteOn()
          {   
              Message.ignoreEvent(true);
              eventId = Message.getEventId();
              eventIds[eventId] = Synth.playNote(Message.getNoteNumber(), 64);    
              eventNoteNumber[eventId] = Message.getNoteNumber();
          }
          
          function onNoteOff()
          {
              // if sustain pedal is up then...
              for (i = 0; i < eventIds.length-1; i++) {
                  if (Message.getNoteNumber() == eventNoteNumber[i])
                      Synth.noteOffByEventId(i);
              };
          }
          

          It takes a lot of iterating, so it seems a bit inefficient. Maybe there's a simpler way that I'm not thinking of.

          1 Reply Last reply Reply Quote 0
          • B
            benosterhouse
            last edited by benosterhouse

            Ok, I'm just realizing, you could iterate backwards through event ids, checking to see if the note event id's key is still pressed, and then you wouldn't be needlessly iterating through every previous event ids.
            Yay, totally efficient cpu-wise!
            Quite a headache to look at though... I'm still wondering if might be over-thinking this though.

            function onNoteOn()
            {   
                Message.ignoreEvent(true);
                keyDown.setValue(Message.getNoteNumber(), 1);
                eventId = Message.getEventId();
                eventIds[eventId] = Synth.playNote(Message.getNoteNumber(), 64);    
                eventNoteNumber[eventId] = Message.getNoteNumber();
            }
            
            function onNoteOff()
            {
                
                keyDown.setValue(Message.getNoteNumber(), 0); // note: keyDown is a MidiList
                i = eventId;
                while (keyDown.getValue(eventNoteNumber[i]) == 1) {
                    i--;
                    Synth.noteOffByEventId(i);
                };
            }
            
            1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey
              last edited by

              Use a MIDI list for storing polyphonic data

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

              1 Reply Last reply Reply Quote 0
              • B
                benosterhouse
                last edited by benosterhouse

                Would a MidiList work for when you have the pedal down, and have multiple voices happening on the same key?

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

                  @benosterhouse A MIDI list is just an array that is dedicated to tracking 128 integer values (designed for polyphonic MIDI data).

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

                  1 Reply Last reply Reply Quote 0
                  • B
                    benosterhouse
                    last edited by benosterhouse

                    What I'm thinking is: say on a piano library you put the pedal down and played several repeated notes. When you lift the pedal, you'd want to noteoff all the repeated notes, not just the most recent one. How do you keep track of all those previous repeated notes?

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

                      @benosterhouse Why not just use Engine.allNotesOff();?

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

                      1 Reply Last reply Reply Quote 0
                      • B
                        benosterhouse
                        last edited by benosterhouse

                        When you lift the pedal, you don't want to note off notes that you're still playing.

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

                          @benosterhouse Good point, so why script it at all since this is the default behaviour?

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

                          1 Reply Last reply Reply Quote 0
                          • B
                            benosterhouse
                            last edited by

                            A couple reasons, but one of them would be so I can keep track of the play position of notes in the onTimer callback.
                            The next question would be why I'm wanting to keep track of the play position of every event.

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

                              @benosterhouse

                              The next question would be why I'm wanting to keep track of the play position of every event.

                              Go on :)

                              On a piano wouldn't a repeated note cancel out the previous note, since it's striking the same string?

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

                              1 Reply Last reply Reply Quote 0
                              • B
                                benosterhouse
                                last edited by

                                Basically, I'm seeing if I can port a library to vst using hise.
                                It has string swells in it, which are tempo synced. I see that hise doesn't really have timestretching yet, but I was realizing there's another way around it:
                                If you play the beginning of the swell, then crossfade into the middle of the swell, you can adjust the length of the swell, so it'd fit into any project tempo (the phasing isn't too bad. I have some ideas to get around that).

                                If you're fading together different parts of the swell, the tail end of it needs to be started with an artificial event.
                                If you have multiple stiched-together swells (which use artificial events), and they're happening on the same key at the same time, you need a way to note-off all the artificial events when you lift the pedal.

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

                                  @benosterhouse I get it, I'll play around with it a little tomorrow and see if I can come up with a way of managing the sustain/note off thing manually.

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

                                  1 Reply Last reply Reply Quote 0
                                  • B
                                    benosterhouse
                                    last edited by benosterhouse

                                    Ok cool!
                                    On a sampled piano, if you play a repeated note with the pedal down you want to keep the previous sample going.

                                    1 Reply Last reply Reply Quote 0
                                    • B
                                      benosterhouse
                                      last edited by

                                      Ok, that way I was trying to iterate through things before was too complicated and didn't actually work.

                                      I just added another dimension to the array so I could record more than one event id per key!
                                      Waaay simpler.

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

                                        How many events do you want to record per key? I'm still thinking that with acoustic instruments in general each repeated note will kill old notes, causing them to decay.

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

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

                                          That's not completely true. For example if you press down the sustain pedal, play a loud note on the piano, then play a soft note on the same key shortly after it, you would hear that the new note is fading down the old note which sounds really bad.

                                          That's why in the sampler options you have the "Kill second note" retrigger behaviour which allows you to have at least two notes of the same key ringing at once. This weakens that effect a little bit, but it's still noticeable.

                                          d.healeyD 1 Reply Last reply Reply Quote 1
                                          • d.healeyD
                                            d.healey @Christoph Hart
                                            last edited by

                                            @Christoph-Hart Very good point!

                                            1505a50a-4d81-4d14-9e10-b24425d75489-image.png

                                            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

                                            49

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.9k

                                            Posts