2

How can I record two audio sources at the same time and create a file where one source is the left channel and the other source is the right channel of a lossless stereo audio recording?

My distro is Kubuntu 12.04 LTS.

My audio source hardware is listed at bottom. Specifically, I believe the two sources I want to record at the same time are:

  1. alsa_output.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo.monitor/#2: Monitor of Scarlett 2i2 USB Analog Stereo
  2. alsa_input.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo/#3: Scarlett 2i2 USB Analog Stereo

FYI, this question might be relevant (but I don't understand the command shown there): how to merge two audio input source using avconv

EDIT: this definitely seems relevant, but I am struggling to understand it: http://ubuntuforums.org/showthread.php?t=1962947

My first guess about how to do this is this simple script:

#!/bin/bash
OUTPUT="audio_`date +%Y-%m-%d_%H%M`"
avconv \
-f alsa -ac 2 -i <alsa_output.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo.monitor> \
-f alsa -ac 1 -i <alsa_input.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo> \
-map 0:0 -map 1:0 \
-acodec flac \
-threads 0 \
-y $OUTPUT

I assume I need to replace what is in angle brackets with the correct notation. I have no idea if the rest of the above script is even close...

Here's my hardware info:

$ pacmd list-cards  
Welcome to PulseAudio! Use "help" for usage information.  
>>> 3 card(s) available.  
[snip other cards]
index: 2
name: <alsa_card.usb-Focusrite_Scarlett_2i2_USB-00-USB>
driver: <module-alsa-card.c>
owner module: 6
properties:
        alsa.card = "1"
        alsa.card_name = "Scarlett 2i2 USB"
        alsa.long_card_name = "Focusrite Scarlett 2i2 USB at usb-0000:04:00.0-2, high speed"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:04:00.0-usb-0:2:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:1c.4/0000:04:00.0/usb3/3-2/3-2:1.0/sound/card1"
        udev.id = "usb-Focusrite_Scarlett_2i2_USB-00-USB"
        device.bus = "usb"
        device.vendor.id = "1235"
        device.vendor.name = "Novation EMS"
        device.product.id = "8006"
        device.product.name = "Scarlett 2i2 USB"
        device.serial = "Focusrite_Scarlett_2i2_USB"
        device.string = "1"
        device.description = "Scarlett 2i2 USB"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-usb"
profiles:
        output:analog-stereo: Analog Stereo Output (priority 6000)
        output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060)
        output:analog-stereo+input:iec958-stereo: Analog Stereo Output + Digital Stereo (IEC958) Input (priority 6055)
        output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500)
        output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5560)
        output:iec958-stereo+input:iec958-stereo: Digital Stereo Duplex (IEC958) (priority 5555)
        input:analog-stereo: Analog Stereo Input (priority 60)
        input:iec958-stereo: Digital Stereo (IEC958) Input (priority 55)
        off: Off (priority 0)
active profile: <output:analog-stereo+input:analog-stereo>
sinks:
        alsa_output.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo/#1: Scarlett 2i2 USB Analog Stereo
sources:
        alsa_output.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo.monitor/#2: Monitor of Scarlett 2i2 USB Analog Stereo
        alsa_input.usb-Focusrite_Scarlett_2i2_USB-00-USB.analog-stereo/#3: Scarlett 2i2 USB Analog Stereo
ports:
        analog-output: Analog Output (priority 9900, available: unknown)
                properties:

        analog-input: Analog Input (priority 10000, available: unknown)
                properties:

        iec958-stereo-input: iec958-stereo-input (priority 0, available: unknown)
                properties:

        iec958-stereo-output: Digital Output (S/PDIF) (priority 0, available: unknown)
                properties:

lsusb -v shows the Focusrite_Scarlett_2i2 as:

Bus 003 Device 002: ID 1235:8006 Novation EMS 
  idVendor           0x1235 Novation EMS
  idProduct          0x8006 

Here is more info on this hardware:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
[snip]
card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

$ arecord -l
**** List of CAPTURE Hardware Devices ****
[snip]
card 1: USB [Scarlett 2i2 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
MountainX
  • 17,168
  • 59
  • 155
  • 264
  • The "Monitor" inputs lets you record the *playback* stream. The other input already is stereo, so I don't understand what your problem is. – CL. Aug 24 '13 at 20:18
  • @CL Well, I'm happy to get any reply, but I really don't know how to respond to your comment. I think the question is clear. If you don't understand what I'm trying to do, please be more specific. Thanks. – MountainX Aug 25 '13 at 00:39
  • What exactly do you mean with "audio source"? Something connected to the inputs of your Scarlett 2i2? – CL. Aug 25 '13 at 08:57
  • When you run `pacmd list-cards` it lists sinks and sources for each card. Sinks "pass through" the audio on its way to the final destination (e.g., speakers). The source in this case is a device that delivers the audio stream to the sink. My Scarlette 2i2 card has two sources listed by `pacmd list-cards`. By experimenting with Audacity I confirmed that the monitor source can be used to record my voice (using a high end XLR mic) and the other source can be used to record the interview subject's voice. I want to maintain them as separate but synced audio tracks in one file (like L/R stereo). – MountainX Aug 25 '13 at 15:48
  • So you have two microphones connected to the two inputs of the 2i2? – CL. Aug 25 '13 at 17:15
  • @CL I am only using 1 mic on the 2i2. I am able to hear (and record) the other voice using the monitor source of the 2i2. See if the extra info I included here helps: http://avp.stackexchange.com/questions/8814/how-to-record-two-sources-into-a-single-audio-file-in-linux – MountainX Aug 25 '13 at 17:26
  • The "Monitor" device is implemented by PulseAudio, so you will not be able to access it as an ALSA device (as would be required for `avconv`). It would be possible to create a virtual ALSA device that does what you want, but you'd have to record directly from the other ALSA input device, which you have taken great care to keep a secret. – CL. Aug 25 '13 at 20:31
  • @CL-thanks for the feedback. Unfortunately, I don't understand. Audacity can record from this "Monitor" source while the Audio Host is selected as "ALSA". What additional device info would you like to see? If you mention the command, I'll run it and post the output if it will help. – MountainX Aug 25 '13 at 21:25
  • Try recording the mic and monitor separately, and then mixing or joining the two audio files, as in [How to overlay/downmix two audio files using ffmpeg](https://stackoverflow.com/questions/14498539/how-to-overlay-downmix-two-audio-files-using-ffmpeg) – Metamorphic Feb 08 '22 at 04:14

1 Answers1

0

My solution was to use JACK Audio Connection kit (http://jackaudio.org/). I ended up installing the KX Studio distro (based on Debian/Ubuntu) and I removed PulseAudio for simplicity.

How can I record two audio sources at the same time and create a file where one source is the left channel and the other source is the right channel of a lossless stereo audio recording?

JACK allows me to do exactly this. I'm also using the Ardour software (DAW).

MountainX
  • 17,168
  • 59
  • 155
  • 264