Kpcha posted Apr 21 '17, 13:24:
Almost everything works fine, samplerbox is a great idea, but I've got annoying problem with latency. I use latest raspberry pi 3 and most recent iso image.
I measured actual latency of my samplerbox: it's alway something about 80 ms.
No matter if i'm using dat soundcard (alesis IO2) or not, no matter if i'm connecting my keyboard through the USB or midi input, with saw or piano samples.
I tried every hardware configuration, but there's still no improvement with the latency.
What else can i do? Is there any easy way to change samplerate and bitrate by editing micro SD card content from my PC? (only solution that comes to my mind).
Nate posted Apr 21 '17, 17:00:
Try lowering the polyphony. I heard of some other tricks somewhwere too.
Kpcha posted Apr 21 '17, 17:41:
I try to use samplerbox as a drum sampler, so i can decrease polyphony from default 80 to very low values (even less than 5), but it's my first contact with raspberry pi and i'm struggling with that problem for a few days :P
In samplerbox.py file everything is clear: i can replace values of polyphony or samplerate by simply replacing the values in some code editor (Sublime Text for example)
I wonder how to edit files saved on my micro SD card to change those values. Or maybe how to create new iso file from previously customized samplerbox.py file.
Kpcha posted Apr 22 '17, 23:50:
I learned how to edit samplerbox code from this topic:
And it seems that changes have been made successfully.
polyphony from 80 to 5
samplerate from 44100 to 48000
blocksize from 512 to 128
But after those changes latency is reduced from 80ms only to 50ms-it's still too high.
I have absolutely no idea what else i can do.
Pavel posted May 3 '17, 00:59:
Would be interesting if you could try Alex's fork (https://github.com/alexmacrae/SamplerBox) and report the results
I have achieved 8ms using it with official board DAC and RPi3: https://cloud.githubusercontent.com/assets/1401984/25642293/9894b1c6-2fa1-11e7-8ade-ca94990d214e.png
AlexM posted May 3 '17, 06:59:
@Kpcha - I'd also be interested to see if my forked version sees an improvement in audio latency for you. I've compiled an image that you can install to your SD card (like Joseph's original one) that contains a slightly older version of the repository @Pavel posted above:
Note: this link won't be around forever. I'll make the next image available elsewhere :)
I think the issue lies with
With some host APIs, the use of non-zero blocksize for a callback stream may introduce an additional layer of buffering which could introduce additional latency. PortAudio guarantees that the additional latency will be kept to the theoretical minimum however, it is strongly recommended that a non-zero blocksize value only be used when your algorithm requires a fixed number of frames per stream callback.
So in my code I removed this and used
latency='low' instead. For the RPi's onboard audio I have forced it to use
latency='high' which sees a latency of around 40-50ms (using low produced undesirable effects).
Jure Matoh posted May 3 '17, 19:47:
I currently have around 30ms of latency on my e-drums. will try Alex's version and report. if that one has mute groups and plays the whole sound I'm a happy camper!
AlexM posted May 4 '17, 04:35:
The version you'll download doesn't have the one shot feature - but if you do a
git pull, the scripts will update to their latest version.
Jure Matoh posted May 5 '17, 14:13:
ok, so I've modified the samplerbox.py to play the entire sound and connected my emu 404 usb interface, through which I run my midi input. so far, so good. latency now dropped to something like 12-13ms (still noticeable, but not as much). my question is: if I build the midi interface the same as in the plans, will this decrease latency even more or not? previously I had my presonus usb interface hooked up and latency was sky high.
need to implement this and mute groups and then I'm ready for live events!
Jure Matoh posted May 5 '17, 14:14:
... also, what's the latency if using the DAC mentioned in the plans?
Kpcha posted May 5 '17, 20:37:
Thanks for Your help Alex. I uploaded Your image: latency decreased from 50ms to 35ms. Noticeably better, but still not enough.
Jure-i tested latency with midi keyboard connected through usb and with diy midi controller based on Arduino (connected through midi input)- there's almost no difference between them.
maybe the problem is my DAC soundcard? (Alesis IO2) But i don't think so. On original image from Joseph latency was the same with or without using dac soundcard.
Jure Matoh posted May 5 '17, 21:32:
I tested the presonus interface and the e-mu interface and the difference is 20-30ms. so yes, could be the interface. also, Alesis aren't really known for producing top notch equipment... try with another interface.
Kpcha posted May 5 '17, 22:12:
Thanks Jure, maybe it's the problem. my Alesis is not the best soundcard, but is it make sense to buy instead of it a cheap DAC soundcard based on pcm2704 as it's reccomended in "make it" section on samplerbox.org site? Can those cheap cards be more suiteable for raspberry pi projects than those more complex cards?
Jure Matoh posted May 7 '17, 11:19:
could be, less overhead. will report once I test the cheapo DAC.
Jure Matoh posted May 7 '17, 14:50:
My findings regarding the latency: I have minimal latency (not noticeable) via a USB keyboard, I get noticeable latency (cca 20ms) via a USB audio interface with MIDI cable connected through the interface. My question is, will I have noticeably reduced latency if I build the MIDI IN from the plans on this website or not? Logically there should be some difference.