HISE Logo Forum
    • Categories
    • Register
    • Login

    need some help with artificial note on events

    Scheduled Pinned Locked Moved Scripting
    7 Posts 2 Posters 79 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.
    • P
      prehm
      last edited by

      hey there,
      I've been reading as much as i could find about this topic but i can't seem to wrap my head around it.

      my general setup is this: user inputs a midi note -> my script does something -> the original note plus additional notes should be put out.

      as far as i understood, i can use Message.makeArtificial() to create a new event that can be manipulated savely. so thats what I do first. then my script for generating notes kicks in (which works fine). I have an object for each additional voice that stores some data, including the note that should be sent out and a Message holder object. all of these voice objects are stored in an array.

      i then iterate over the array, storing the original Message inside the respective Message Holder object with Message.makeArtificialOrLocal() (i need individual event IDs) and Message.store(), then changing the note to its new value from within that same object using setNoteNumber().
      Then I use Synth.addMessageFromHolder() to trigger the generated notes.

      thats all fine, however the noteOffs dont work. I tried using Synth.noteOffByEventId() and referring to the message Holders event ID with .getEventID(), but it doesnt work.
      I also tried using MessageHolder.setType to change the event to a noteOff and then Synth.addMessageFromHolder(), but nothing happens.

      Also using Synth.attachNote only seems to work for one additional Note.

      I can get all notes to stop when I use the same ID for all of them, however I need individual IDs because notes are not necessarily triggered all at once.

      any help would be very appreciated!

      cheers :)

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

        @prehm Hi,

        So whatever you're doing here, you probably want to put it in a secondary MIDI processor, not in your interface script.

        You probably don't need makeArtificial here - unless you want to change the original note.

        I think you're overcomplicating the whole thing.

        In on init create a midi list. This will be used to store the IDs of your notes.

        const eventIds = Engine.createMidiList()

        Then in on note on you can create new notes with playNote which will return an id you can store in the midi list.

        // You should probably put a check here to see if there is already an ID stored for this note number, and if it is you turn it off before storing the new event
        
        eventIds.setValue(Message.getNoteNumber(), Synth.playNote(x, y, z)); // I can't remember the exact parameters so check the docs
        

        Then in on note off you can turn off the note using its ID.

        // You should probably put a check here to make sure there is a valid ID for this note
        
        Synth.noteOffByEventId(eventIds.getValue(Message.getNoteNumber));
        

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

        P 1 Reply Last reply Reply Quote 0
        • P
          prehm @d.healey
          last edited by prehm

          @d-healey
          Hey man,
          Thanks for your quick reply!
          I‘ll try that when I get home.
          The reason I wanted to use messages instead of synth.playnote is that I want to have the option to alter the detune value (btw thanks for uploading part 2 of the microtuning video, it was me who asked for that :))
          So if I understand correctly, I would have to create a child processor for my midi stuff?
          Sorry I realize it’s a very basic question but how would I access variables from the interface script from inside that child processor and vice versa? I‘m working on a midi fx plugin so my whole interface is tied to the logic part

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

            @prehm said in need some help with artificial note on events:

            I want to have the option to alter the detune value

            Synth.addPitchFade(); - set the time to 0 and it will be instant detuning

            @prehm said in need some help with artificial note on events:

            I would have to create a child processor for my midi stuff?

            Yes, it's good to separate realtime stuff from UI stuff.

            @prehm said in need some help with artificial note on events:

            Sorry I realize it’s a very basic question but how would I access variables from the interface script from inside that child

            You don't. You build the realtime MIDI part as a standalone module that works entirely by itself without the GUI. Then you connect the controls on your GUI to it using parameter/processor ID or setAttribute - just like the built in modules.

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

            P 1 Reply Last reply Reply Quote 0
            • P
              prehm @d.healey
              last edited by

              @d-healey
              Well, I had a feeling that cramming everything into one script and ignoring the module tree was not the intended approach.. 😅 I guess I have some work to do then.
              I only got into HISE because I want to realize an idea for a midi processor, so until now I haven’t touched anything other than the script editor and some graphics functions.. I’m not quite sure how I would use set attribute in my case, the interface will have to trigger a lot of smaller functions and change variables, can I somehow expose these as attributes in my script processor?

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

                @prehm said in need some help with artificial note on events:

                the interface will have to trigger a lot of smaller functions and change variables, can I somehow expose these as attributes in my script processor?

                The two MIDI processors are completely independent, you can't access variables from one in the other - well you could use global variables, but that way is madness.

                You probably have to reevaluate the structure of your project to build it in a more modular way.

                If this is your first project I recommend starting small and if you want to cram everything into the interface script then do it - if you run into audio drop outs or other issues you can deal with that later. And when you get to project two you can try a different approach.

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

                P 1 Reply Last reply Reply Quote 0
                • P
                  prehm @d.healey
                  last edited by

                  @d-healey
                  Thanks, your advice is much appreciated.
                  So far everything works just fine and I was surprised to find that all the calculations that my script does for every note on take less than half a millisecond at a buffer size of 128, which is great. My first attempt in pure data was unusable in terms of latency..
                  I’ve started using namespaces and external script files to keep everything nice and tidy, thanks to your video on the topic.
                  There is a lot more stuff for me to learn but it’s very exciting to know that I have all the tools I need to make it real.
                  Cheers!

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

                  30

                  Online

                  1.8k

                  Users

                  12.0k

                  Topics

                  104.6k

                  Posts