Midi Player?
-
@Christoph-Hart Is there a way to add multiple events to a track? I'd love to see a snip on how you would paint a timeline as well
-
@dustbro said in Midi Player?:
Is there a way to add multiple events to a track? I'
Yes, but I realise there is one puzzle piece missing.
- Create a list of
MessageHolders
which contain the MIDI messages - Set the MIDI properties for each message
- Call
flush()
to pass it to the MIDI player.
But you can't set the Type for the
MessageHolder
object (it was initially created to hold a reference to actual MIDI input so there was no need to change its type, but now we needMessageHolder.setType(MessageHolder.NoteOn);
What do you mean with timeline? Any graphic representation grabs the rectangle list from the MIDI player, then applies some transformations and displays the information in some way, so if you can show me an example I can check how to realise it.
- Create a list of
-
@Christoph-Hart I'm trying to incorporate this into a drum sampler...
So file browser to drag n drop midi into a player, and an associated midi track to arrange parts. -
Alright, a snippet how to use the MIDI API to create notes programatically is available here:
https://docs.hise.audio/tutorials/recipes/event-processing/create-midi-sequence.html
Now the other thing you want to achieve is a little bit more complex, as it would require to divide the notes into multiple "clips", which is not supported ATM (and chances are tiny that it will be added in the future since it requires a full rework of how the MIDI files are handled).
-
@Christoph-Hart said in Midi Player?:
it would require to divide the notes into multiple "clips"
I'm thumbing thru the MidiPlayer API and found:
getNoteRectangleList(var targetBounds) This converts the MIDI data in the current sequence to a list of rectangles for each note scaled to fill the rectangle supplied as argument.
The description says
The most simple application of this is to draw a piano-roll content into a Panel.
@Christoph-Hart Can you use a panel as a "clip" with this? I'm checking out the example code, but unsure how to properly populate "note". @Dominik-Mayer any insight on this?
for(note in list) { // `note` is a array with 4 numbers and can be passed // into all Graphic API functions pretty conveniently. g.fillRect(note); }
I'm also seeing
setRepaintOnPositionChange(var shouldRepaintPanel) If true, the panel will get a repaint() call whenever the playback position changes.
description:
By default this is off, but if you need your connected Panel to repaint during playback (eg. to display a ruler that indicates the position), set this to true and it repaint() will be called periodically during playback
would this Ruler be similar to the timeline ruler in the pic above?
-
Making a ruler and showing the contents of a clip is the smallest problem (in fact these are trivial to achieve with the API calls you listed above).
The problem which you won't be able to overcome is to combine multiple MIDI files into a timeline, and drag them around as entity.
I've modified the example from the docs to use a panel to display the position and content of the MIDI file which should get you started on the basics:
HiseSnippet 2049.3oc4Y8+aabaE+NaeE0JyEoaEC6GIBFvNuncQxeIN.EEwxx1wZI1VUxMMnEEAz2wSGStiTkGkc0Jx9ab+oj+C1dOxS5NYq5ooktgto3.K936Q995mGIcWkLjkmKUNtqew3gLG2ekW+wBcR6DJW3z4PG2Ow6TZtloHVRGLdHMOmE435t5yPBtquli4y6e5AzTpHjURxw4kRdH6E7LttjZ28eNOM8XZD6BdVEt2Y+NgRQaYpbDnOq50vYHM7szArynHaq3439QGEw0RUeMUyxcbW6.Yz39IxqEV9eIOmeYJCGzzoOrPVxGKSiPMFo5zNgmF0chcm63350szKrp0K7Ydmxi3SoW5MtuYBRoDU8GtqbWpWy+4pWi4odqVQ89nIAIi5kRGyTSBRcNrCwRo4LJU6QJESn6y99QrYBNu+oEScgBbyUo+Bob3QBJnpQUI6t5rl2pKl4caSxA09i4oLz7bmL.3FMEHLeHUScby8dxVAhKd7yeR6d85zIH3zu7nu4MsBBBdUPPqftAY7d8unyVeCPIXbPva1ausFDz5jyggu4g6sUbbqsMeu0SxhiCdU2fSD+4tm8WXsO3331shia1pSuGFdR2fjCCB16gOOHvA0ixrMWL+rOeffpGo.ZdmMJ6.JXAUbJmIy3v7lJnBh2e+CYh4QF8qfySoqVgXc1y3ncpDwWyFw+Tu9gJ9Pc4Lnu52TPsLeb1XucVmUjddjMpEORDp4RAgFEclTy7S4455jvDpPvRqSD.MwnrKYp5jqXoxPtdbcxPYNGkpNIkIFnS1r1OVi.ethpHYjufbjX.WvBBULHq3TPIfB1SvLZk+letgyrfblFMC+r.beOWTcBjxYlc0uTApxvKKTE+I5T0IaaUd+BiXlcDBd4ZZ1P+BUb.S2GFBocGKUe4HHNvTG.Zct+DabyB4mZfxEx.kSMPo0.iiqNycYgxeZiPtjFA4gShTUsFLVGLbTdheVA4RJRfx61nF9uG8HxEI7bx0.BMIArRB.FaxLH4EHH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JP3p2m7WZ.xHuE3ev0I0lY2XBhLVL4vAK6i8r3NN+P48RNY+wkCd89WiIVvchbux0wIwjXfi9qla3eKPe3dyxnQo3MhpdYZ7EDJl.Boy.7if6PIsd7LWAcwugciE9A.VT08S85x0gIyWeWYN5KDY94VeKduhM7NJNFvdJU107N9UK6iSrbpxmXUk640GPPLMMMJxu0Ll703obeFSvTnSs4c7NR+sE8cjFtvuiz4.p7UrKTTAzlIelEtOKieATNjWk3WkCGvf888vnbU5skvs+m2Tu+oGCF4bkoOdrZS5RqLnIwL28+lunxGlGLZs+K7dVe3q192GbX0EScmiGzs6sdWz6Cow30tORfOCAPA0weM.qFSGkpmPc175SkB4vDofGVMn2ioU7ACXpp59bMnVZ8LuL2mseOVJiVMA92uO1ulp.+DaI8EMWbewcEu9cdV0kfEij+2.Te0++DT2dIiAmRgD0ev9rm8ArzPVwCUkiM5WAwCsiafisfohHyf+N7oXxl3X2hIaNYx+irGYzPk70g1yTg4xergBX2Bya7tt2o3XRSGyIGA47fi65jAHhuNLDc2+Iv+LeY1ZIjY6kPlcVBY1cIj4wKgL6sDx7j6TFrYTqQZYlsTDHz8H6eM.2o+AIbW04evx051q
-
@Christoph-Hart Thanks for the update!
I'm doing a little tinkering but can't quite wrap my head around it's functionality.
I've added a play + stop button to your example (using the property editor), but get unexpected results. Pressing play will only play 1 random note, and when I hit stop, the midi player switches to an empty sequence.
What's the proper way to to add controls to the player?HiseSnippet 2167.3oc4Y8+aaabEmz1LqVcNHcqXX+3gfAL5EOFI+k3.TTDKK+MsDaqJ4lFzhtryjGkXB4crGOYEsh.r+M1+I6Oi8mR9OX68tijhxVwUUsaCqU1Fh26du6806y634NRgOKKSHsrW8hwoLK6eoSuwb0fVCnQbq1GXYeWmSoYJljXHs+3TZVFKvx1d4iQB1qthk9y6dx9zXJ2mMgjk0yEQ9rmEkDolPsydOMJN9HZ.6hnjJbu8ds8E7VhXwPvdV1otUJ0+0z9rynHaK4XYemCChTBYOEUwxrrWYeQv3dC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wz14PaqqXWHobnOb1TKbOVRzEvVlrpD+7L3DXruoKlkqRukfJm4Tu6IGAN4LkoG9dG5xklIPWzotbjqekSeuuQsYdgeq7+fK76G+ca+vAGVd9L2YDAs6biKN9dPYLduDGxw6oAnf13uB51DRGFqJnNcc8oBtHcffG4WMo2kojQ86yjUs8Y5PMUpot5xOdutrXFsZA7uaO7.MTIDmXKXrnw7GKts70u0wXtDbyH4mFf5K+ySPcyag0+TJTn9Fy8B2CvR8Y42jGdXS3rNnn5w0KNnVOFOPO3eAexmrAN1NexFES9eEcjP8khW5aNzIVK+AZJfey0WB9pNmhiIMJOtoC79.VI.h3K88wv8eDhOyVlMW.Y1ZAjY6EPlcV.YdzBHytKfLO9VkAaF0bnRjX1JBD5bn4eWhc4+wF6ks92.YvWttA
-
@dustbro if you use the "create generic script reference" on the MidiPlayer
and paste it in initCallbackconst var MIDIPlay = Synth.getMidiProcessor("MIDI Player1");
you can use this code to enable disable the play function
inline function onPlayControl(component, value) { MIDIPlay.setAttribute(1, value); MIDIPlay.setAttribute(0, !value); };
Attribut 1 is Play and 0 is Stop
However you have to disconnect the "Play" btn from "Property editor"
this function above make only use of the Play btn value, but you've set the buttons in a radio group so the stopbtn will set the playbtn to value = 0
-
@ulrik Thanks for that! What about changing the sequence? Could I make an array of sequences and push that to a combobox?
-
@ulrik the suggested code is two thumbs up here.
@Christoph-Hart When the STOP command is selected, the midi player removes the sequence. Any insight on that?HiseSnippet 2221.3oc4Y8+aaabEmzNLqVcNHcqXX+3sfAL5EMFIam3.DTTKKamnkXGUK2jfVTjcl7nDSHui83IqpEDf9mv9Sa+oz+C1du632jsrqfZ1FVqhCr36du68488im6KE9rrLgzxdsSmlxrr+0NClxUi5NhFws5suk8sbNhloXRhgzdSSoYYr.Ka6UeLRvdsaXo+7Ce9dzXJ2mUQxx5EhHe1yhRhTUT6u6SihiOjFvNMJoF2auaOeAuqHVLFvypNsrRo9ukNjcLEYaEGK6adPPjRHGnnJVlk8M1SDLcvHwDtg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PoJvdCmCe0xdwUKGTtkAJery.nostOuFH+N8yjWhu9yiYblDcpsul6X7etn2wX5BeGiOGFWeN6TIkCm+HalMd.KI5TnPHqNwuLCN4I6aOAixybYZBpbtK8Ce9gfQNWYFfuukNcoSBb5gYtWnKdaaeXtLwa7+f657Ce01O8lCqtXvcNdP69W5NyuMjFi2GyAb79o.JHF+MvjhP53XUA0YyqORvEoiD7H+5A8SXv4MFNjIqi84ZPvISl4Va+zcOgEyn0Sf+i6hGjiJA+DaI8EsWbew0Eu98NF3RvhQxOOZpu5uLapad6ygGQgD0uybk3Cfdo9r7avDOnHb9DTT8ysJNf1.FOP+v+B9juXa7Y67EaWr3+UzQB0WJdsu4PiXt7Goo.1MWe++q4bD9Loc4wLcf2CxJA5H9Zeezc+W.+y7kYykPlsVBY1dIj49KgLOXIjYmkPlGdsxfCi5LVIRLkh.g9GX9KEYW9GqxdUq+Md7mAJ.
it also throws this in the console
Interface:! Line 17, column 18: no iterable type
-
@ulrik any insight on how to script the midi player to playback different sequences?
Like if I drag in 5 different midi files, it creates 5 sequences.. how do you get it to play the different sequences back to back?
The end game is to be able to assemble an entire song and have playback follow the DAW timeline.
I saw @Christoph-Hart added a bunch of new midiplayer functionality the other day. Very thankful for that! -
@dustbro I've never used multitrack but I guess you should make use of
MidiPlayer.setFile();
.... for loading
and usegetPlaybackPosition()
together with a timer to check when
MidiPlayer.getPlaybackPosition()
reached -0, the file is ended and then use "
MidiPlay.setTrack(int trackIndex)
to start next sequence
-
@ulrik thanks for that! I saw in the API that it recommended not hot swapping tracks. Maybe there's a similar call for sequence?
-
Now there is :)
-
@Christoph-Hart I'm thinking that I'll need some playhead info to create a midi sequencer...
When I remove these comments, HISE wont compilevoid MainController::storePlayheadIntoDynamicObject(AudioPlayHead::CurrentPositionInfo &/*newPosition*/) { //static const Identifier bpmId("bpm"); //static const Identifier timeSigNumerator("timeSigNumerator"); //static const Identifier timeSigDenominator("timeSigDenominator"); //static const Identifier timeInSamples("timeInSamples"); //static const Identifier timeInSeconds("timeInSeconds"); //static const Identifier editOriginTime("editOriginTime"); //static const Identifier ppqPosition("ppqPosition"); //static const Identifier ppqPositionOfLastBarStart("ppqPositionOfLastBarStart"); //static const Identifier frameRate("frameRate"); //static const Identifier isPlaying("isPlaying"); //static const Identifier isRecording("isRecording"); //static const Identifier ppqLoopStart("ppqLoopStart"); //static const Identifier ppqLoopEnd("ppqLoopEnd"); //static const Identifier isLooping("isLooping"); //ScopedLock sl(getLock()); //hostInfo->setProperty(bpmId, newPosition.bpm); //hostInfo->setProperty(timeSigNumerator, newPosition.timeSigNumerator); //hostInfo->setProperty(timeSigDenominator, newPosition.timeSigDenominator); //hostInfo->setProperty(timeInSamples, newPosition.timeInSamples); //hostInfo->setProperty(timeInSeconds, newPosition.timeInSeconds); //hostInfo->setProperty(editOriginTime, newPosition.editOriginTime); //hostInfo->setProperty(ppqPosition, newPosition.ppqPosition); //hostInfo->setProperty(ppqPositionOfLastBarStart, newPosition.ppqPositionOfLastBarStart); //hostInfo->setProperty(frameRate, newPosition.frameRate); //hostInfo->setProperty(isPlaying, newPosition.isPlaying); //hostInfo->setProperty(isRecording, newPosition.isRecording); //hostInfo->setProperty(ppqLoopStart, newPosition.ppqLoopStart); //hostInfo->setProperty(ppqLoopEnd, newPosition.ppqLoopEnd); //hostInfo->setProperty(isLooping, newPosition.isLooping); }
-
Wanna dig up this old thread. Having some fun with the Midi Player but need some help regarding playback position.
I'm using a midi note to trigger a midi file. All works well, but the playback always begins at the beginning of the file. How are you guys setting playback to start relative to the DAW transport?I see we have
.setPlaybackPosition(var newPosition)
what function do we call to get a position I can pass into here?
-
Did some more tinkering.
I've enabled:const Identifier ppqPosition("ppqPosition"); const Identifier ppqPositionOfLastBarStart("ppqPositionOfLastBarStart");
Using the ppqPosition, I'm able to get a value starting at 0 and increasing by 1 per quarter note. So bar 1 starts at 0, bar 2 starts at 4, bar 3 starts at 8, etc...
The midi player playback position is expecting a value between 0 and 1, so I enabled ppqPositionOfLastBarStart, and with that I'm able to create a formula that gives me a range of 0-1 per bar.// get position on timeline var position = Engine.getPlayHead().ppqPosition; // get last bar value var last = Engine.getPlayHead().ppqPositionOfLastBarStart; // calculate position per bar var currentpostition = (position - last)/4;
Once I have that value, I'm using this code to set the position and sync playback
var timeStamp = Message.getTimestamp(); MidiPlayer.setPlaybackPosition(currentpostition); MidiPlayer.play(timeStamp);
but... the midi file it still starting playback from the beginning of the file, no matter where the playback head is in the DAW.
On another note, I started this script in HISE standalone. All worked well, but I couldn't properly use ppqPosition and ppqPositionOfLastBarStart. Since there was no transport to get info from, I'd always get a value of 0.
So I built up the plugin version so I can run the script inside a host and get real time values (which worked) but when I trigger playback of the midiplayer, I get this error pointing to the line of code I'm using for ppq Engine.getPlayHead().ppqPosition:Illegal operation in audio thread: HeapBlock allocation
-
@dustbro Very interesting tinkering ;)
I have no idea how the midiPlayer works, but maybe defering your script will remove the error... -
What if you call
Engine.getPlayhead()
in the onInit callback and then just use the updated properties in other callback? It throws this error because you're creating an object with this method in a realtime context. -
@Christoph-Hart Gonna give this a go today.