Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Linux

Reply
 
Thread Tools Display Modes
Old 04-05-2019, 09:21 AM   #1
David Else
Human being with feelings
 
David Else's Avatar
 
Join Date: Mar 2012
Location: Near London, UK
Posts: 575
Default How can I record ALSA on the command line in mono not 6 tracks at once?!

I have been messing about with this for ages, and finally I can record in the pcm_s32le my sound card outputs (rather than the default 16bit)... but only all six inputs at once?!

Quote:
ffmpeg -f alsa -acodec pcm_s32le -ac 6 -i hw:1 -c:a copy out.wav

Guessed Channel Layout for Input Stream #0.0 : 5.1
Input #0, alsa, from 'hw:1':
Duration: N/A, start: 1554480872.967563, bitrate: 9216 kb/s
Stream #0:0: Audio: pcm_s32le, 48000 Hz, 5.1, s32, 9216 kb/s
If I use any number other than 6
Quote:
-ac 6
, or leave out the number of channels then it gives me:

Quote:
[alsa @ 0x555fe4b05440] cannot set sample format 0x10000 2 [or whatever number I choose] (Invalid argument)
I don't think it is an FFMPEG thing, that is why I am asking here

I think the answer is here somewhere:

Quote:
arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: USB [Scarlett 6i6 USB], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

arecord -L
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default
Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=Keyboard
Default Audio Device
sysdefault:CARD=USB
Scarlett 6i6 USB, USB Audio
Default Audio Device
front:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
Front speakers
surround21:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=USB,DEV=0
Scarlett 6i6 USB, USB Audio
IEC958 (S/PDIF) Digital Audio Output
__________________
----------> Fedora Linux Distribution = Computing Joy & Freedom <----------
Learn Digital Audio Home | 'Nebula Explained' Course Out Now! | YouTube Channel | Twitter

Last edited by David Else; 04-05-2019 at 09:49 AM.
David Else is offline   Reply With Quote
Old 04-06-2019, 05:34 AM   #2
David Else
Human being with feelings
 
David Else's Avatar
 
Join Date: Mar 2012
Location: Near London, UK
Posts: 575
Default

I almost solved it, I think on an ALSA level the sound card is outputting all channels at once, so for some reason I need to specify that it has 6 channels. I then need to mix it down to one with -af "pan=mono|c0=FR".
__________________
----------> Fedora Linux Distribution = Computing Joy & Freedom <----------
Learn Digital Audio Home | 'Nebula Explained' Course Out Now! | YouTube Channel | Twitter
David Else is offline   Reply With Quote
Old 04-06-2019, 06:44 AM   #3
Glennbo
Human being with feelings
 
Glennbo's Avatar
 
Join Date: Mar 2008
Location: Planet Earth
Posts: 3,314
Default

I have different sound hardware (two M-Audio Delta 2496 cards) and could never get ALSA in REAPER to see four inputs and four outputs.

In Windows, the two cards appear as a single 4in/4out device. In Linux I had to use JACK with QjackCtrl's patchbay to get all four inputs to work in REAPER, but it's reliable and when I record acoustic drums now all I have to do is fire up QjackCtrl which launches REAPER for me, and I've got all four inputs.

For anything else besides acoustic drums I launch REAPER direct and only have the primary sound card available.
__________________
Glennbo
Hear My Music - Click Me!!!
--
Glennbo is offline   Reply With Quote
Old 04-08-2019, 01:38 AM   #4
Jack Winter
Human being with feelings
 
Jack Winter's Avatar
 
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,770
Default

I'm not 100% sure about this... But IIRC the alsa driver might present either a fixed amount of channels or a range. In one of the cases you have to open the device for all the channels, otherwise you get an error.

Regarding the M-Audio 2496 I think it's actually 12 channels or something like that, so to be able to open it you'd have to specify all the channels that the chip is supporting even if there isn't anything connected in the hardware itself.

Back when I tried to help you with this, I think there was also a way to create a combined device and route the channels so that the channels that you have physically available would be consecutive in numbering, but I've forgotten the details IIRC you never tested the final config file I came up with, so not sure if it works in the real world

If you are interested I could try to see if I still have the information available somewhere.
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040,etc. :)
Jack Winter is offline   Reply With Quote
Old 04-08-2019, 06:19 AM   #5
Glennbo
Human being with feelings
 
Glennbo's Avatar
 
Join Date: Mar 2008
Location: Planet Earth
Posts: 3,314
Default

Back when we were trying to get multi-channel ALSA working with my two M-Audio cards, I tried that last configuration you made up but it still only showed up in REAPER as 2 channels in and out.

My biggest issue with using QjackCtrl to do my mapping is just remembering to launch REAPER using it. Only once so far have I recorded acoustic drum tracks and then realized I had fired up REAPER directly so only two of the four tracks recorded anything. Fortunately I had the part down pretty good. I re-launched with QjackCtrl, and got the four tracks recorded on the next try.
__________________
Glennbo
Hear My Music - Click Me!!!
--
Glennbo is offline   Reply With Quote
Old 04-08-2019, 11:14 AM   #6
David Else
Human being with feelings
 
David Else's Avatar
 
Join Date: Mar 2012
Location: Near London, UK
Posts: 575
Default

I have things working now, and my script is rocking! Anybody want to suggest an improvement or see a problem?

I have been deep in FFMPEG all week and ALSA, I have tried to breakdown this script into parts to make it easy to follow and adapt, even put some links in. Note the 'audio_input' and 'audio_hw' array of arguments, within is dark hidden info from the depths of ALSA!

My sound card settings are:

audio_input=(alsa -acodec pcm_s32le -ac 6)

I need to choose pcm_s32le for 32bit input (which is probably 24bit, but it defaults to 16bit we definitely don't want). I need to choose 6 channels, as that is how many inputs my device has. Any other number and ALSA just says 'NO!'

audio_hw=("front:CARD=USB,DEV=0")

This is a direct reference to my sound card, if i did something like HW:0 that can change on reboot. Your card can reveal it's special name with aplay -L. It will look something like mine I suspect.

Just save the script, make it executable, then call it with the name of the file you want to create. It then records the screen and sound in the ultimate quality of your choice, no crappy re-sampling or mucking about. Adapt as you wish. Right now it records my mic input in mono losslessly, which was not an easy feat and nearly drove me bonkers.

Code:
#!/usr/bin/env bash

set -eu

buffer=(-thread_queue_size 128)
video_input=(x11grab -video_size 1920x1080 -framerate 30)
audio_input=(alsa -acodec pcm_s32le -ac 6)   # we need to specify 6 channels/s32le as defaults fail
audio_hw=("front:CARD=USB,DEV=0")            # replaces usual hw:n that can change (use aplay -L)
video_enc=(libx264 -preset ultrafast -crf 0) # https://trac.ffmpeg.org/wiki/Encode/H.264
audio_enc=(pcm_s32le -af "pan=mono|c0=FR")   # https://ffmpeg.org/ffmpeg.html#Main-options

ffmpeg "${buffer[@]}" -f "${video_input[@]}" -i "$DISPLAY" \
    "${buffer[@]}" -f "${audio_input[@]}" -i "${audio_hw[@]}" \
    -c:v "${video_enc[@]}" \
    -c:a "${audio_enc[@]}" \
    "$1".mkv
__________________
----------> Fedora Linux Distribution = Computing Joy & Freedom <----------
Learn Digital Audio Home | 'Nebula Explained' Course Out Now! | YouTube Channel | Twitter
David Else is offline   Reply With Quote
Old 04-08-2019, 11:37 AM   #7
Jack Winter
Human being with feelings
 
Jack Winter's Avatar
 
Join Date: Aug 2007
Location: Luxembourg/Spain
Posts: 1,770
Default

Quote:
Originally Posted by Glennbo View Post
Back when we were trying to get multi-channel ALSA working with my two M-Audio cards, I tried that last configuration you made up but it still only showed up in REAPER as 2 channels in and out.
I seem to remember that you were happy with qjackctl so we gave up on it. I still had a few ideas though If you are interested I can see if I can dig that up again, I probably have it squirreled away somewhere, but I can't promise to do it straight away
__________________
Reaper for Linux Documentation (WIP). Software: Archlinux/KDE, Fabfilter FX, Komplete 8, Nebula, Schwa/Stillwell, T-racks Max/Amplitube/SVX, etc. Gear: i7-2600k/4700HQ/16GB, RME Multiface/Babyface, Behringer X32, Genelec 8040,etc. :)
Jack Winter is offline   Reply With Quote
Old 04-08-2019, 02:10 PM   #8
Glennbo
Human being with feelings
 
Glennbo's Avatar
 
Join Date: Mar 2008
Location: Planet Earth
Posts: 3,314
Default

Quote:
Originally Posted by Jack Winter View Post
I seem to remember that you were happy with qjackctl so we gave up on it. I still had a few ideas though If you are interested I can see if I can dig that up again, I probably have it squirreled away somewhere, but I can't promise to do it straight away
It's probably more hassle than it's worth. The only time I need 4 channels at once is recording acoustic drums, and launching with QjackCtrl that works reliably and at very low latency for that.

I appreciate your offer because like you, I'm pretty sure it can be made to work. It's just not a high enough priority yet for me to spend more time with it.
__________________
Glennbo
Hear My Music - Click Me!!!
--
Glennbo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.