Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using pulseaudio loopback's to link together my system sounds and my microphone. The problem is that my system sounds have a delay of a second or even more sometimes. I have changed ticked simultaneous in paprefs but that has not fixed it. I am using this script to do so.

STREAM_MODULE=$(pactl load-module module-null-sink sink_name=StreamAudio sink_properties=device.description="StreamAudio")

pactl load-module module-loopback source=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor sink=StreamAudio latency_msec=1 >> /dev/null  
pactl load-module module-loopback source=alsa_input.usb-AKM_AK5370-00-AK5370.analog-mono sink=StreamAudio latency_msec=1 >> /dev/null

pactl load-module module-device-manager >> /dev/null  

read -p "Loaded! Press enter to unload!"

pactl unload-module $STREAM_MODULE
pactl unload-module module-device-manager
pactl unload-module module-null-sink
pactl unload-module module-loopback

I have gone through pages of google, but nothing seems to fix it. Is there something obvious I am missing?

alsa_output.pci-0000_00_1b.0.analog-stereo.monitor are all my system sounds.

alsa_input.usb-AKM_AK5370-00-AK5370.analog-mono is my microphone

Here is an example where the delay becomes 3.4 seconds: http://screencloud.net/v/tNAQ while the other loopback has a lot less http://screencloud.net/v/suIF

From what I can tell, for some reason the buffer fills up. Any way I can flush it or something?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I have found a temporary way out, but this still confuses me. I have made a combined module, and after that I link every sound source I want to the combined one, which then routes to my system sounds and to the Streaming sink.

STREAM_MODULE=$(pactl load-module module-null-sink sink_name=StreamAudio sink_properties=device.description="StreamAudio")
COMBINE_MODULE=$(pactl load-module module-combine-sink sink_name=Combined sink_properties=device.description="Combined" slaves=StreamAudio,alsa_output.pci-0000_00_1b.0.analog-stereo)

pactl load-module module-loopback rate=44000 adjust_time=0 source=alsa_input.usb-AKM_AK5370-00-AK5370.analog-mono sink=StreamAudio latency_msec=1 >> /dev/null

pactl load-module module-device-manager >> /dev/null  

read -p "Loaded! Press enter to unload!"

pactl unload-module $COMBINE_MODULE
pactl unload-module $STREAM_MODULE
pactl unload-module module-device-manager
pactl unload-module module-loopback

There is probably a way I can grep the results of pacmd list-clients and then clean out only valid sources, change their output to the combined sink, but that would take too long and complex to do.

Though now a new problem arises, and I even tested it by running the command through terminal. For some reason I can't change the output sink of Java. Here is what I tried and what it returned:

vilsol@skynet:~$ pacmd move-sink-input 6421 124
Welcome to PulseAudio! Use "help" for usage information.
>>> Moved failed.

I tried with others as well and they all worked. 6421 is the Java index, and 124 is the sink index.

share|improve this answer

Sometime ago I was able to loopback my guitar to the speakers without noticeable delay, so pulseaudio supports that, but I remember having trouble with delays less than 10ms. My suggestions are

  1. to review the command parameters
  2. use a bigger delay
  3. test each loopback separately and
  4. ask directly pulseaudio developers for instructions.
share|improve this answer
    
I have already tried testing each one separately even then the system audio makes a massive buffer, the actual arguments are fine as well. I have also tried increasing the latency, that doesn't help either. I will probably have to ask in the PulseAudio community. –  Vilsol Jul 5 at 17:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.