Re: [Alsa-user] Route input to output with minimal latency

2017-07-21 Thread Clemens Ladisch
Robert Bielik wrote:
> using the alsaloop tool and setting a latency, what does that mean
> exactly ? If I set latency to 48 frames (like below), does it mean 48
> frames per capture/playback, i.e. so total latency is 96 frames ? Or
> is 48 the total latency ?

As far as I can see, the buffer size is set to half that, so it should
be the total software latency.


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-21 Thread Robert Bielik
Dear Clemens,

Thank you so much for the alsaloop tip, I just ran it with:

> chrt -rr 70 alsaloop -f S32_LE -C plughw:0 -P plug:ladspa -l 48

And it works perfectly, exactly what I needed! 

Regards
/Robert

> -Original Message-
> From: Robert Bielik [mailto:robert.bie...@dirac.com]
> Sent: den 21 juli 2017 11:32
> To: Clemens Ladisch <clem...@ladisch.de>; alsa-user@lists.sourceforge.net
> Subject: Re: [Alsa-user] Route input to output with minimal latency
> 
> Hello Clemens,
> 
> > Otherwise, you have to do the capture and playback in software.  See
> > the alsaloop tool.  What latency you can reach depends on how much
> > other applications and drivers interfere with the scheduling; on the
> > Pi, typical culprits are WiFi, ethernet, or USB.
> > Also see <https://wiki.linuxaudio.org/wiki/raspberrypi>.
> 
> Thanks, I'll look at alsaloop tool. For further info, I am using an I2S sound 
> card
> (http://www.audioinjector.net/rpi-hat) , and have setup an ALSA device to
> route playback.pcm through a LADSPA plugin, so all DSP will reside in the
> plugin, thus I only need to route ALSA input to output in the application 
> 
> Regards
> /Robert
> --
> Check out the vibrant tech community on one of the world's most engaging
> tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Alsa-user mailing list
> Alsa-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/alsa-user
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-21 Thread Robert Bielik
Hello Clemens,

> Otherwise, you have to do the capture and playback in software.  See the
> alsaloop tool.  What latency you can reach depends on how much other
> applications and drivers interfere with the scheduling; on the Pi, typical
> culprits are WiFi, ethernet, or USB.
> Also see .

Thanks, I'll look at alsaloop tool. For further info, I am using an I2S sound 
card (http://www.audioinjector.net/rpi-hat) , and have setup an ALSA device to 
route playback.pcm through a LADSPA plugin, so all DSP will reside in the 
plugin, thus I only need to route ALSA input to output in the application 

Regards
/Robert
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-21 Thread Clemens Ladisch
Gordon Scott wrote:
> On 21/07/17 08:18, Clemens Ladisch wrote:
>> What latency you can reach depends on how much other
>> applications and drivers interfere with the scheduling; on the Pi,
>> typical culprits are WiFi, ethernet, or USB.
>
> Indeed. Any serial and/or packetising interface will certainly add _some_ 
> latency.

No; I meant that these drivers will interfere with sound when they are
doing something else.


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-21 Thread Gordon Scott



On 21/07/17 08:18, Clemens Ladisch wrote:

What latency you can reach depends on how much other
applications and drivers interfere with the scheduling; on the Pi,
typical culprits are WiFi, ethernet, or USB.


Indeed. Any serial and/or packetising interface will certainly add 
_some_ latency. The drivers need to collect and slice up the data, put 
it into those packets and send them over the medium. Then the packets 
must be unpacked and the data stream put back together.


IIRC (and I may not, so feel free to correct), USB 2.0 and lower will 
cause 1ms of latency all on it's own, just because of the time-slotting 
used in the serial stream.


Ethernet can certainly be quicker, but can also be less predictable if 
there's any other traffic or you use large packets.


I imagine, but do not know, that WiFi may be slower. A quick 'ping' test 
here shown two to fifteen ms, but that may be caused by other factors. 
That compares with a fairly steady 0.5ms over Ethernet.


If you are looking for total latency of 1ms, that it likely 
over-optimistic, though it might _just_ be feasible. Just one lost 
packet, though, will likely cause an audible click (those are fun on a 
multi-killowatt PA).


Safer would be, say, 5ms.

3ms is probably OK as it gives enough time to re-send a missing packet 
_and_ work towards recovering the lost time.



--
Gordon Scott
http://www.gscott.co.uk
www.nautavulgaris.org syn www.thepopularsailor.org
https://www.facebook.com/ThePopularSailor

*Rescue Tally Ho*
http://www.yachttallyho.com
https://www.facebook.com/yachtTallyHo

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-21 Thread Clemens Ladisch
Robert Bielik wrote:
> I want to route input to output with minimal possible latency, this
> will run on a Raspberry Pi, and the latency should be < 1 ms.

This is easiest to do if the hardware already has this routing built in.

Otherwise, you have to do the capture and playback in software.  See the
alsaloop tool.  What latency you can reach depends on how much other
applications and drivers interfere with the scheduling; on the Pi,
typical culprits are WiFi, ethernet, or USB.
Also see .

> if the ALSA capture and playback device is mmapped to the same buffer
> area, this should be dealt with automatically. Is this possible ?

Only in theory.  The current API has no mechanism for that.


Regards,
Clemens

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-20 Thread Ralf Mardorf
On Thu, 20 Jul 2017 18:14:07 +, Robert Bielik wrote:
>No, software input to output, i.e. capture data and send to playback
>directly with minimal latency.
>
>But I realize that mmapping is not possible since capture and playback
>device will have separate buffers, so I still have to copy from
>capture to playback buffers.

I don't know to what "zero-copy" in the description refers to, but even
if there should be the need to copy, I doubt that latency caused by
such copies would be an issue, at least not for a negligible amount of
IOs. I guess if latency isn't caused by audio hardware, than usually by
the signal processing of applications, but unlikely by the routing.
However, I never programmed using ALSA and my audio recording
experiences are from decades ago. I was just surprised about the
< 1 ms, since I would expect software side this shouldn't be an issue.

I might be mistaken.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] Route input to output with minimal latency

2017-07-20 Thread Ralf Mardorf
On Thu, 20 Jul 2017 17:47:17 +, Robert Bielik wrote:
>I want to route input to output with minimal possible latency, this
>will run on a Raspberry Pi, and the latency should be < 1 ms.
>
>I was thinking... if the ALSA capture and playback device is mmapped
>to the same buffer area, this should be dealt with automatically. Is
>this possible ?

http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html

I wonder if you are mistaking apples for oranges. Do you want to
connect the audio device's hardware outputs with the audio device's
hardware inputs with cables or do you want to connect software outputs
with software inputs?

-- 
Vote for apulse!
echo $(w3m https://aur.archlinux.org/packages/apulse |grep 'Votes:')
Votes: 86 Updated: Thu Jul 20 20:07:37 CEST 2017

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user