Forum
    • Categories
    • Register
    • Login

    Creating a MIDI copier/transposer in HISE

    Scheduled Pinned Locked Moved Scripting
    9 Posts 2 Posters 43 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.
    • F
      flameshower
      last edited by

      Given a MIDI track, I want to write a function such that it takes the note at a given position, creates its 2nd harmonic note at the same position, and places the note at the same position in the track.

      How would I go about doing this?

      Here's a basic transposer I have written so far. It doesn't copy the notes, it just moves them up an octave.

      for(note in track)
      {
          if(note.isNoteOn()) {
      	    
          
      	    Console.print(note.dump());
          	Console.print("Before: " + note.getNoteNumber()); 
         
          	note.setNoteNumber(note.getNoteNumber() + 12);	    				      
      
      
      	    Console.print("After: " + note.getNoteNumber()); 
      	     
          }  
      }
      
      David HealeyD 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @flameshower
        last edited by

        @flameshower said in Creating a MIDI copier/transposer in HISE:

        and places the note at the same position in the track.

        This part you can't do. It's not possible to write to a DAW's MIDI tracks from a plugin.

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

        F 1 Reply Last reply Reply Quote 1
        • F
          flameshower @David Healey
          last edited by

          @David-Healey Got it. Would it be possible to play the note in the track, plus the 2nd harmonic at the same time?

          Like, it would play the note's 2nd harmonic at the same time without writing it to the track?

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

            @flameshower Yes you can do that. Synth.playNote() is probably what you need there.

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

            F 1 Reply Last reply Reply Quote 1
            • F
              flameshower @David Healey
              last edited by

              @David-Healey Ok, so

                  if(note.isNoteOn()) {
              	    
                  
              	    Console.print(note.dump());
                  	Console.print("Before: " + note.getNoteNumber()); 
                 
                  	//note.setNoteNumber(note.getNoteNumber() + 12);
                  	Synth.playNote(note.getNoteNumber(), note.getVelocity());
                  	Synth.playNote(note.getNoteNumber()+12, note.getVelocity());
                  	Synth.playNote(note.getNoteNumber()-12, note.getVelocity());	    				      
              
              
              	    Console.print("After: " + note.getNoteNumber()); 
              	     
                  } 
              

              The issue now is whenever I click Compile, it always hangs on the first note, never going to the second. I have to turn off the synth module to get it to stop. What's the fix? I'm a beginner here, so I'm in need of help with this lol

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

                @flameshower said in Creating a MIDI copier/transposer in HISE:

                if(note.isNoteOn()) {
                

                What is note?

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

                F 1 Reply Last reply Reply Quote 0
                • F
                  flameshower @David Healey
                  last edited by

                  @David-Healey

                  Content.makeFrontInterface(600, 600);
                  const lookAndFeel = Engine.createGlobalScriptLookAndFeel();
                  const var MIDIPlayer1 = Synth.getMidiPlayer("MIDI Player1");
                  const var track = MIDIPlayer1.getEventList(); // The notes to be transposed up 1 octave
                  
                  
                  /* Grab note, create second harmonic of note
                  playing at same time of it
                  O(n) complexity
                  */
                  Console.print("-------------------------------------");
                  for(note in track)
                  {
                      if(note.isNoteOn()) {
                  	    
                      
                  	    Console.print(note.dump());
                      	Console.print("Before: " + note.getNoteNumber()); 
                     
                      	//note.setNoteNumber(note.getNoteNumber() + 12);
                      	Synth.playNote(note.getNoteNumber(), note.getVelocity());
                      	Synth.playNote(note.getNoteNumber()+12, note.getVelocity());
                      	Synth.playNote(note.getNoteNumber()-12, note.getVelocity());	    				      
                  
                  
                  	    Console.print("After: " + note.getNoteNumber()); 
                  	     
                      }  
                  }
                  // 3. Flush the processed list back to the MIDI file
                  MIDIPlayer1.flushMessageList(track);
                  
                  David HealeyD 1 Reply Last reply Reply Quote 0
                  • David HealeyD
                    David Healey @flameshower
                    last edited by David Healey

                    @flameshower Oh you're using the MIDI player, when you said track I assumed you were referring to a DAW track. In that case what you originally wanted might be possible.

                    You've put it all in on init though, so that will only run when the plugin is first loaded (or you click compile).

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

                    F 1 Reply Last reply Reply Quote 0
                    • F
                      flameshower @David Healey
                      last edited by flameshower

                      @David-Healey

                      As an aside: I plan on exporting this to Ableton, so eventually the plugin will load MIDIs from DAW tracks.

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

                      40

                      Online

                      2.1k

                      Users

                      13.0k

                      Topics

                      112.8k

                      Posts