stsaz / fmedia

fast audio player/recorder/converter
BSD 2-Clause "Simplified" License
212 stars 20 forks source link

Multi-channel recording #94

Closed C-gotoh closed 1 year ago

C-gotoh commented 1 year ago

It seems to be not possible to capture multiple channels of a single microphone and encode them as separate channels in the output file, is that correct?

The --channels flag supports besides the values "left", "right", "mono" and "stereo" (the latter mixes all channels to one and duplicates it as far as I can tell from the documentation and behaviour) also the number of output channels "1" and "2", which are aliases for the "mono" and "stereo" options I presume?

Is it possible to select specific channels from an input device?

stsaz commented 1 year ago

Hi!

--channels= argument currently supports these values:

    "1",
    "2",
    "5.1",
    "7.1",
    "left",
    "mono",
    "right",
    "stereo",

stereo should produce correct Left-Right channel file, does it not work for you?

What OS and audio library (e.g. WASAPI, PulseAudio, etc) did you try? Note that on Windows you should set up audio recording format inside Windows Sound Settings, otherwise fmedia will receive mixed-channel audio input, no matter what fmedia options you may specify. For best quality I recommend using WASAPI in exclusive mode on Windows.

Is it possible to select specific channels from an input device?

Do you want to select, say, channel 1 and channel 4, and output them to different files, say, file1.wav & file4.wav, or just glued together into a 2-channel file e.g. mixed-ch1+ch4.wav ?

C-gotoh commented 1 year ago

Hi @stsaz ,

thanks for the clarification. "5.1" is what I needed. Is there a documentation for this or a way to specify the number of channels to capture? I assume only the predefined options are available for channel labeling reasons in the encoded file?

The stereo option seems to produce the correct output, the issue was with my firmware apparently.

I'm using PulseAudio on linux to test this.

I would probably prefer to output a separate file for each targeted input channel, but a mix would also be fine.

Thanks for your fast and helpful feedback so far!

stsaz commented 1 year ago

Is there a documentation for this or a way to specify the number of channels to capture? I assume only the predefined options are available for channel labeling reasons in the encoded file?

It's not possible to specify any other channel value except predefined ones. It seems I forgot to properly document this... Anyway, my channel conversion code is incomplete, and the only supported layouts are:

Supported layouts:
1: FC
2: FL+FR
5.1: FL+FR+FC+LFE+BL+BR
7.1: FL+FR+FC+LFE+BL+BR+SL+SR

Some audio formats, AFAIK, have different layouts, and I should test this functionality properly before claiming that it works OK. Therefore, multichannel audio support is currently experimental, although 5.1 and 7.1 should work fine for most cases, I think.

I would probably prefer to output a separate file for each targeted input channel, but a mix would also be fine.

In general, it won't be a problem to implement another command-line argument for selecting only specific channels while recording, e.g. --use-channels=1,3,5 or even random --use-channels=4,1,3 along with --channels=5.1, and together they will produce a FL+FR+FC 3-channel file - is this what you mean? If so, I don't really understand now why it can be useful...

I recently started to work on a new major update - https://github.com/stsaz/phiola. For now I can only recommend you to try something like phiola rec -chan 3 -o file.wav (you can specify an arbitrary channel number there!) that should just use channels 1,2,3.

C-gotoh commented 1 year ago

Thanks, I will check out that project.

In general, it won't be a problem to implement another command-line argument for selecting only specific channels while recording, e.g. --use-channels=1,3,5 or even random --use-channels=4,1,3 along with --channels=5.1, and together they will produce a FL+FR+FC 3-channel file - is this what you mean? If so, I don't really understand now why it can be useful...

Indeed, this is what I mean. It can be useful if you are messing around with hardware that outputs non-standard audio signals, where not every channel contains useful information. So that is an edge-case that you shouldn't worry about..

Closing this issue then.