robertsonics / WAV-Trigger-Arduino-Serial-Library

WAV Trigger Serial Control Arduino Library
27 stars 13 forks source link

Latency workaround - set track number offset? #14

Open michaelforrest opened 6 years ago

michaelforrest commented 6 years ago

I'm using a Wav Trigger with an Arduino Nano in a Eurorack synth module prototype (https://www.instagram.com/p/BgZHnupjNuN/) and I'm noticing a bit latency when triggering via serial.

I'm currently using the hardware interrupt on the Arduino to send a wTrig.trackPlayPoly() with the track selected by a pot.

An idea I had was to trigger directly via the Wav Trigger's onboard trigger inputs, BUT I want to be able to select from hundreds of samples instead of being limited to 16.

What if there was a new serial command to set the track offset on those 16 triggers? So we could say wTrig.setFirstTrack(113) and then the first on-board trigger would play track number 113, and the second 114, etc...? It would really open up some flexibility of the unit.

Would something like this be possible with only software updates?

robertsonics commented 6 years ago

By "a of bit latency", what amount are you talking about? There will always be some latency due to the fact that priority is given to playing audio and because the WAV Trigger is polyphonic, sounds have to be mixed into a play buffer which is up to 1 buffer (about 3ms) behind. No getting around that.

It's possible that the latency from triggers will be slightly less than the serial protocol, but triggers are still scanned at a lower priority than streaming audio and are debounced.

That said, trigger offsets are already implemented using Trigger Banks, which will offset the trigger numbers by 16 for each bank. Tsunami has a serial command to set the Trigger Bank, but I haven't gotten around to implementing it in the WAV Trigger. I will do this on the next firmware bump.

michaelforrest commented 6 years ago

Hi @robertsonics thanks for responding.

You can hear from the Instagram video I linked (https://www.instagram.com/p/BgZHnupjNuN/) that the snares being triggered over serial from the Arduino are very slightly behind. It must be > 20ms because you can hear it.

Trigger Banks are exactly what I'm asking for here so I'll look forward to that next firmware update!

robertsonics commented 6 years ago

Ok - I just posted WAV Trigger firmware v1.32 which adds a SET_TRIGGER_BANK serial command, and also updated the Arduino library with a setTriggerBank() function. I haven't tested it, and won't have a chance to do so for a week or so, but it's a pretty straightforward addition and I suspect will just work. Please let me know.

michaelforrest commented 6 years ago

Awesome, thanks! I'll be able to check it tomorrow.

michaelforrest commented 6 years ago

Oh, looks like I don't have the thing I need to upload new firmware just yet.