HISE Logo Forum
    • Categories
    • Register
    • Login

    Transposing MIDI Player Based On Incoming Notes

    Scheduled Pinned Locked Moved Scripting
    2 Posts 1 Posters 94 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.
    • M
      mwplugs
      last edited by

      So i have just figured out the simple way to have a single key trigger the midi player, however i would like to devote an area of the keybed to the midi loop and have the coinciding note transpose the midi player. Ex. Range Note 0-24 Root =Note 12. Giving the ability to transpose the midi melody up or down one octave.

      This works fine with corresponding noteoff message to make it stop..i have it at 36 for testing. but want it 0-24 with 12 root and up and down transposing based on the pressed key

      function onNoteOn()
      {
      	if(Message.getNoteNumber() == 36)
          {
              var timeStamp = Message.getTimestamp();
              MIDIPlayer1.play(timeStamp);
              Message.ignoreEvent(true);
          }
      }
      

      What do i need to do to achieve this? I would also be connecting a button to enable and disable this processing and behave like a normal keybed

      M 1 Reply Last reply Reply Quote 0
      • M
        mwplugs @mwplugs
        last edited by

        @mwplugs ok i figured out a long handed way to achieve this..

        declaring the midi modules in oninit

        const var MIDIPlayer1 = Synth.getMidiPlayer("MIDI Player1"); 
        const var Transposer1 = Synth.getMidiProcessor("Transposer1");
        

        then i have to manually add the note range i want to trigger with transpose

        function onNoteOn()
        {
        	if(Message.getNoteNumber() == 36)
            {
                var timeStamp = Message.getTimestamp();
                MIDIPlayer1.play(timeStamp);
                Message.ignoreEvent(true);
                Transposer1.setAttribute(Transposer1.TransposeAmount, -1);
            }
            if(Message.getNoteNumber() == 37)
                {
                    var timeStamp = Message.getTimestamp();
                    MIDIPlayer1.play(timeStamp);
                    Message.ignoreEvent(true);
                    Transposer1.setAttribute(Transposer1.TransposeAmount, 1);
                }
        }
        

        then the noteoff messages

        {
        	if(Message.getNoteNumber() == 36)
            {
                var timeStamp = Message.getTimestamp();
                MIDIPlayer1.stop(timeStamp);
                Message.ignoreEvent(true);
            }
            if(Message.getNoteNumber() == 37)
                {
                    var timeStamp = Message.getTimestamp();
                    MIDIPlayer1.stop(timeStamp);
                    Message.ignoreEvent(true);
                }
        }
        

        i KNOW there is a much more efficient way to achieve this...however im not good with arrays and indexes. and i wouldnt be mad if someone optimized this code for 0-24 with note 12 root :) but as of now it works lol

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

        17

        Online

        1.7k

        Users

        11.8k

        Topics

        103.0k

        Posts