[pulseaudio-discuss] Virtual loopback to provide PCM capture

Colin Guthrie gmane at colin.guthr.ie
Mon Jun 29 04:11:36 PDT 2009


'Twas brillig, and Tanu Kaskinen at 29/06/09 11:40 did gyre and gimble:
> 2009/6/29 Davide Cescato <ceski at fedoraproject.org>:
>> Actually I now have a somewhat related question, for another unrelated task
>> I have in mind: recording voip phone calls. What I currently can do is
>> recording from the microphone input, which picks up both my voice and the
>> other person's voice coming through the speakers. However, the path "out
>> through the speakers and in through the microphone" adds a lot of noise to
>> the other person's voice.
>>
>> So, is it possible to somehow set up PA to let me capture a mixed stream
>> containing both the internal audio stream carrying the other person's voice
>> and the microphone input, so that both voices can be captured in good
>> quality? Of course, I would wear headphones to hear the other person's voice
>> and to block it from going through the speakers.
> 
> No, PA doesn't have a feature to mix multiple recording sources.
> However, if the voip app is capable of recording through PA (as
> opposed to using the sound card directly) then you could record the
> two sources and do the mixing yourself somehow. Recording through PA
> shouldn't be any significant feat for alsa applications (just use the
> "default" device like with output), but AFAIK skype can't do it
> currently.
> 
> Recording from multiple sources can have some timing issues due to
> clock drift between the sources. If the nominal sample rate is 44100Hz
> and the real rate difference is 12Hz between the devices (I think this
> might be quite ordinary case) then the drift is about one second per
> hour, if I calculated this correctly. For short calls this shouldn't
> be too much. Also, if the output device (from which you record using
> the monitor source) and the mic device are on the same card, they may
> share the clock, in which case no drift happens.
> 


Just to add a little more here:

What Tanu says is totally correct with regard to clock skew (well, as 
far as I understand it too!).

Now pulse does have a somewhat related capability with regards for 
compensating for this skew in the form of module-combine. What this 
module does is take two sinks (i.e. output devices - alsa cards etc) and 
combine them into one virtual sink. You can then play on this sink and 
have your sound physically output on two independent cards at once. This 
module deals with the complications of resampling due to clock skew that 
is also present in this scenario.

In theory, what you are doing is somewhat similar, but kind of the 
opposite case, you want to take two sources (the mic + the monitor 
source of the "sink input" (i.e. the playback stream of just the voip 
app - not the monitor source of the sink itself as it may contain other 
sound from other apps too) and join them to have a kind of joined source 
which you then simply record.

I'm not sure what Lennart's ultimate plans are in this regard, but it 
would be a useful feature IMO to be able to do this.

In theory a third party app can look for any streams for a given 
application (VoIP app) and automatically find the relevant sources and 
record them in a combined stream that is created and destroyed on the 
fly. The only special case handling the app would have to do is to 
handle when a source disappears from under it gracefully (e.g. when the 
app stops playing sound, the stream will die and thus the monitor source 
that goes with it will also die, killing our combined source - typically 
traditional apps don't like it when pulse kills the stream, so you'd 
have to be careful to handle this correctly).

This may or may not be practically useful as the app itself may do 
numerous post processing after sampling input before sending it to the 
other party. From a legal perspective, what you record is not 
necessarily what the other person actually heard, but it's probably good 
enough for most purposes.

It's quite a lot of work tho', so I wouldn't expect this kind of support 
in pulse anytime soon, if at all :) (unless you get your hands dirty and 
do it yourself :D)

Just thought I'd throw it out there into the discussion pool and see if 
it could swim :p

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
   Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
   Mandriva Linux Contributor [http://www.mandriva.com/]
   PulseAudio Hacker [http://www.pulseaudio.org/]
   Trac Hacker [http://trac.edgewall.org/]




More information about the pulseaudio-discuss mailing list