geoffreybennett / alsa-scarlett-gui

alsa-scarlett-gui is a Gtk4 GUI for the ALSA controls presented by the Linux kernel Focusrite Scarlett2 Mixer Driver
589 stars 35 forks source link

Clarett+ 8pre -- recording microphone from PCM does not work in wf-recorder #91

Closed 71GA closed 9 months ago

71GA commented 9 months ago

Confirmation

Issue Category

Please select the category that best describes your issue:

Environment Details

Linux Distribution and Version

Focusrite Interface Series and Model

Issue Description

I made my Claret+ 8pre almost working. My current settings (settings.state.zip) look like this in the GUI:

drawing

In the "Router" window you can see that my microphone from Analogue 3 is routed to PCM 3and Mixer input 3. When I make some noise on the microphone, signal can be seen from the "Level" window.

In the "Router" window you can also see that microphone signal is not routed to my Yamaha HS8 studio monitors in order to prevent any loops and subsequent squeaking noises.


It looks like everything works inside the alsa-scarlett-gui. However when I try to record my desktop with audio from microphone things don't work. Here is an example where I use pw-cli list-object Device and pw-cli list-object Node to identify Claret+ 8pre "PCM inputs". I use this info to start wf-recorderdesktop streamming app which is configured to take audio from these "PCM inputs" and record a video recording.mp4.


┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
  └─> pw-cli list-objects Device
    id 43, type PipeWire:Interface:Device/3
        object.serial = "127"
        factory.id = "14"
        client.id = "33"
        device.api = "v4l2"
        device.description = "081d"
        device.name = "v4l2_device.pci-0000_00_14.0-usb-0_3.2.3.1.3_1.2"
        media.class = "Video/Device"
    id 44, type PipeWire:Interface:Device/3
        object.serial = "44"
        factory.id = "14"
        client.id = "33"
        device.api = "v4l2"
        device.description = "USB2.0 HD UVC WebCam"
        device.name = "v4l2_device.pci-0000_00_1d.0-usb-0_1.5_1.0"
        media.class = "Video/Device"
    id 45, type PipeWire:Interface:Device/3
        object.serial = "45"
        factory.id = "14"
        client.id = "33"
        device.api = "v4l2"
        device.description = "USB2.0 HD UVC WebCam"
        device.name = "v4l2_device.pci-0000_00_1d.0-usb-0_1.5_1.0.2"
        media.class = "Video/Device"
    id 46, type PipeWire:Interface:Device/3
        object.serial = "132"
        factory.id = "14"
        client.id = "33"
        device.api = "alsa"
        device.description = "Logitech G PRO X Gaming Headset"
        device.name = "alsa_card.usb-Logitech_PRO_X_000000000000-00"
        device.nick = "PRO X"
        media.class = "Audio/Device"
    id 47, type PipeWire:Interface:Device/3
        object.serial = "131"
        factory.id = "14"
        client.id = "33"
        device.api = "alsa"
        device.description = "HD Webcam C510"
        device.name = "alsa_card.usb-046d_081d_B79494D0-00"
        device.nick = "USB Device 0x46d:0x81d"
        media.class = "Audio/Device"
    id 48, type PipeWire:Interface:Device/3
        object.serial = "48"
        factory.id = "14"
        client.id = "33"
        device.api = "alsa"
        device.description = "Clarett+ 8Pre"
        device.name = "alsa_card.usb-Focusrite_Clarett__8Pre_00003057-00"
        device.nick = "Clarett+ 8Pre"
        media.class = "Audio/Device"
    id 49, type PipeWire:Interface:Device/3
        object.serial = "49"
        factory.id = "14"
        client.id = "33"
        device.api = "alsa"
        device.description = "Built-in Audio"
        device.name = "alsa_card.pci-0000_00_1b.0"
        device.nick = "HDA Intel PCH"
        media.class = "Audio/Device"
    id 50, type PipeWire:Interface:Device/3
        object.serial = "128"
        factory.id = "14"
        client.id = "33"
        device.api = "v4l2"
        device.description = "081d"
        device.name = "v4l2_device.pci-0000_00_14.0-usb-0_3.2.3.1.3_1.2"
        media.class = "Video/Device"

┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
  └─> pw-cli list-objects Node
    id 28, type PipeWire:Interface:Node/3
        object.serial = "28"
        factory.id = "10"
        priority.driver = "20000"
        node.name = "Dummy-Driver"
    id 29, type PipeWire:Interface:Node/3
        object.serial = "29"
        factory.id = "10"
        priority.driver = "19000"
        node.name = "Freewheel-Driver"
    id 36, type PipeWire:Interface:Node/3
        object.serial = "36"
        factory.id = "10"
        client.id = "33"
        node.name = "Midi-Bridge"
        media.class = "Midi/Bridge"
    id 51, type PipeWire:Interface:Node/3
        object.serial = "129"
        object.path = "v4l2:/dev/video2"
        factory.id = "10"
        client.id = "33"
        device.id = "50"
        priority.session = "980"
        node.description = "081d (V4L2)"
        node.name = "v4l2_input.pci-0000_00_14.0-usb-0_3.2.3.1.3_1.2"
        node.nick = "081d"
        media.class = "Video/Source"
        media.role = "Camera"
    id 52, type PipeWire:Interface:Node/3
        object.serial = "52"
        object.path = "v4l2:/dev/video0"
        factory.id = "10"
        client.id = "33"
        device.id = "44"
        priority.session = "1000"
        node.description = "USB2.0 HD UVC WebCam (V4L2)"
        node.name = "v4l2_input.pci-0000_00_1d.0-usb-0_1.5_1.0"
        node.nick = "USB2.0 HD UVC WebCam"
        media.class = "Video/Source"
        media.role = "Camera"
    id 59, type PipeWire:Interface:Node/3
        object.serial = "322"
        object.path = "alsa:pcm:1:hw:1:playback"
        factory.id = "18"
        client.id = "33"
        device.id = "48"
        priority.session = "1000"
        priority.driver = "1000"
        node.description = "Clarett+ 8Pre Multichannel"
        node.name = "alsa_output.usb-Focusrite_Clarett__8Pre_00003057-00.multichannel-output"
        node.nick = "Clarett+ 8Pre"
        media.class = "Audio/Sink"
    id 84, type PipeWire:Interface:Node/3
        object.serial = "323"
        object.path = "alsa:pcm:1:hw:1:capture"
        factory.id = "18"
        client.id = "33"
        device.id = "48"
        priority.session = "2000"
        priority.driver = "2000"
        node.description = "Clarett+ 8Pre Multichannel"
        node.name = "alsa_input.usb-Focusrite_Clarett__8Pre_00003057-00.multichannel-input"
        node.nick = "Clarett+ 8Pre"
        media.class = "Audio/Source"
    id 91, type PipeWire:Interface:Node/3
        object.serial = "377"
        factory.id = "6"
        client.id = "86"
        application.name = "Firefox"
        node.name = "Firefox"
        media.class = "Stream/Output/Audio"

┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
  └─> pw-jack wf-recorder --audio "alsa_input.usb-Focusrite_Clarett__8Pre_00003057-00.multichannel-input"

For unknown reason recording.mp4 video has no sound. This seems weird because we can see that there is signal in "PCM 3" inside the àlsa-scarlett-gui`.

Furthermore, I started some youtube video and if I try to record outputs instead of the inputs like this:

┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
  └─> pw-jack wf-recorder --audio "alsa_output.usb-Focusrite_Clarett__8Pre_00003057-00.multichannel-output"

Then, video has sound.


It seems like I can only record my output, i.e. whatever comes to my Yamaha HS8 studio monitors, but because microphone does not, it is not recorded. However it is worse than this...

In the "Mixer" window I increased gain on the intersections of input Mix 3 and outputs Mix A / Mix B (going to my Yamaha HS8 studio monitors). I then tried recording using:

┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
  └─> pw-jack wf-recorder --audio "alsa_output.usb-Focusrite_Clarett__8Pre_00003057-00.multichannel-output"

and

┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
  └─> pw-jack wf-recorder --audio "alsa_input.usb-Focusrite_Clarett__8Pre_00003057-00.multichannel-input"

but both recording sessions failed to record audio in the video. Does anyone have a clue why I can not record my microphone?

geoffreybennett commented 9 months ago

Hi @71GA,

I am no expert on PipeWire, and I've never heard of wf-recorder until now, but that said...

I suspect you haven't done anything to tell PipeWire or wf-recorder that you want to record channel 3, and it's just recording channels 1/2 (or maybe even every channel & downmixing making everything too quiet). Simple solution is probably to select the Pro Audio profile and connect your mic to PCM 1+2, but try these steps in order to see what's actually happening:

  1. Run qpwgraph and observe the graph when recording to see what channels are being recorded.

  2. Run pavucontrol and select the "Pro Audio" profile for your Clarett. Then repeat step 1.

  3. Using alsa-scarlett-gui, connect your microphone to PCM inputs 1 & 2 instead of PCM input 3 (although you can leave that connection there), then try recording again. Based on what I'm guessing you'll see in steps 1 & 2, recording will work at this stage.

  4. If step 3 works, but you really want to use PCM input 3 instead of 1/2, create a PipeWire "Coupled Stream" device which takes audio from PCM 3 and sends it to a new virtual mono audio device that you can record from. See https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Virtual-devices#coupled-streams

Again, I'm no expert on PipeWire, but I think steps 3 or 4 above are the solution for you.

Let me know how you go please :).

Regards, Geoffrey.

71GA commented 9 months ago

@geoffreybennett Good idea to use qpwgraph to see what happens when wf-recorderruns... I will test it and report back. Meanwhile... What is the difference between Clarett+ 8pre sett as "Multichanel Duplex" or "Pro audio" inside the pavucontrol or pulsemixer?

Note: Did you read a comment at the top of the first image that I posted? I think it would benefit interface a lot to do it like this.

71GA commented 9 months ago

@geoffreybennett This is the thingie... I started wf-recorder like this:

┌───┐
│ $ │ ziga > ziga--workstation > ~ 
└─┬─┘ /dev/pts/3
   └─> pw-jack wf-recorder --audio "alsa_input.usb-Focusrite_Clarett__8Pre_00003057-00.pro-input-0"

And opened qpwgraph which gave away what wf-recorder is doing. It is only recording from AUX1 and AUX2 (actually PCM1 and PCM2).

20231221_20h36m08s_grim

Now, knowing this, I returned inside the alsa-scarlett-gui and inside the "Router" window routed my microphone to PCM1 and PCM2 instead.

20231221_20h41m07s_grim

With this configuration (settings.state.zip) microphone is successfully recorded when running wf-recorder in the same way as above.

Add: I still don't know what to change in the "Router" window if for some reason I would also want wf-recorder to record computer audio alongside my microphone. I suspect that I should somehow route microphone and computer audio to a "Mixer" and put them on the same two mixer outputs which should then route to the PCM1 and PCM2 in the "Router" window. I hope this works. :)

71GA commented 9 months ago

I solved it! As already implied in the "Add" in my previous post, I really used a mixer and achieved a perfect settings (settings.state.zip) that enables me to record computer audio and my microphone with wf-recorder.

I hope this helps someone as well: 20231221_20h57m14s_grim

Done!

geoffreybennett commented 7 months ago

Hi @71GA,

I just noticed in your routing that you've got Mix C going to PCM Inputs 1 & 2. That will result in your recording having the left channel of your computer audio sent to the left and right channels of your recording. If you want a stereo recording of your computer audio then send Mix D to PCM Input 2. Depending on what you've got on the Analogue 7/8 inputs you might want to adjust those in the mixer too. Something like this:

image

Regards, Geoffrey.