aucat - join two mono files into stereo

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

aucat - join two mono files into stereo

Jan Stary
I must be missing something obvious.
How does aucat mix two mono files into one stereo file
as the left and right channel, respectively?

This mixes the two mono files into the left channel,
leaving the right channel empty:

$ aucat -n -i 1.wav -i 2.wav -o mix.wav  

That surprises me; the -j option says:
       
        If the flag is off, then each source channel is routed
        to a single destination channel, possibly discarding channels.

Here the -j is off (by default), so 1.wav is routed
into a single destination channel, namely the left;
2.wav is also routed into a single channel: the left.
Is that intended?


Turning -j on, this mixes each of the two mono files
into both the left and the right channel of the stereo output:

$ aucat -j on -n -i 1.wav -i 2.wav -o mix.wav  

Having -j on,

        a single source may be sent to multiple destinations
        and multiple sources may be mixed into a single destination.

Here, each of 1.wav and 2.wav is indeed sent to multiple destinations,
namely both the left and right channel of the stereo output. However,
"multiple sources are mixed into a single destination" even with -j off:
above, both 1.wav and 2.wav end up in the left channel.

        Jan

Reply | Threaded
Open this post in threaded view
|

Re: aucat - join two mono files into stereo

Alexandre Ratchov-2
On Mon, Feb 10, 2020 at 10:45:02PM +0100, Jan Stary wrote:
> I must be missing something obvious.
> How does aucat mix two mono files into one stereo file
> as the left and right channel, respectively?
>

You have to specify which file goes to which channel,
for instance:

        aucat -n -c 0:0 -i 1.wav -c 1:1 -i 2.wav -c 0:1 -o mix.wav


There is a multi-channel bus. Inputs files (-i) are written to the bus
and output files (-o) are read from the bus. Bus channels are numbered
from 0 to the greatest channel of all files. The per-file -c option
specifies which channels of the bus the file will provide or consume.

> This mixes the two mono files into the left channel,
> leaving the right channel empty:
>
> $ aucat -n -i 1.wav -i 2.wav -o mix.wav  
>

Yes, by default '-c 0:0' is assumed for mono files,
so both go to the left one.

> That surprises me; the -j option says:
>
> If the flag is off, then each source channel is routed
> to a single destination channel, possibly discarding channels.
>
> Here the -j is off (by default), so 1.wav is routed
> into a single destination channel, namely the left;
> 2.wav is also routed into a single channel: the left.
> Is that intended?
>

Yes. We want two files specified the same way to be routed to the same
destination (ie file position on the command line shouldn't matter).

> Turning -j on, this mixes each of the two mono files
> into both the left and the right channel of the stereo output:
>
> $ aucat -j on -n -i 1.wav -i 2.wav -o mix.wav  
>
> Having -j on,
>
> a single source may be sent to multiple destinations
> and multiple sources may be mixed into a single destination.
>
> Here, each of 1.wav and 2.wav is indeed sent to multiple destinations,
> namely both the left and right channel of the stereo output. However,
> "multiple sources are mixed into a single destination" even with -j off:
> above, both 1.wav and 2.wav end up in the left channel.
>

Reply | Threaded
Open this post in threaded view
|

Re: aucat - join two mono files into stereo

Jan Stary
On Feb 10 23:29:18, [hidden email] wrote:

> On Mon, Feb 10, 2020 at 10:45:02PM +0100, Jan Stary wrote:
> > I must be missing something obvious.
> > How does aucat mix two mono files into one stereo file
> > as the left and right channel, respectively?
> >
>
> You have to specify which file goes to which channel,
> for instance:
>
> aucat -n -c 0:0 -i 1.wav -c 1:1 -i 2.wav -c 0:1 -o mix.wav
>
>
> There is a multi-channel bus. Inputs files (-i) are written to the bus
> and output files (-o) are read from the bus. Bus channels are numbered
> from 0 to the greatest channel of all files. The per-file -c option
> specifies which channels of the bus the file will provide or consume.

Thank you, that was my confusion: the -c channel numbers are global.

Without realizing that, the -c 1:1 seems strange for a mono file.
In fact, the wording of

  -c min:max
             The range of audio file channel numbers.
             The default is 0:1, i.e. stereo.

makes it seems erroneous to specify -c 1:1 for a mono file:
being mono, it doesn't even have a '1' channel.

Could you please add something to the effect of your paragraph above?
I can't think of a wording that would be short and clear.

Would you please consider including the following EXAMPLE
to accompany the one that't there now (spliting stereo)?
(I break the cmdline between -i and -o in both cases.)

Index: aucat.1
===================================================================
RCS file: /cvs/src/usr.bin/aucat/aucat.1,v
retrieving revision 1.114
diff -u -p -r1.114 aucat.1
--- aucat.1 24 Apr 2017 06:47:41 -0000 1.114
+++ aucat.1 10 Feb 2020 22:44:08 -0000
@@ -285,8 +285,14 @@ $ aucat -r 44100 -c 2:3 -o file1.wav -c
 .Pp
 Split a stereo file into two mono files:
 .Bd -literal -offset indent
-$ aucat -n -i stereo.wav -c 0:0 -o left.wav \e
- -c 1:1 -o right.wav
+$ aucat -n -i stereo.wav \e
+ -c 0:0 -o left.wav -c 1:1 -o right.wav
+.Ed
+.Pp
+Create a stereo file having two given mono channels:
+.Bd -literal -offset indent
+$ aucat -n -c 0:0 -i left.wav -c 1:1 -i right.wav \e
+ -c 0:1 -o stereo.wav      
 .Ed
 .Sh SEE ALSO
 .Xr audioctl 1 ,


> > Turning -j on, this mixes each of the two mono files
> > into both the left and the right channel of the stereo output:
> >
> > $ aucat -j on -n -i 1.wav -i 2.wav -o mix.wav  
> >
> > Having -j on,
> >
> > a single source may be sent to multiple destinations
> > and multiple sources may be mixed into a single destination.
> >
> > Here, each of 1.wav and 2.wav is indeed sent to multiple destinations,
> > namely both the left and right channel of the stereo output. However,
> > "multiple sources are mixed into a single destination" even with -j off:
> > above, both 1.wav and 2.wav end up in the left channel.

This still seems a bit unclear: "multiple sources being mixed into
a single destination" is not exclusively a feature of -j on,
but the current wording makes it sound that way.

        Jan

Reply | Threaded
Open this post in threaded view
|

Re: aucat - join two mono files into stereo

Jan Stary
On Feb 10 20:31:35, [hidden email] wrote:
> On 2/10/20 18:07, Jan Stary wrote:
> > +Create a stereo file having two given mono channels:
>
> Might be better to say:
>
> Combine two mono files into a single stereo file, one mono file per channel:
>
> "Create a stereo file" makes it sound like you're creating it out of thin
> air, or something. :-)

Yes, thank you. Below I tweaked the wording some more to make it
as similar to the existing text as possible ("mix" not "combine"),
while retaining the point that each of the mono files ends up
in one channel of the stereo.

        Jan

Index: aucat.1
===================================================================
RCS file: /cvs/src/usr.bin/aucat/aucat.1,v
retrieving revision 1.114
diff -u -p -r1.114 aucat.1
--- aucat.1 24 Apr 2017 06:47:41 -0000 1.114
+++ aucat.1 11 Feb 2020 06:26:57 -0000
@@ -285,8 +285,14 @@ $ aucat -r 44100 -c 2:3 -o file1.wav -c
 .Pp
 Split a stereo file into two mono files:
 .Bd -literal -offset indent
-$ aucat -n -i stereo.wav -c 0:0 -o left.wav \e
- -c 1:1 -o right.wav
+$ aucat -n -i stereo.wav \e
+ -c 0:0 -o left.wav -c 1:1 -o right.wav
+.Ed
+.Pp
+Mix two mono files into a stereo file, one per channel:
+.Bd -literal -offset indent
+$ aucat -n -c 0:0 -i left.wav -c 1:1 -i right.wav \e
+ -c 0:1 -o stereo.wav      
 .Ed
 .Sh SEE ALSO
 .Xr audioctl 1 ,

Reply | Threaded
Open this post in threaded view
|

Re: aucat - join two mono files into stereo

Jan Stary
In reply to this post by Alexandre Ratchov-2
On Feb 10 23:29:18, [hidden email] wrote:

> On Mon, Feb 10, 2020 at 10:45:02PM +0100, Jan Stary wrote:
> > I must be missing something obvious.
> > How does aucat mix two mono files into one stereo file
> > as the left and right channel, respectively?
> >
>
> You have to specify which file goes to which channel,
> for instance:
>
> aucat -n -c 0:0 -i 1.wav -c 1:1 -i 2.wav -c 0:1 -o mix.wav
>
>
> There is a multi-channel bus. Inputs files (-i) are written to the bus
> and output files (-o) are read from the bus. Bus channels are numbered
> from 0 to the greatest channel of all files. The per-file -c option
> specifies which channels of the bus the file will provide or consume.

Thank you. The following diff attempts to add a short explanation
along these lines to the manpage. (Is it to wordy?)

Index: aucat.1
===================================================================
RCS file: /cvs/src/usr.bin/aucat/aucat.1,v
retrieving revision 1.114
diff -u -p -r1.114 aucat.1
--- aucat.1 24 Apr 2017 06:47:41 -0000 1.114
+++ aucat.1 11 Feb 2020 06:45:55 -0000
@@ -79,10 +79,17 @@ The options are as follows:
 The buffer size of the audio device in frames.
 Default is 7680.
 .It Fl c Ar min : Ns Ar max
-The range of audio file channel numbers.
-The default is
-.Cm 0:1 ,
-i.e. stereo.
+The range of audio channels.
+For input files, these are the channels the file contributes
+to the global multi-channel bus;
+for output files, these are the channels the file consumes.
+option for details about channel routing.
+If the file header specifies a number of channels,
+.Nm
+will use that by default.
+Otherwise,
+.Cm 0:1
+is the default.
 .It Fl d
 Increase log verbosity.
 .It Fl e Ar enc

> > This mixes the two mono files into the left channel,
> > leaving the right channel empty:
> >
> > $ aucat -n -i 1.wav -i 2.wav -o mix.wav  
> >
>
> Yes, by default '-c 0:0' is assumed for mono files,

For files with a header, aucat uses what the header said about channels.
That makes the above sentence seem to be in conflict with

        The default is 0:1, i.e. stereo.

in the current manpage (also addressed in the above diff).

        Jan


Reply | Threaded
Open this post in threaded view
|

Re: aucat - join two mono files into stereo

Jan Stary
> > There is a multi-channel bus. Inputs files (-i) are written to the bus
> > and output files (-o) are read from the bus. Bus channels are numbered
> > from 0 to the greatest channel of all files. The per-file -c option
> > specifies which channels of the bus the file will provide or consume.
>
> Thank you. The following diff attempts to add a short explanation
> along these lines to the manpage. (Is it to wordy?)

Sorry, stray left-over line removed now.

Index: aucat.1
===================================================================
RCS file: /cvs/src/usr.bin/aucat/aucat.1,v
retrieving revision 1.114
diff -u -p -r1.114 aucat.1
--- aucat.1 24 Apr 2017 06:47:41 -0000 1.114
+++ aucat.1 11 Feb 2020 06:45:55 -0000
@@ -79,10 +79,17 @@ The options are as follows:
The buffer size of the audio device in frames.
Default is 7680.
.It Fl c Ar min : Ns Ar max
-The range of audio file channel numbers.
-The default is
-.Cm 0:1 ,
-i.e. stereo.
+The range of audio channels.
+For input files, these are the channels the file contributes
+to the global multi-channel bus;
+for output files, these are the channels the file consumes.
+If the file header specifies a number of channels,
+.Nm
+will use that by default.
+Otherwise,
+.Cm 0:1
+is the default.
.It Fl d
Increase log verbosity.
.It Fl e Ar enc