setOnGridChange()
-
Has anyone experience with the
setOnGridChange()
function call?
I tinkered around with it, and it seems to be interesting for building DAW synced sequenceres, like in the following example. You need to open it in HISE plugin inside a DAW.// Run in HISE Plugin inside a DAW Content.makeFrontInterface(600, 600); const var TH = Engine.createTransportHandler(); TH.setSyncMode(TH.PreferExternal); TH.setEnableGrid(true, 8); var testArray = ["first",34,56,78,123,35,87,64]; // output sequence to console, if DAW is playing TH.setOnGridChange(SyncNotification, gridChange); inline function gridChange(x,y,z) { local index = x % 8; Console.print(testArray[index]); }
The function
gridChange
needs three parameters, otherweise HISE will complain about the parameter amount.
The first parameter seems to receive the playhead position of the DAW in dependence to the grid you have to set viasetEnableGrid()
But what are the two other parameters for? Any ideas? -
onGridChange(int gridIndex_, uint16 timestamp, bool firstGridInPlayback_)
timestamp
is the sample position of the grid event in the current buffer so you could pass this onto any message you create to assure sample-accuracy.firstGridInPlayback
is true when the grid callback is the first that happened after the playback was started. The MIDI player eg. uses this information to resync the playhead and you could do something similar. Be aware that this currently does not respect loop points or seeking inside the DAW, so you have to stop and start the DAW playback for resyncing. -
@Christoph-Hart Great! Thanks for the explanation!