sox-users@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* Loopback latency issue
       [not found] <0713c9d8-7bdf-4b97-99b4-12e219e94d45@Spark>
@ 2020-07-10 17:40 ` Maxim Doumkine
  2020-07-10 18:08   ` Darryl Lewis
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Maxim Doumkine @ 2020-07-10 17:40 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 681 bytes --]

Hello everyone,

We are trying to build a Sox based real-time sound altering app, and we’ve got everything working on our LUbuntu 16.04 stations except for an issue w latency.

When we test it on actual hardware, we are having a latency of about 2 seconds, when we test it on our virtual machine the latency is more like 250ms.

sox -t pusleaudio default -t pulseaudio null pitch n
Whenever we add the null loopback or aloop, we experience a delay. No amount of config tinkering seems to affect this latency on an actual workstation.

We’d appreciate an advice or any input but would be equally glad to hire a consultant for a fee to get this resolved.

Thank you.

[-- Attachment #1.2: Type: text/html, Size: 1023 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-10 17:40 ` Loopback latency issue Maxim Doumkine
@ 2020-07-10 18:08   ` Darryl Lewis
  2020-07-11 16:04     ` Maxim Doumkine
  2020-07-11 13:12   ` Måns Rullgård
  2020-07-13 11:49   ` Jan Stary
  2 siblings, 1 reply; 11+ messages in thread
From: Darryl Lewis @ 2020-07-10 18:08 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1099 bytes --]


Is your virtual machine exactly the same (OS version) as your physical PC?
It might be a driver issue with different versions.


From: Maxim Doumkine <maxd@coregears.com>
Reply to: "sox-users@lists.sourceforge.net" <sox-users@lists.sourceforge.net>
Date: Saturday, 11 July 2020 at 3:58 am
To: "sox-users@lists.sourceforge.net" <sox-users@lists.sourceforge.net>
Subject: [SoX-users] Loopback latency issue

Hello everyone,

We are trying to build a Sox based real-time sound altering app, and we’ve got everything working on our LUbuntu 16.04 stations except for an issue w latency.

When we test it on actual hardware, we are having a latency of about 2 seconds, when we test it on our virtual machine the latency is more like 250ms.

sox -t pusleaudio default -t pulseaudio null pitch n
Whenever we add the null loopback or aloop, we experience a delay. No amount of config tinkering seems to affect this latency on an actual workstation.

We’d appreciate an advice or any input but would be equally glad to hire a consultant for a fee to get this resolved.

Thank you.

[-- Attachment #1.2: Type: text/html, Size: 3539 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-10 17:40 ` Loopback latency issue Maxim Doumkine
  2020-07-10 18:08   ` Darryl Lewis
@ 2020-07-11 13:12   ` Måns Rullgård
  2020-07-11 15:59     ` Maxim Doumkine
  2020-07-11 16:12     ` Steve Masters
  2020-07-13 11:49   ` Jan Stary
  2 siblings, 2 replies; 11+ messages in thread
From: Måns Rullgård @ 2020-07-11 13:12 UTC (permalink / raw)
  To: Maxim Doumkine; +Cc: sox-users

Maxim Doumkine <maxd@coregears.com> writes:

> Hello everyone,
>
> We are trying to build a Sox based real-time sound altering app, and we’ve
> got everything working on our LUbuntu 16.04 stations except for an issue w
> latency.
>
> When we test it on actual hardware, we are having a latency of about 2
> seconds, when we test it on our virtual machine the latency is more like
> 250ms.
>
> sox -t pusleaudio default -t pulseaudio null pitch n
> Whenever we add the null loopback or aloop, we experience a delay. No amount
> of config tinkering seems to affect this latency on an actual workstation.

The first thing I'd do is get rid of pulseaudio and access the ALSA
device directly.  Even then, however, there are several places where
latency is added.  You can find the ALSA buffer sizes currently uses by
examining /proc/asound/card0/pcm0p/sub0/hw_params (or whatever numbers
your system uses).  The size (in bytes) of the main buffer in SoX is set
with the --buffer option.  Some effects have additional internal buffers.

-- 
Måns Rullgård


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-11 13:12   ` Måns Rullgård
@ 2020-07-11 15:59     ` Maxim Doumkine
  2020-07-11 16:12     ` Steve Masters
  1 sibling, 0 replies; 11+ messages in thread
From: Maxim Doumkine @ 2020-07-11 15:59 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 648 bytes --]

We’ve tried that with no effect. :-/ it’s curious how it doesn’t work on actual workstation but works fine on virtualized pc.
On 11 Jul 2020, 16:12 +0300, Måns Rullgård <mans@mansr.com>, wrote:
>
> The first thing I'd do is get rid of pulseaudio and access the ALSA
> device directly. Even then, however, there are several places where
> latency is added. You can find the ALSA buffer sizes currently uses by
> examining /proc/asound/card0/pcm0p/sub0/hw_params (or whatever numbers
> your system uses). The size (in bytes) of the main buffer in SoX is set
> with the --buffer option. Some effects have additional internal buffers.

[-- Attachment #1.2: Type: text/html, Size: 1067 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-10 18:08   ` Darryl Lewis
@ 2020-07-11 16:04     ` Maxim Doumkine
  0 siblings, 0 replies; 11+ messages in thread
From: Maxim Doumkine @ 2020-07-11 16:04 UTC (permalink / raw)
  To: sox-users, sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1411 bytes --]

Yes it is an exact clone.
On 10 Jul 2020, 21:09 +0300, Darryl Lewis <darryl.lewis@unsw.edu.au>, wrote:
>
> Is your virtual machine exactly the same (OS version) as your physical PC?
> It might be a driver issue with different versions.
>
>
> From: Maxim Doumkine <maxd@coregears.com>
> Reply to: "sox-users@lists.sourceforge.net" <sox-users@lists.sourceforge.net>
> Date: Saturday, 11 July 2020 at 3:58 am
> To: "sox-users@lists.sourceforge.net" <sox-users@lists.sourceforge.net>
> Subject: [SoX-users] Loopback latency issue
>
> Hello everyone,
>
> We are trying to build a Sox based real-time sound altering app, and we’ve got everything working on our LUbuntu 16.04 stations except for an issue w latency.
>
> When we test it on actual hardware, we are having a latency of about 2 seconds, when we test it on our virtual machine the latency is more like 250ms.
>
> sox -t pusleaudio default -t pulseaudio null pitch n
> Whenever we add the null loopback or aloop, we experience a delay. No amount of config tinkering seems to affect this latency on an actual workstation.
>
> We’d appreciate an advice or any input but would be equally glad to hire a consultant for a fee to get this resolved.
>
> Thank you.
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users

[-- Attachment #1.2: Type: text/html, Size: 3008 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-11 13:12   ` Måns Rullgård
  2020-07-11 15:59     ` Maxim Doumkine
@ 2020-07-11 16:12     ` Steve Masters
  1 sibling, 0 replies; 11+ messages in thread
From: Steve Masters @ 2020-07-11 16:12 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1679 bytes --]

I wonder if it's because the virtual pc doesn't have the same amount of
processes running on it, nor physical data traffic, that your actual
workstation has to deal with. Added to that, the memory available to it -
not being used elsewhere - would improve perfoemance. Just my thinking.

On Sat, 11 Jul 2020, 14:31 Måns Rullgård, <mans@mansr.com> wrote:

> Maxim Doumkine <maxd@coregears.com> writes:
>
> > Hello everyone,
> >
> > We are trying to build a Sox based real-time sound altering app, and
> we’ve
> > got everything working on our LUbuntu 16.04 stations except for an issue
> w
> > latency.
> >
> > When we test it on actual hardware, we are having a latency of about 2
> > seconds, when we test it on our virtual machine the latency is more like
> > 250ms.
> >
> > sox -t pusleaudio default -t pulseaudio null pitch n
> > Whenever we add the null loopback or aloop, we experience a delay. No
> amount
> > of config tinkering seems to affect this latency on an actual
> workstation.
>
> The first thing I'd do is get rid of pulseaudio and access the ALSA
> device directly.  Even then, however, there are several places where
> latency is added.  You can find the ALSA buffer sizes currently uses by
> examining /proc/asound/card0/pcm0p/sub0/hw_params (or whatever numbers
> your system uses).  The size (in bytes) of the main buffer in SoX is set
> with the --buffer option.  Some effects have additional internal buffers.
>
> --
> Måns Rullgård
>
>
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users
>

[-- Attachment #1.2: Type: text/html, Size: 2316 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-10 17:40 ` Loopback latency issue Maxim Doumkine
  2020-07-10 18:08   ` Darryl Lewis
  2020-07-11 13:12   ` Måns Rullgård
@ 2020-07-13 11:49   ` Jan Stary
  2020-07-13 12:05     ` Jan Stary
                       ` (2 more replies)
  2 siblings, 3 replies; 11+ messages in thread
From: Jan Stary @ 2020-07-13 11:49 UTC (permalink / raw)
  To: sox-users

On Jul 10 20:40:09, maxd@coregears.com wrote:
> We are trying to build a Sox based real-time sound altering app, and we’ve got everything working on our LUbuntu 16.04 stations except for an issue w latency.
> 
> When we test it on actual hardware, we are having a latency of about 2 seconds, when we test it on our virtual machine the latency is more like 250ms.
> 
> sox -t pusleaudio default -t pulseaudio null pitch n

I don't use pulseaudio, but I assume that "default"
and "null" are names of pulseaudio (pseudo)devices.

How can you tell the delay when writing to a null device?
(If that means what I think it means: dropping the pulseaudio,
would it be what sox -d -n does?) I just tried

	sox -d -d pitch 1000

an OpenBSD current/amd64, and there is indeed
about a half second of delay.

> Whenever we add the null loopback or aloop, we experience a delay.

I don't understand: what does your application do
that you need to "add a null loopback"?


On Jul 11 14:12:13, mans@mansr.com wrote:
> Some effects have additional internal buffers.

It seems there is a delay even when just playing
default input to default output; even without the effects:

	sox -d -d

(So I don't think it's the effect processing
that introduces the delay.)

Jan



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-13 11:49   ` Jan Stary
@ 2020-07-13 12:05     ` Jan Stary
  2020-07-13 15:09     ` Maxim Doumkine
  2020-07-13 20:52     ` Måns Rullgård
  2 siblings, 0 replies; 11+ messages in thread
From: Jan Stary @ 2020-07-13 12:05 UTC (permalink / raw)
  To: sox-users

On Jul 13 13:49:27, hans@stare.cz wrote:
> I just tried
> 
> 	sox -d -d pitch 1000
> 
> on OpenBSD current/amd64, and there is indeed
> about a half second of delay.

For comparison,

	 aucat -c 0:0 -o - | aucat -c 0:0 -i -

has about the same delay.



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-13 11:49   ` Jan Stary
  2020-07-13 12:05     ` Jan Stary
@ 2020-07-13 15:09     ` Maxim Doumkine
  2020-07-13 20:52     ` Måns Rullgård
  2 siblings, 0 replies; 11+ messages in thread
From: Maxim Doumkine @ 2020-07-13 15:09 UTC (permalink / raw)
  To: sox-users


[-- Attachment #1.1: Type: text/plain, Size: 1782 bytes --]

	It’s definitely not the effect processing…  we are using this to modify voice in realtime, make someone sound deeper/older for instance. Without any effects there’s still a delay.
On Jul 13, 2020, 4:16 PM +0400, Jan Stary <hans@stare.cz>, wrote:
> On Jul 10 20:40:09, maxd@coregears.com wrote:
> > We are trying to build a Sox based real-time sound altering app, and we’ve got everything working on our LUbuntu 16.04 stations except for an issue w latency.
> >
> > When we test it on actual hardware, we are having a latency of about 2 seconds, when we test it on our virtual machine the latency is more like 250ms.
> >
> > sox -t pusleaudio default -t pulseaudio null pitch n
>
> I don't use pulseaudio, but I assume that "default"
> and "null" are names of pulseaudio (pseudo)devices.
>
> How can you tell the delay when writing to a null device?
> (If that means what I think it means: dropping the pulseaudio,
> would it be what sox -d -n does?) I just tried
>
> sox -d -d pitch 1000
>
> an OpenBSD current/amd64, and there is indeed
> about a half second of delay.
>
> > Whenever we add the null loopback or aloop, we experience a delay.
>
> I don't understand: what does your application do
> that you need to "add a null loopback"?
>
>
> On Jul 11 14:12:13, mans@mansr.com wrote:
> > Some effects have additional internal buffers.
>
> It seems there is a delay even when just playing
> default input to default output; even without the effects:
>
> sox -d -d
>
> (So I don't think it's the effect processing
> that introduces the delay.)
>
> Jan
>
>
>
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users

[-- Attachment #1.2: Type: text/html, Size: 2586 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-13 11:49   ` Jan Stary
  2020-07-13 12:05     ` Jan Stary
  2020-07-13 15:09     ` Maxim Doumkine
@ 2020-07-13 20:52     ` Måns Rullgård
  2020-07-13 22:20       ` Rafal Maszkowski
  2 siblings, 1 reply; 11+ messages in thread
From: Måns Rullgård @ 2020-07-13 20:52 UTC (permalink / raw)
  To: Jan Stary; +Cc: sox-users

Jan Stary <hans@stare.cz> writes:

> On Jul 11 14:12:13, mans@mansr.com wrote:
>> Some effects have additional internal buffers.
>
> It seems there is a delay even when just playing
> default input to default output; even without the effects:
>
> 	sox -d -d
>
> (So I don't think it's the effect processing that introduces the
> delay.)

No, then it's just the main buffer that is set with the --buffer option.

-- 
Måns Rullgård


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Loopback latency issue
  2020-07-13 20:52     ` Måns Rullgård
@ 2020-07-13 22:20       ` Rafal Maszkowski
  0 siblings, 0 replies; 11+ messages in thread
From: Rafal Maszkowski @ 2020-07-13 22:20 UTC (permalink / raw)
  To: sox-users

On Mon, Jul 13, 2020 at 09:52:00PM +0100, Måns Rullgård wrote:
> Jan Stary <hans@stare.cz> writes:
> > On Jul 11 14:12:13, mans@mansr.com wrote:
> >> Some effects have additional internal buffers.
> > It seems there is a delay even when just playing
> > default input to default output; even without the effects:
> > 	sox -d -d
> > (So I don't think it's the effect processing that introduces the
> > delay.)
> No, then it's just the main buffer that is set with the --buffer option.

There are some buffers in the kernel and large default buffers in
pulseaudio. I have used only small part of the advice in
https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting
and that decreased the delay from some 1/2 s to few tens of ms if I can
judge by ear. There is more to read there though.

    Modify PulseAudio's configuration file (2/4)

    /etc/pulse/daemon.conf

    default-fragments = 3
    default-fragment-size-msec = 5

    Restart the PulseAudio daemon (3/4)


R.
-- 
„Walczy on z całym zapamiętaniem przeciwko intelektowi” - z akt personalnych prof. A. Baeumlera


_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-07-13 22:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0713c9d8-7bdf-4b97-99b4-12e219e94d45@Spark>
2020-07-10 17:40 ` Loopback latency issue Maxim Doumkine
2020-07-10 18:08   ` Darryl Lewis
2020-07-11 16:04     ` Maxim Doumkine
2020-07-11 13:12   ` Måns Rullgård
2020-07-11 15:59     ` Maxim Doumkine
2020-07-11 16:12     ` Steve Masters
2020-07-13 11:49   ` Jan Stary
2020-07-13 12:05     ` Jan Stary
2020-07-13 15:09     ` Maxim Doumkine
2020-07-13 20:52     ` Måns Rullgård
2020-07-13 22:20       ` Rafal Maszkowski

sox-users@lists.sourceforge.net unofficial mirror

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/sox-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 sox-users sox-users/ https://public-inbox.org/sox-users \
		sox-users@lists.sourceforge.net
	public-inbox-index sox-users

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.audio.sox
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.audio.sox
	nntp://news.gmane.io/gmane.comp.audio.sox
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/sox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git