Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-06 Thread Sean Greenslade
On Fri, Feb 05, 2021 at 10:12:18AM +0100, Renaud GHIA wrote:
> Our application is pulseaudio only.
> So in this case I suppose that Jack must be interconnected with pulseaudio.
> Do you think that even interconnected, I wouldn't have cpu usage problems ?

There will almost certainly be a resampling stage if you pipe audio
between JACK and Pulseaudio.

> Concerning  the remap module, without remap the virtual device is not
> visible by our application...

It's common for applications to ignore monitor sources when presenting a
list of sources to pick from, however if your application allows for a
device name to be specified directly, you can select the monitor source
that way.

Alternatively, you can redirect an existing source output to a different
source programmatically by using "pactl move-source-output", or by using
a grapical utility like pavucontrol.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-05 Thread Pierre-Louis Bossart




On 2/4/21 7:15 PM, Sean Greenslade wrote:

On Thu, Feb 04, 2021 at 06:29:47PM +0100, Renaud GHIA wrote:

Thank you for the tip.
Now I am sure that resampling does not apply (see below).
But unfortunately pulseaudio always consumes 30% of one CPU core!



The reason is that you are using module-loopback. Due to a potential
difference between the clocks on the null sink and on the real sound card
(even though both report 44100 Hz), it always has to resample in order to
correct for the clock skew. If you don't understand, here is an analogy:
you have two mechanical watches. Even though both claim that their hour
hand makes one full circle every 12 hours, in fact, if left unattended,
they will diverge over time. There is no way to avoid that, except by
moving to Jack or PipeWire which simply don't introduce a null sink with an
independent clock.

If you decide to stay on PulseAudio, you can tweak the resampling method.
The default, speex-float-1, is light on the CPU resources and should
produce no distortions detectable by human ear on typical speech and music.
It does produce easily detectable distortions on specifically crafted
signals. If you want to make sure that the resampler is transparent no
matter what is thrown at it, use speex-float-5. There is no point in going
higher than that.


Thanks for your response.
I understand the problem of clock drift when we have several audio hardware
devices (with different qwartz).
But here, it's a pity that the null video driver has an independent clock...
Concerning pipewire, for now it doesn't work with our particular
application (no sound), but it seems to evolve quickly.
I haven't tried jack for now, but if it depends on pulseaudio, won't I have
the same problem?


Jack doesn't depend on pulseaudio, it's an independent sound server.
Though there are ways to make the two interconnect.

As far as I know, jack solves this problem by only allowing one hardware
sound device and locking all clocks to that. See:

https://jackaudio.org/faq/multiple_devices.html

One thing that just occured to me was to ask whether you acutally need
to use the remap module at all. I just did a quick test on a very weak
machine of mine: a null sink, a music player outputting to that sink,
and ffmpeg recording the null sink's monitor-source, all with matching
44.1 kHz sample rates. This resulted in no resamplers in the chain, and
only 9% CPU usage on a 2010 Atom CPU.


If you have an HDaudio device, it's quite likely that the HDaudio bus 
clock and your MONOTONIC_RAW time are locked already. If you use the 
MONOTONIC option for your timers, it'll be subject to NTP corrections 
but for short-enough rendering you shouldn't see a problem without 
resampling.

My 2 cents.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-05 Thread Renaud GHIA
Our application is pulseaudio only.
So in this case I suppose that Jack must be interconnected with pulseaudio.
Do you think that even interconnected, I wouldn't have cpu usage problems ?
Concerning  the remap module, without remap the virtual device is not
visible by our application...
Thanks a lot for your time.

Renaud

Le ven. 5 févr. 2021 à 02:15, Sean Greenslade  a
écrit :

> On Thu, Feb 04, 2021 at 06:29:47PM +0100, Renaud GHIA wrote:
> > >> Thank you for the tip.
> > >> Now I am sure that resampling does not apply (see below).
> > >> But unfortunately pulseaudio always consumes 30% of one CPU core!
> > >>
> > >
> > > The reason is that you are using module-loopback. Due to a potential
> > > difference between the clocks on the null sink and on the real sound
> card
> > > (even though both report 44100 Hz), it always has to resample in order
> to
> > > correct for the clock skew. If you don't understand, here is an
> analogy:
> > > you have two mechanical watches. Even though both claim that their hour
> > > hand makes one full circle every 12 hours, in fact, if left unattended,
> > > they will diverge over time. There is no way to avoid that, except by
> > > moving to Jack or PipeWire which simply don't introduce a null sink
> with an
> > > independent clock.
> > >
> > > If you decide to stay on PulseAudio, you can tweak the resampling
> method.
> > > The default, speex-float-1, is light on the CPU resources and should
> > > produce no distortions detectable by human ear on typical speech and
> music.
> > > It does produce easily detectable distortions on specifically crafted
> > > signals. If you want to make sure that the resampler is transparent no
> > > matter what is thrown at it, use speex-float-5. There is no point in
> going
> > > higher than that.
> >
> > Thanks for your response.
> > I understand the problem of clock drift when we have several audio
> hardware
> > devices (with different qwartz).
> > But here, it's a pity that the null video driver has an independent
> clock...
> > Concerning pipewire, for now it doesn't work with our particular
> > application (no sound), but it seems to evolve quickly.
> > I haven't tried jack for now, but if it depends on pulseaudio, won't I
> have
> > the same problem?
>
> Jack doesn't depend on pulseaudio, it's an independent sound server.
> Though there are ways to make the two interconnect.
>
> As far as I know, jack solves this problem by only allowing one hardware
> sound device and locking all clocks to that. See:
>
> https://jackaudio.org/faq/multiple_devices.html
>
> One thing that just occured to me was to ask whether you acutally need
> to use the remap module at all. I just did a quick test on a very weak
> machine of mine: a null sink, a music player outputting to that sink,
> and ffmpeg recording the null sink's monitor-source, all with matching
> 44.1 kHz sample rates. This resulted in no resamplers in the chain, and
> only 9% CPU usage on a 2010 Atom CPU.
>
> --Sean
>
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-04 Thread Sean Greenslade
On Thu, Feb 04, 2021 at 06:29:47PM +0100, Renaud GHIA wrote:
> >> Thank you for the tip.
> >> Now I am sure that resampling does not apply (see below).
> >> But unfortunately pulseaudio always consumes 30% of one CPU core!
> >>
> >
> > The reason is that you are using module-loopback. Due to a potential
> > difference between the clocks on the null sink and on the real sound card
> > (even though both report 44100 Hz), it always has to resample in order to
> > correct for the clock skew. If you don't understand, here is an analogy:
> > you have two mechanical watches. Even though both claim that their hour
> > hand makes one full circle every 12 hours, in fact, if left unattended,
> > they will diverge over time. There is no way to avoid that, except by
> > moving to Jack or PipeWire which simply don't introduce a null sink with an
> > independent clock.
> >
> > If you decide to stay on PulseAudio, you can tweak the resampling method.
> > The default, speex-float-1, is light on the CPU resources and should
> > produce no distortions detectable by human ear on typical speech and music.
> > It does produce easily detectable distortions on specifically crafted
> > signals. If you want to make sure that the resampler is transparent no
> > matter what is thrown at it, use speex-float-5. There is no point in going
> > higher than that.
>
> Thanks for your response.
> I understand the problem of clock drift when we have several audio hardware
> devices (with different qwartz).
> But here, it's a pity that the null video driver has an independent clock...
> Concerning pipewire, for now it doesn't work with our particular
> application (no sound), but it seems to evolve quickly.
> I haven't tried jack for now, but if it depends on pulseaudio, won't I have
> the same problem?

Jack doesn't depend on pulseaudio, it's an independent sound server.
Though there are ways to make the two interconnect.

As far as I know, jack solves this problem by only allowing one hardware
sound device and locking all clocks to that. See:

https://jackaudio.org/faq/multiple_devices.html

One thing that just occured to me was to ask whether you acutally need
to use the remap module at all. I just did a quick test on a very weak
machine of mine: a null sink, a music player outputting to that sink,
and ffmpeg recording the null sink's monitor-source, all with matching
44.1 kHz sample rates. This resulted in no resamplers in the chain, and
only 9% CPU usage on a 2010 Atom CPU.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-04 Thread Renaud GHIA
Thanks for your response.
I understand the problem of clock drift when we have several audio hardware
devices (with different qwartz).
But here, it's a pity that the null video driver has an independent clock...
Concerning pipewire, for now it doesn't work with our particular
application (no sound), but it seems to evolve quickly.
I haven't tried jack for now, but if it depends on pulseaudio, won't I have
the same problem?

Renaud






Le jeu. 4 févr. 2021 à 00:20, Alexander E. Patrakov  a
écrit :

> чт, 4 февр. 2021 г. в 03:10, Renaud GHIA :
>
>> Thank you for the tip.
>> Now I am sure that resampling does not apply (see below).
>> But unfortunately pulseaudio always consumes 30% of one CPU core!
>>
>
> The reason is that you are using module-loopback. Due to a potential
> difference between the clocks on the null sink and on the real sound card
> (even though both report 44100 Hz), it always has to resample in order to
> correct for the clock skew. If you don't understand, here is an analogy:
> you have two mechanical watches. Even though both claim that their hour
> hand makes one full circle every 12 hours, in fact, if left unattended,
> they will diverge over time. There is no way to avoid that, except by
> moving to Jack or PipeWire which simply don't introduce a null sink with an
> independent clock.
>
> If you decide to stay on PulseAudio, you can tweak the resampling method.
> The default, speex-float-1, is light on the CPU resources and should
> produce no distortions detectable by human ear on typical speech and music.
> It does produce easily detectable distortions on specifically crafted
> signals. If you want to make sure that the resampler is transparent no
> matter what is thrown at it, use speex-float-5. There is no point in going
> higher than that.
>
> --
> Alexander E. Patrakov
> CV: http://u.pc.cd/wT8otalK
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-03 Thread Alexander E. Patrakov
чт, 4 февр. 2021 г. в 03:10, Renaud GHIA :

> Thank you for the tip.
> Now I am sure that resampling does not apply (see below).
> But unfortunately pulseaudio always consumes 30% of one CPU core!
>

The reason is that you are using module-loopback. Due to a potential
difference between the clocks on the null sink and on the real sound card
(even though both report 44100 Hz), it always has to resample in order to
correct for the clock skew. If you don't understand, here is an analogy:
you have two mechanical watches. Even though both claim that their hour
hand makes one full circle every 12 hours, in fact, if left unattended,
they will diverge over time. There is no way to avoid that, except by
moving to Jack or PipeWire which simply don't introduce a null sink with an
independent clock.

If you decide to stay on PulseAudio, you can tweak the resampling method.
The default, speex-float-1, is light on the CPU resources and should
produce no distortions detectable by human ear on typical speech and music.
It does produce easily detectable distortions on specifically crafted
signals. If you want to make sure that the resampler is transparent no
matter what is thrown at it, use speex-float-5. There is no point in going
higher than that.

-- 
Alexander E. Patrakov
CV: http://u.pc.cd/wT8otalK
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-03 Thread Renaud GHIA
Thank you for the tip.
Now I am sure that resampling does not apply (see below).
But unfortunately pulseaudio always consumes 30% of one CPU core!

Renaud

driver: 
flags:
state: RUNNING
source: 8 
volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% /
0.00 dB
   balance 0.00
muted: no
current latency: 0.50 ms
requested latency: 2000.00 ms
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
resample method: (null)
owner module: 6
client: 29 
properties:
media.name = "record"
application.name = "Lavf58.20.100"
native-protocol.peer = "UNIX socket client"
native-protocol.version = "32"
application.process.id = "18295"
application.process.user = "vagrant"
application.process.host = "debian10.localdomain"
application.process.binary = "ffmpeg"
application.language = "C"
window.x11.display = ":0"
application.process.machine_id = "c79df160d01f4c7780e6da0aaf5515c3"
application.process.session_id = "8"
module-stream-restore.id = "source-output-by-application-name:Lavf58.20.100"

Le mer. 3 févr. 2021 à 21:04, Sean Greenslade  a
écrit :

> On Tue, Feb 02, 2021 at 10:40:51AM +0100, Renaud GHIA wrote:
> > Hi,
> >
> > Below the result of the command "pacmd list".
> > Here without any change of resampling method.
>
> This part here shows your ffmpeg client:
>
> > index: 1
> > driver: 
> > flags:
> > state: RUNNING
> > source: 2 
> > volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% /
> > 0.00 dB
> >balance 0.00
> > muted: no
> > current latency: 0.50 ms
> > requested latency: 2000.00 ms
> > sample spec: s16le 2ch 48000Hz
> > channel map: front-left,front-right
> > Stereo
> > resample method: speex-float-1
>
> It seems like ffmpeg is requesting 48 kHz audio, so pulse is forced to
> resample. If possible, can you try running your ffmpeg process with the
> flag "-sample_rate 44100" and see if that reduces the CPU usage?
>
> Everything else in your pulse chain is 44.1 kHz, so with that change
> there should be no resampling at all.
>
> --Sean
>
> ___
> pulseaudio-discuss mailing list
> pulseaudio-discuss@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-03 Thread Sean Greenslade
On Tue, Feb 02, 2021 at 10:40:51AM +0100, Renaud GHIA wrote:
> Hi,
> 
> Below the result of the command "pacmd list".
> Here without any change of resampling method.

This part here shows your ffmpeg client:

> index: 1
> driver: 
> flags:
> state: RUNNING
> source: 2 
> volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% /
> 0.00 dB
>balance 0.00
> muted: no
> current latency: 0.50 ms
> requested latency: 2000.00 ms
> sample spec: s16le 2ch 48000Hz
> channel map: front-left,front-right
> Stereo
> resample method: speex-float-1

It seems like ffmpeg is requesting 48 kHz audio, so pulse is forced to
resample. If possible, can you try running your ffmpeg process with the
flag "-sample_rate 44100" and see if that reduces the CPU usage?

Everything else in your pulse chain is 44.1 kHz, so with that change
there should be no resampling at all.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-02 Thread Renaud GHIA
Hi,

Below the result of the command "pacmd list".
Here without any change of resampling method.

Thanks

Memory blocks currently allocated: 10, size: 102.5 KiB.
Memory blocks allocated during the whole lifetime: 105406, size: 15.0 MiB.
Memory blocks imported from other processes: 5, size: 8.6 KiB.
Memory blocks exported to other processes: 2, size: 188 B.
Total sample cache size: 0 B.
Default sample spec: s16le 2ch 44100Hz
Default channel map: front-left,front-right
Default sink name: VAC
Default source name: VACmic
Memory blocks of type POOL: 5 allocated/101237 accumulated.
Memory blocks of type POOL_EXTERNAL: 0 allocated/0 accumulated.
Memory blocks of type APPENDED: 0 allocated/0 accumulated.
Memory blocks of type USER: 0 allocated/0 accumulated.
Memory blocks of type FIXED: 0 allocated/0 accumulated.
Memory blocks of type IMPORTED: 5 allocated/4169 accumulated.
21 module(s) loaded.
index: 0
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore the volume/mute state of
devices"
module.version = "12.2"
index: 1
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore the volume/mute/device state of
streams"
module.version = "12.2"
index: 2
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore profile of cards"
module.version = "12.2"
index: 3
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Augment the property sets of streams with additional
static information"
module.version = "12.2"
index: 4
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "David Henningsson"
module.description = "Switches ports and profiles when devices are
plugged/unplugged"
module.version = "12.2"
index: 5
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Detect available audio hardware and load matching
drivers"
module.version = "12.2"
index: 6
name: 
argument: <>
used: -1
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "Native protocol (UNIX sockets)"
module.version = "12.2"
index: 7
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore the default sink and source"
module.version = "12.2"
index: 8
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "When a sink/source is removed, try to move its
streams to the default sink/source"
module.version = "12.2"
index: 9
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Colin Guthrie"
module.description = "Always keeps at least one sink loaded even if it's a
null one"
module.version = "12.2"
index: 11
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically set device of streams based on intended
roles of devices"
module.version = "12.2"
index: 12
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "When a sink/source is idle for too long, suspend it"
module.version = "12.2"
index: 13
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Create a client for each ConsoleKit session of this
user"
module.version = "12.2"
index: 14
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Create a client for each login session of this user"
module.version = "12.2"
index: 15
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Position event sounds between L and R depending on
the position on screen of the widget triggering them."
module.version = "12.2"
index: 16
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Mute & cork streams with certain roles while others
exist"
module.version = "12.2"
index: 17
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Colin Guthrie"
module.description = "Detect when various filters are desirable"
module.version = "12.2"
index: 18
name: 
argument: <>
used: -1
load once: yes
properties:
module.author = "Colin Guthrie"
module.description = "Load filter sinks automatically when needed"
module.version = "12.2"
index: 19
name: 
argument: 
used: 2
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "Clocked NULL sink"
module.version = "12.2"
index: 20
name: 
argument: 
used: 1
load once: no
properties:
module.author = "Stefan Huber"
module.description = "Virtual 

Re: [pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-02-01 Thread Sean Greenslade
On Sat, Jan 30, 2021 at 12:29:46PM +0100, Renaud GHIA wrote:
> Hi,
> 
> I use pulseaudio in a use case where the cpu usage is very high (30%) and
> IHMO this is not normal.
> I tried all the tricks to decrease the cpu load without success
> (resampling-method etc...). The cpu remains high.
> 
> My use case is simple. I redirect the sound output of an application to the
> sound input of another application (in this case ffmpeg). I load two
> modules to create my virtual audio cable like this:
> 
> pactl load-module module-null-sink sink_name=VAC_spk
> sink_properties=device.description=VAC
> 
> pactl load-module module-remap-source master=VAC_spk.monitor
> source_name=VAC1_mic source_properties=device.description=VAC
> 
> Everything works perfectly, except the cpu which is 30% for this simple use
> case.
> My cpu is a AMD threadripper and i'am with the latest stable release
> pulseaudio 14.2 freshly compiled,
> Do you know how to lower the CPU usage?

Have you made sure that everything in the chain is operating at the same
sample rate? That could be a cause of high CPU usage.

Also, I've seen high CPU usage on my setups when I have a large number
of pulse clients running and I open pavucontrol, since pavucontrol
creates a source output for every client in order to display its VU
meters.

If neither of those are the cause, can you share the output of the
command "pacmd list" when you're seeing high CPU usage? That might shed
additional light on what's happening in your setup.

--Sean

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Virtual audio cable - high cpu usage

2021-01-30 Thread Renaud GHIA
Hi,

I use pulseaudio in a use case where the cpu usage is very high (30%) and
IHMO this is not normal.
I tried all the tricks to decrease the cpu load without success
(resampling-method etc...). The cpu remains high.

My use case is simple. I redirect the sound output of an application to the
sound input of another application (in this case ffmpeg). I load two
modules to create my virtual audio cable like this:

pactl load-module module-null-sink sink_name=VAC_spk
sink_properties=device.description=VAC

pactl load-module module-remap-source master=VAC_spk.monitor
source_name=VAC1_mic source_properties=device.description=VAC

Everything works perfectly, except the cpu which is 30% for this simple use
case.
My cpu is a AMD threadripper and i'am with the latest stable release
pulseaudio 14.2 freshly compiled,
Do you know how to lower the CPU usage?

Thanks

Renaud
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss