Discussion:
[SoX-users] Recording Stereo Mix and Microphone at the same time
Dino Vidakovic
2017-04-24 12:15:55 UTC
Permalink
I'm trying to record both sources at the same time into a single file. Is
this possible with Sox? If not, does anyone have any ideas or best
practices to achieve this?
fmiser
2017-04-24 15:36:31 UTC
Permalink
Post by Dino Vidakovic
I'm trying to record both sources at the same time into a single
file. Is this possible with Sox? If not, does anyone have any
ideas or best practices to achieve this?
Do you have three channels of DAC (digital to analog conversion).
A typical sound card will only have two. Unless you have a card
or interface with more, the only possible way to do it is to mix
the stereo to mono with external hardware (2 resistors) and then
have one channel the mic and the other as the now mono mix.

If you have enough DACs to do three tracks at once, then SoX
should be able to accommodate.

A third option is to record the two sources an different times.
That is, record the stereo, then play back the stereo and record
the mic. This is called "over-dubbing". SoX is not well suited to
this type of work. I would recommend ecasound, a command-line
multi-track audio editor. It is not as versatile as SoX, but it
better suited to multi-track DAW (digital audio workstation) task.
Doug Lee
2017-04-24 16:02:22 UTC
Permalink
Post by Dino Vidakovic
I'm trying to record both sources at the same time into a single file.
Is this possible with Sox? If not, does anyone have any ideas or best
practices to achieve this?
If you just mean two devices into one file, I would think something like this would work, where your device names may vary:

sox -m -t waveaudio "Microphone (Logitech Wireless H" -t waveaudio "Microphone (Andrea PureAudio US" outfile.wav

Timings may vary slightly among devices though; so if you're trying to get real-time, more-than-two-channel data mixed down to two channels, your results may and may not be pleasing.
--
Doug Lee ***@dlee.org http://www.dlee.org
SSB BART Group ***@ssbbartgroup.com http://www.ssbbartgroup.com
"If you refuse to be made straight when you are green,
you will not be made straight when you are dry." {African}
Måns Rullgård
2017-04-25 09:43:20 UTC
Permalink
Post by Doug Lee
Post by Dino Vidakovic
I'm trying to record both sources at the same time into a single file.
Is this possible with Sox? If not, does anyone have any ideas or best
practices to achieve this?
If you just mean two devices into one file, I would think something
sox -m -t waveaudio "Microphone (Logitech Wireless H" -t waveaudio "Microphone (Andrea PureAudio US" outfile.wav
Timings may vary slightly among devices though; so if you're trying to
get real-time, more-than-two-channel data mixed down to two channels,
your results may and may not be pleasing.
There are two time-related issues with this. Firstly, the two devices
may not start recording at exactly the same time. The tracks will then
have to be realigned after recording, which is easy enough if they all
start with an externally generated sync signal. Secondly, the ADC
clocks of the devices can (will) drift relative to each other eventually
leading to a buffer overflow or underflow since Sox assumes all inputs
have synchronised samples. There is no easy fix for this.
--
Måns Rullgård
Jan Stary
2017-06-29 11:32:06 UTC
Permalink
Post by Dino Vidakovic
I'm trying to record both sources at the same time into a single file. Is
this possible with Sox? If not, does anyone have any ideas or best
practices to achieve this?
If all the inputs are different channels of the same audio device,
than this is no different than recording any other number of channels
from a single device. But that's probably not what you have.
Is the (mono?) mic connected through one audio card
and the "stereo mix" (a line-in from somewhere?) through another?

I assume you want to record both at the same time, synchronized
(such as a vocal or a solo over a mix of the instrumental tracks).
Or you want to play the stereo mix as an accompaniment and record the mic,
synchronized to the accompaniment (overdubbing).

It is more the underlying audio system's work to do this,
i.e. to warant the synchronization. For example, OpenBSD's sndio
subsystem is very good at this; e.g.

aucat -i backing.wav -o solo.wav

will play backing.wav as an input and record solo.wav as an output,
with sample-precision. SoX is probably not the best tool for this.


Jan

Loading...