Is it possible to delay midi notes / sampler playback by a few ms?
-
@Morphoice said in Is it possible to delay midi notes / sampler playback by a few ms?:
even if I remove that
You should keep it, it forces good programming habits by preventing you doing real-time stuff in your ui script. You should make a secondary script for playing your notes and connect your GUI to it.
-
@Morphoice When you save a script to clipboard, it shows like this:
function onNoteOn() { } function onNoteOff() { } function onController() { } function onTimer() { } function onControl(number, value) { }
So you see they are just functions within
onInit
-
@Morphoice Dave said it, just keep it and do your MIDI things in another script
-
@d-healey this might sound like a totally stupid noob question, but how exactly do I do that? I have only ever put stuff inside the interface script or put some functions into an include which I recon are "included" so not really out of the script
-
@Morphoice said in Is it possible to delay midi notes / sampler playback by a few ms?:
but how exactly do I do that
This is the simple explanation, but not necessarily the best way:
- Add a new MIDI processor.
- Take all your MIDI note generating code, your button grid, etc. and copy it to this new MIDI processor.
- Remove the MIDI note generating code from your UI script.
- Connect the buttons on your UI to the buttons on the new MIDI processor.
A better approach would avoid duplicating the grid and would allow the new MIDI processor to handle an arbitrary number of grid buttons on the UI so that it could be reused in other projects. But this would require more work so probably not worth the trouble at this stage of your HISE journey.
Another, more modular approach, would have a separate MIDI processor for each of your samplers.
-
@d-healey the delay needn't be on the pads, I'm fine with it on the real midi input only
so I created a new MidiProcessor and put the delay code in it's onNoteOnfunction onNoteOn() { Message.delayEvent(Math.randInt(0, 30000)); }
that seems to do the trick and I can reenable the deferCallbacks on the interface script! Unless I'm mistaken this was an easy fix that should work
-
@d-healey ofc the delay value is just around 300, I'm just looking for phase variance when the oneshots appear on a strict grid they sound better that way, as not every kick/snare is exactly at the same position as all the other sounds. It's what gives the organic 80s vibe ;)
-
@Morphoice said in Is it possible to delay midi notes / sampler playback by a few ms?:
so I created a new MidiProcessor and put the delay code in it's onNoteOn
That should do it.
-
@d-healey what you suggested with duplicating the controls to pilot the other script is what I would go with as well, but... Would there be a simpler way using instead a global broadcaster of some sort?
-
@ustk said in Is it possible to delay midi notes / sampler playback by a few ms?:
a global broadcaster of some sort
I tried adding a broadcaster to a global variable but it didn't go well. I asked Christoph about it and he says not to do it.
The way I suggested is the way all the other built-in modules of HISE work, so I think it's a good way to do it.
-
@d-healey said in Is it possible to delay midi notes / sampler playback by a few ms?:
the way all the other built-in modules of HISE work
Quite a valid point!