Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)? [ SOLVED ]

This section is dedicated to applications and configurations for the Google Android OS.

Moderators: MattKingUSA, khz

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)? [ SOLVED ]

Post by Nachei »

My laptop's internal mic broke, so I looked for a way to replace it with the mic of an old Android tablet, connected via USB (it's very convenient to have this microphone always at hand without having to assemble anything when you have an idea, etc). I found this project:

https://github.com/gdzx/audiosource

and got it working without problems with Pulseaudio: the tablet's microphone shows in Pavucontrol as a device called "Unix FIFO source /tmp/audiosource (Microphone)", I can choose it in audio-recorder, and it records flawlessly.

Now I'm trying to take the next step and see of making it work with Jack, so that I can use the microphone in a DAW.

I've tried connecting to Jack with Cadence, the Pulseaudio > Jack bridge is enabled, but Catia's patchbay does not show this mic as a connection.

Do you think of something I could try to make this mic visible to Jack? It surprised me how simple to configure was this Audiosource program, "it just worked", but I'm wondering if such simplicity maybe also means that it doesn't have the code necessary to "talk to" jackd, etc... Thank you for any suggestion...

Last edited by Nachei on Sun Dec 31, 2023 10:13 am, edited 1 time in total.
User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by bluebell »

If you use PulseAudio JACK Sink then jack-clients should be able to record from Pulseaudio.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Nachei »

bluebell wrote: Fri Dec 29, 2023 1:33 pm

If you use PulseAudio JACK Sink

I assume I use it, I'm on Ubuntu 22.04.3., which runs with Pulseaudio, and when I start Jack, a box "PulseAudio Jack Sink" appears in Catia (what I don't get is a box showing the tablet's mic). I'm thus assuming Jack Sink is enabled by default in this system. I have no problem with any other Jack program.

bluebell wrote: Fri Dec 29, 2023 1:33 pm

then jack-clients

This takes to my previous question. What is a jack client? Does jack-sink turn any audio program you use automatically into a "jack client", or each program (the tablet-to laptop converter Audiosource in my case) needs to have their own code that "talks" to Jack, and maybe Audiosource does not have it? To sum up again, Pulse sees and uses the tablet mic, but Jack does not (no box in Catia).

bluebell wrote: Fri Dec 29, 2023 1:33 pm

should

Yeah, we both agree on what should be happening. But the tab's mic does not appear in Catia or Carla, and there's no way to use it via Jack. That's the reason for this post, to ask for some ideas, if maybe there's some config change I could look into, or an alternative way of doing it... This comment doesn't really advance my situation, but thank you for at least confirming that this is weird... :)

User avatar
Impostor
Established Member
Posts: 1392
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 366 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Impostor »

Nachei wrote: Sat Dec 30, 2023 10:30 am

Yeah, we both agree on what should be happening. But the tab's mic does not appear in Catia or Carla, and there's no way to use it via Jack.

All of Pulseaudio's output will be routed through pulseaudio-jack-sink. No individual connections for pulseaudio apps will be available. In jack's connection manager you must simply route the output of pulseaudio-jack-sink into your DAW. That routes all of pulseaudio's sound into your DAW, indiscriminately (any muting/mixing of pulseaudio sources must be done with a pulseaudio mixer).

Much nicer would be to get the mic input recognized in Jack directly, but I've no clue how to do that. That would mean using two distinct audio devices, one for the usb-input, one for output.
https://jackaudio.org/faq/multiple_devices.html

Last edited by Impostor on Sat Dec 30, 2023 11:04 am, edited 1 time in total.
User avatar
LAM
Established Member
Posts: 992
Joined: Thu Oct 08, 2020 3:16 pm
Has thanked: 141 times
Been thanked: 349 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by LAM »

This is what I use to "expose" a Mic or any other source from PA to JACK with its own Sink and Source:

Code: Select all

#!/bin/bash

### Find the default input device
#MICROPHONE='alsa_input.usb-SunplusIT_Inc_FHD_Camera_Microphone_01.00.00-02.analog-stereo'
MICROPHONE=$(pactl get-default-source)
### Create an empty array
mic_pa_devs=()
### Load PA JACK modules and save the index in an array
mic_pa_devs+=( $(pactl load-module module-jack-sink sink_name=mic_out client_name=MicOut channels=1 connect=no) )
mic_pa_devs+=( $(pactl load-module module-jack-source source_name=mic_in client_name=MicIn channels=2 connect=no) )
### Load PA JACK loopback module and save the index in an array
mic_pa_devs+=( $(pactl load-module module-loopback source=${MICROPHONE} sink=mic_out latency_msec=1) )

function remove-mic-modules() {
### Load the file in the array
readarray -t pa_devs < /tmp/pa_devs

### Remove every modules by index
for module in "${pa_devs[@]}"
do
	pactl unload-module $module
	# or do whatever with individual element of the array
done

### Remove the temp file
rm /tmp/pa_devs
exit 0
}

# Set a trap for SIGINT and SIGTERM signals
trap remove-mic-modules SIGTERM SIGINT SIGKILL

### Wait for a keypress to remove the modules
#read -n 1 -s -r -p "Press any key to remove devices"
#echo
while true
do
	sleep 1
done

Use CTRL+C to exit and remove the Mic sources and sink. I use this script in RaySession so it's one click away to start/stop it.

Image

Last edited by LAM on Sat Dec 30, 2023 11:33 am, edited 1 time in total.

in mix, nobody can hear your screen

User avatar
Impostor
Established Member
Posts: 1392
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 366 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Impostor »

LAM wrote: Sat Dec 30, 2023 11:02 am

This is what I use to "expose" a Mic or any other source from PA to JACK with its own Sink and Source:

Isn't using alsa_in/out (https://man.archlinux.org/man/alsa_out.1.en) a better option, cutting out the middle man pulseaudio?

@Nachei: zita-ajbridge is a package found in the Ubuntu repo, providing equivalent functionality, with the extra promise of "much better audio quality". Although maybe it doesn't work with usb plugin devices: "The alsa device should be a 'hw:' one, i.e. direct access to a soundcard and not an ALSA 'plug' device." (https://kokkinizita.linuxaudio.org/linu ... guide.html)

Attachments
promise.png
promise.png (40.8 KiB) Viewed 85396 times
Last edited by Impostor on Sat Dec 30, 2023 11:42 am, edited 4 times in total.
User avatar
LAM
Established Member
Posts: 992
Joined: Thu Oct 08, 2020 3:16 pm
Has thanked: 141 times
Been thanked: 349 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by LAM »

That depends on your case, using PulseAudio allows you to select that Mic when using PA applications, so it can work with both PA and JACK.

@Nachei is using https://github.com/gdzx/audiosource that sends audio via USB to Pulseaudio from another device. Not sure how your suggestion would work here.

in mix, nobody can hear your screen

User avatar
Impostor
Established Member
Posts: 1392
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 366 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Impostor »

LAM wrote: Sat Dec 30, 2023 11:18 am

That depends on your case, using PulseAudio allows you to select that Mic when using PA applications, so it can work with both PA and JACK.

@Nachei is using https://github.com/gdzx/audiosource that sends audio via USB to Pulseaudio from another device. Not sure how your suggestion would work here.

I was just thinking that if Pulseaudio can get sound from this usb connection, then one should also be able to get sound from it with just alsa.

User avatar
erlkönig
Established Member
Posts: 210
Joined: Tue May 31, 2022 8:58 am
Has thanked: 42 times
Been thanked: 48 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by erlkönig »

You could introduce a udev rule, that, when the mic is connected to usb, runs a little script that does all the connection stuff.

Currently working with
https://www.honeysuckers.rocks/?lang=en
Fiddling with sequencers does not evolve into music necessarily and Mac users have smelly feet and guzzle little children.

User avatar
bluebell
Established Member
Posts: 1927
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 113 times
Been thanked: 122 times

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by bluebell »

Nachei wrote: Sat Dec 30, 2023 10:30 am
bluebell wrote: Fri Dec 29, 2023 1:33 pm

If you use PulseAudio JACK Sink

I assume I use it, I'm on Ubuntu 22.04.3., which runs with Pulseaudio, and when I start Jack, a box "PulseAudio Jack Sink" appears in Catia (what I don't get is a box showing the tablet's mic). I'm thus assuming Jack Sink is enabled by default in this system. I have no problem with any other Jack program.

bluebell wrote: Fri Dec 29, 2023 1:33 pm

then jack-clients

This takes to my previous question. What is a jack client? Does jack-sink turn any audio program you use automatically into a "jack client", or each program (the tablet-to laptop converter Audiosource in my case) needs to have their own code that "talks" to Jack, and maybe Audiosource does not have it? To sum up again, Pulse sees and uses the tablet mic, but Jack does not (no box in Catia).

bluebell wrote: Fri Dec 29, 2023 1:33 pm

should

Yeah, we both agree on what should be happening. But the tab's mic does not appear in Catia or Carla, and there's no way to use it via Jack. That's the reason for this post, to ask for some ideas, if maybe there's some config change I could look into, or an alternative way of doing it... This comment doesn't really advance my situation, but thank you for at least confirming that this is weird... :)

With PulseAudio JACK Sink the whole Pulseaudio output goes there. So you won't find your mic there explicitely.

There are alternatives: You can make JACK see your mic with zalsa_in.

Code: Select all

jack_load zalsa_in -i "-d hw:USB"

Instead of USB use the name you see with

Code: Select all

arecord -l

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Nachei »

Impostor wrote: Sat Dec 30, 2023 10:51 am

All of Pulseaudio's output will be routed through pulseaudio-jack-sink. No individual connections for pulseaudio apps will be available. In jack's connection manager you must simply route the output of pulseaudio-jack-sink into your DAW. That routes all of pulseaudio's sound into your DAW, indiscriminately (any muting/mixing of pulseaudio sources must be done with a pulseaudio mixer).

Thank you so much for this great and clear explanation... This is something I didn't know about Pulseaudio and I thought it was going to solve my problem. I tried, per your suggestion, connecting in Catia the output of pulseaudio-jack-sink to the inputs of my DAW (Reaper), then created a track and armed it to record.

What happens is that I get the computer sounds through that track (e.g. the music player that was on)... but not the tablet's mic (tapping on it does not make react the levels, like it does in Pavucontrol).

The part of getting the computer sound makes sense to me, out of what you say... What doesn't is that the tablet's mic is still absent...

Related to that, here are the input devices I'm getting in Pavucontrol:

https://drive.google.com/file/d/1nh7DXF ... drive_link

When I tap on the tablet's mic, the levels of "Unix FIFO Source /tmp/audiosource" move, but the levels on "Monitor of Jack Sink" do nothing (and neither do in Output devices > Jack Sink). Shouldn't those levels be moving too with the taps, given that the sink receives the tablet mic's output?

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Nachei »

@LAM

Thank you for the script, it looked promising, when I ran it it creates a Mic_Out box, but connecting it to the DAW does nothing, I don't know what is it connecting (I haven't managed to understand PA yet and I'm not really sure what the script does...)

I didn't know about RaySession either, I'll also check it out, it looks cool...

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Nachei »

@Impostor

Thank you for the suggestion of zita-ajbridge, although, out of what you yourself say and even quote about the USB devices, I don't think in this case it's even worth trying (or is it?) Good to know for the future that its sound quality is better, by now the sound quality I get with Audiosource is more than enough for the quick-crappy demos I intend to use it for...

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Nachei »

@erlkönig

Thank you for the idea, udev is something I've hardly used and I've always been curious to harness more its power... Perhaps your suggestion is more of the "stage 2" kind, "once you have it working, optimize it"... I'm still at stage 1 I'm afraid, trying to have something that works... :)

Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Ideas to make Jack detect a tablet's microphone connected via USB (and present in Pulseaudio)?

Post by Nachei »

@Bluebell

Thank you for this other great suggestion... Unfortunately, with arecord -l I only get

Code: Select all

**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

This doesn't seem to me like something USB connected, but rather my broken built-in laptop mic....

However, one of the many things I found in Internet and tried without understanding too much:

Code: Select all

pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'

gives

Code: Select all

    index: 1
	name: <alsa_output.pci-0000_00_1f.3.analog-stereo.monitor>
		device.string = "0"
    index: 2
	name: <alsa_input.pci-0000_00_1f.3.analog-stereo>
		device.string = "front:0"
    index: 3
	name: <android>
		device.string = "/tmp/audiosource"
    index: 4
	name: <jack_out.monitor>
  * index: 5
	name: <jack_in>

Therefore the tablet gets detected by Pulseaudio (as index: 3, android)... but not as a hardware connection? Any idea why this might be? Hardware detection is another area where my knowledge is very patchy...

Thank you everybody for the great answers... Even if I don't finally get to solve this, Pulseaudio and Jack have stopped being the dark mystery they used to be for me...

Post Reply