Creating a MIDI copier/transposer in HISE
-
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()); } } -
@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.
-
@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?
-
@flameshower Yes you can do that.
Synth.playNote()is probably what you need there. -
@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
-
-
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); -
@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 initthough, so that will only run when the plugin is first loaded (or you click compile). -
As an aside: I plan on exporting this to Ableton, so eventually the plugin will load MIDIs from DAW tracks.