LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-28-2011, 08:57 AM   #1
Wintershade
LQ Newbie
 
Registered: Aug 2006
Location: Croatia
Distribution: Arch Linux (rolling release)
Posts: 26

Rep: Reputation: 15
ALSA and PulseAudio - recording multiple input devices?


Hello. I have an Intel HDA audio card, and would like to record both my soundcard output and my microphone input at the same time.

Getting to record my soundcard output (aka "Stereo Mix" or "What-U-Hear") is impossible for my soundcard without using the PulseAudio monitor, so I've set that up. Now I can record either the PulseAudio monitor for my soundcard, or the microphone input, but I don't know how to record both at the same time.

Currently, my .asoundrc looks like this:
Code:
pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}


# PulseAudio monitor for all output channels
# Microphone input is NOT included

pcm.pulse_monitor {
  type pulse
  device alsa_output.pci-0000_00_1b.0.analog-surround-51.monitor
}

ctl.pulse_monitor {
  type pulse
  device alsa_output.pci-0000_00_1b.0.analog-surround-51.monitor
}



# PulseAudio microphone

pcm.pulse_mic {
  type pulse
  device alsa_input.pci-0000_00_1b.0.analog-stereo
}

ctl.pulse_mic {
  type pulse
  device alsa_input.pci-0000_00_1b.0.analog-stereo
}

So now I can choose either "pulse" as an input channel in, for example, Audacity or RecordMyDesktop applications (and then set in the PA volume control the actual channel which I want recorded), or choose "pulse_monitor" or "pulse_mic", in order to record either the PA monitor or the microphone, respectively.

I've read through the ALSA plugins reference, as well as the Asym and Dmix pages on ALSA wiki, but I'm still not sure how to put this together.


I figured there should be a way either to route the microphone input into the ALSA output, and thus make the PA monitor "hear" what I speak into the microphone, or to make a completely new channel with both ALSA output and microphone input as "slaves", and then use that for recording.

If anyone could help me accomplish this (or suggest a different solution), I'd be very grateful.


Thanks in advance!
 
Old 04-29-2011, 03:33 PM   #2
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
Quickest might be to just wire your mic to your sound card, module-loopback will do it:

Code:
$ pacmd load-module module-loopback latency_msec=5 # or whatever, the default 200 is way too high
wires Pulse's default source and sink. That won't stop whatever else is playing through the card, mixing is what pulse does. Google module-loopback for the rest of the gory details.

I've found variations on this sed

Code:
pacmd list-sources | sed -nr '/^ |\tname:/H;${g;s/\n\t/\t/g;s/\n//p'
useful for cutting down the volume of pulse's list output (all hail ^R).

To stop the loopback, unload the module (pacmd list-modules will tell you its number).
 
Old 04-29-2011, 06:32 PM   #3
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
What is it exactly that you're trying to do? I might suggest using Jack for all types of low latency routing, and most applications now use native jack output, so you might be able to use it with whatever programs you were using earlier to record via what u hear. Again, it depends on what you're trying to do.

Tip: Why not record narration or whatever you are recording from the mic after you record what you are recording from what u hear? You can then mix it up using something like audacity, and use better editing and effects and what not.
 
Old 04-30-2011, 03:22 AM   #4
Wintershade
LQ Newbie
 
Registered: Aug 2006
Location: Croatia
Distribution: Arch Linux (rolling release)
Posts: 26

Original Poster
Rep: Reputation: 15
Okay, I got what I needed. Thanks to @jthill and this article (more precisely the comments) I managed to get both monitor and microphone input into one sink, and then record it.

Basically, what I did was as follows:

1. open /etc/pulse/default.pa, and uncomment the line:
Code:
load-module module-null-sink
2. ...actually I have to give the sink a name, so I changed the line into:
Code:
load-module module-null-sink sink_name=rmd
(rmd stands for RecordMyDesktop)

3. added two more loopback sinks for rmd
Code:
load-module module-loopback latency_msec=5 sink=rmd
load-module module-loopback latency_msec=5 sink=rmd
4. edited my .asoundrc to remove the unneeded stuff (which was already covered by the alsa-plugins package anyway):
Code:
pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}
5. Restarted my system, mostly to give myself a little time to chant "IA! IA! CTHULHU FHTAGN!" a few times, just for the good measure...

6. Fired up qt-recordmydesktop, started recording, fired up pavucontrol, started recording with qt-recordmydesktop

7. In pavucontrol's Recording tab, set the application [recordmydesktop] to capture "Monitor of Null Output", and the two Loopbacks to Null Outptut set one from "Monitor of Internal Audio", and the other one just "Internal Audio".


Voila! It works perfectly now
I'm absolutely thrilled to have achieved this, because it's not really something my soundcard was even meant to be able to do, and I'm absolutely positive that it's impossible to achieve under W*****s. Many thanks to everyone for your help, it is much appreciated.
 
Old 04-30-2011, 03:41 PM   #5
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
Thank you!

I had no idea the null sink provides a monitor. That was the piece I was missing.
 
  


Reply

Tags
alsa, microphone, mix, pulseaudio, recording



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording sound with PulseAudio from Line-In and Microphone, not working falmdavis Linux - Newbie 4 03-26-2012 07:03 PM
[SOLVED] Squeeze + Pulseaudio + Alsa and USB Midi device causes Pulseaudio crash mad4linux Debian 1 01-26-2011 03:57 AM
pulseaudio default devices overidden tethysgods Linux - Software 2 09-04-2010 01:40 PM
mencoder an alsa input devices delta1010lt zaguerinho Linux - Software 2 06-13-2009 12:43 AM
ALSA - I need Line-Input recording with SB Audigy outspoken Linux - Software 0 05-21-2005 10:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration