PedalinoMini icon indicating copy to clipboard operation
PedalinoMini copied to clipboard

Lowest latency

Open patricksebastien opened this issue 4 years ago • 7 comments

Hi, I want to build a looper using PedalinoMini (using Pure Data or SooperLooper). What is the lowest latency configuration that I can use, is it: Wifi or Bluetooth. If Wifi is it OSC (that would be great) or ipMIDI or RTP-Midi (not sure if there's a difference).

Anyone measure the latency? Is the distance playing a huge factor in the responsiveness?

patricksebastien avatar Mar 20 '20 02:03 patricksebastien

I don't know how to measure the latency in a precise way.

Using a Mac with Catalina and MIDI Network (AppleMIDI) protocol the typical latency reported by the software is between 5 and 10ms. Sometime is around 3 ms but some packet can be delayed until 50-100 ms. Of course the overload of the WiFi and the distance from AP makes a big difference.

image

I think ipMidi could save some ms but it doesn't make any difference on high WiFi traffic load. Bluetooth should be better but I don't know how to measure latency.

alf45tar avatar Mar 25 '20 07:03 alf45tar

Thanks for the feedback. Will see if I can do a simple test (not very accurate but will give me an idea of what to expect): adc microphone close to a momentary switch -> pulse in speaker recorded with the same microphone (then in audacity I can calculated the latency).

A good read for bluetooth midi latency (lots of information + a test rig): https://www.nime.org/proceedings/2019/nime2019_paper006.pdf

patricksebastien avatar Mar 25 '20 22:03 patricksebastien

I had the time to dig this subject I have good news. I'm not 100% confident on the setup I did but here we go with the information I have.

Ubuntu Studio - low latency kernel running jack at 44100hz / 64 period / 2 buffer. Reported latency: 2.9ms, real latency (round-trip) reported by jack_iodelay:

457.089 frames     10.365 ms total roundtrip latency
	extra loopback latency: 265 frames
	use 132 for the backend arguments -I and -O

In PD I created a patch that send a pulse (sample accurate dirac impulse generator) when receiving a trigger, a microphone record the physical trigger on the device and both channels are sent to Audacity. Here's the patch for reference:

patch

  1. Commercial foot pedal midi (not USB) -> midi in of soundcard -> pd midihardware

  2. Commercial USB finger pad trigger -> pd (via alsa midi) midiusb

  3. PedalinoMini Wifi OSC pedalino_OSC

22ms very stable, the circuit was around 2 meters from my computer. I wasn't able to test farther (not enough microphone cable). I will not test BLE, because OSC is fast enough for my needs and very easy to receive in PD.

Cheers

patricksebastien avatar Mar 27 '20 02:03 patricksebastien

I have sad experience with looper in Ableton Live, wich I trigger with PedalinoMINI from MIDI out -> MIDI USB adapter. The latency is tremendows - about 1sec or more. It's imposible to use. How can it be and what to do? Thanks in advance for any ideas.

MaxZak2020 avatar Jan 04 '21 20:01 MaxZak2020

Hi, sorry for digging up this issue. First of all, thanks for this nice project! I also want to use PedalinoMini with SooperLooper and lowest possible latency. I did some quick measurements on the scope to check the latency between the actual momentary button press and sending of the MIDI message. I used the Legacy MIDI output. On the screenshot from the scope you can see the button on channel 1 and the MIDI output from D4 on channel 2. image

If my measurement setup is correct there seems to be a consistent latency of around 22ms introduced to signal chain by PedalinoMini. Can someone confirm my measurements? The 22 ms seem to match patricksebastien results. However with his setup he actually should see PedalinoMini latency plus the latency of his audio output. Maybe the output latency of his PD sketch and DAC are very low. If the 22 ms of internal PedalinoMini latency are correct: Where does it come from and is there any way to decrease it? I didn't have the time to dig through the code yet.

Cheers

Edit: The observed latency seems to be directly related to the debounce interval used by the AceButton library. The default setting is 20ms. Lowering the debounce interval to 10 ms seems to work for my setup and reduces overall latency to around 10ms. This means that the internal PedalinoMini latency is probably mostly due to the software debouncing of AceButton. I'll take a look at the AceButton library, maybe there is an earlier event (before start of the debounce interval) which can trigger the MIDI message. Otherwise I'll probably add Schmitt triggers to my buttons and try to lower the debounce interval to 1ms or so.

Edit2: I gave it a try and modified the AceButton library to fire an event at the start of the debouncing interval. I modified PedalinoMini actions to support this event as "Fast Press". First tests seem to be successful. Latency is decreased to about 300µS: image

However, I probably broke some other stuff in PedalinoMini. Also false triggerings might be an issue which has to be addressed. All in all it's just an experimental hack, which seems to work ok for momentary buttons and decreases latency substantially. Repo can be found here: https://github.com/he-leon/PedalinoMini/tree/low_latency_press

he-leon avatar Oct 18 '21 18:10 he-leon

@he-leon I would like to learn more about your setup (sooperlooper + pedalino). Do you have a website where you share your work or a way to contact you?

patricksebastien avatar Oct 30 '21 20:10 patricksebastien

@he-leon I would like to learn more about your setup (sooperlooper + pedalino). Do you have a website where you share your work or a way to contact you?

I'm currently trying to find a good setup for sooperlooper in combination with PedalinoMini. The thing is I just started playing around with looping and I've never used a proper hardware looper as a reference. So I'm not really sure how a good setup should feel. In differents words: If my loops don't seam well or are out of time it's hard to tell whether it's due to a bad software/hardware setup or because I just simply suck at looping, lol. Currently I'm using SooperLooper running on Arch Linux (no special low latency kernel). As an audio interface atm I use a cheap and crappy Behringer XENYX302USB. I built a small Pedalino board from some multiplex plywood with 5 momentary switches and an ESP32 devkit v1. I'm using the MIDI legacy DIN output of PedalinoMini connected to a Roland UM-One MkII USB MIDI interface. Currently I'm trying to figure out a way to get Input and Output latency compensation in Jack/SooperLooper dialed (I think theoretically you can compensate all MIDI and audio latency here. But not 100% sure.). I'd like to create a test setup for the loop station: As mentioned I might suck at looping which means I'm not a good reference for testing. That's why I'm thinking of programming an Arduino or ESP as a simulated "looping artist" with perfect timing: It would push the switch (tie Pedalino input low) and play a click track for my audio interface simultaneously. By analyzing the recorded audio in SooperLooper I could then measure any latency and compensate it accordingly. That's somewhat similar to your approach recording the "press sound" of the button and triggering a signal with Pure Data.

However, I'm not sure when I will find the time to do this. If I find a good setup eventually I'll update this thread or post a link to a write up! If you have any questions you can also contact me via email: image

Cheers

he-leon avatar Nov 01 '21 20:11 he-leon