[pulseaudio-discuss] How to create a virtual microphone with source set as default monitor device?
guest271314 at gmail.com
Sun Sep 13 17:18:23 UTC 2020
This project started attempting to capture the output of
If run $ pacmd list-sink-inputs will get
sink: 4 <alsa_output.pci-0000_00_14.2.analog-stereo>
volume: mono: 64460 / 98% / -0.43 dB
current latency: 0.00 ms
requested latency: 0.59 ms
sample spec: s16le 1ch 22050Hz
channel map: mono
resample method: speex-float-1
client: 192 <speech-dispatcher-espeak-ng>
media.name = "playback"
application.name = "speech-dispatcher-espeak-ng"
native-protocol.peer = "UNIX socket client"
native-protocol.version = "33"
application.process.id = "45464"
application.process.user = "ubuntu-studio"
application.process.host = "ubuntu-studio"
application.process.binary = "sd_espeak-ng"
application.language = "C"
window.x11.display = ":0.0"
application.process.machine_id = "<id>"
application.process.session_id = "<id>"
$ pacmd list-sources
2 source(s) available.
* index: 4
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
suspend cause: (none)
volume: mono: 0 / 0% / -inf dB
base volume: 20724 / 32% / -30.00 dB
volume steps: 65537
current latency: 4.60 ms
max rewind: 0 KiB
sample spec: s16le 1ch 48000Hz
channel map: mono
used by: 1
linked by: 1
configured latency: 40.00 ms; range is 0.50 .. 2000.00 ms
card: 1 <alsa_card.usb-046d_0804_0B17FC60-02>
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "USB Audio"
alsa.id = "USB Audio"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "USB Device 0x46d:0x804"
alsa.long_card_name = "USB Device 0x46d:0x804 at
usb-0000:00:12.0-1.4, high speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "pci-0000:00:12.0-usb-0:1.4:1.2"
udev.id = "usb-046d_0804_0B17FC60-02"
device.bus = "usb"
device.vendor.id = "046d"
device.vendor.name = "<vendor>"
device.product.id = "0804"
device.product.name = "<name>"
device.serial = "046d_0804_0B17FC60"
device.form_factor = "webcam"
device.string = "hw:1"
device.buffering.buffer_size = "192000"
device.buffering.fragment_size = "96000"
device.access_mode = "mmap+timer"
device.profile.name = "mono-fallback"
device.profile.description = "Mono"
device.description = "<description>"
module-udev-detect.discovered = "1"
device.icon_name = "camera-web-usb"
analog-input-mic: Microphone (priority 8700, latency offset 0
usec, available: unknown)
device.icon_name = "audio-input-microphone"
active port: <analog-input-mic>
One part of what am trying to do is create a virtual microphone that
takes input from speech-dispatcher-espeak-ng persistently or route
output from speech-dispatcher-espeak-ng to the microphone, so that
when capture the microphone the output will be from speech-dispatcher.
How to achieve that?
On Tue, Sep 8, 2020 at 9:24 PM Sean Greenslade <sean at seangreenslade.com> wrote:
> On Mon, Sep 07, 2020 at 05:03:59PM -0700, guest271314 wrote:
> > > I doubt that will be possible. Pavucontrol makes use of the native
> > If mpv can be embedded in an HTML document
> > https://github.com/Kagami/mpv.js it should be possible to embed
> > pavucontrol or pavucontrol-qt
> > https://email@example.com/why-you-should-use-qt-qml-for-you-next-cross-platform-application-part-1-desktop-5e6d8856b7b4)
> > in particular in a browser; for example using WebAssembly; WASI;
> > Native Messaging; at least the ability to control Recording tab (-t 2)
> Electron is a whole separate discussion. Electron applications have
> different levels of access to the system than the vanilla chromium
> > > After reading through those bug reports and related issue links, it's
> > > pretty clear that this is not a use case that they are particularly
> > > interested in supporting.
> > The majority of own repositories at github are dedicated to fixing
> > WontFix; supporting SSML parsing; variable width and height video
> > capture with ability to merge multiple tracks into a single media
> > container, or stream media without a container; streaming audio
> > potentially infinite input streams, that is, a dynamic Internet radio
> > station; capturing speech synthesis output from Web Speech API, which
> > is the origin of this use case of capturing system audio output.
> > > May I perhaps suggest using a different
> > > browser? Firefox had no problem with monitor inputs last time I
> > > checked.
> > Interestingly, am completing testing of another workaround where since
> > Firefox does capture monitor devices, a new, dedicated instance of
> > Nightly is started prior to launching Chromium, the MediaStreamTrack
> > and MediaStream therefrom are added to a WebRTC RTCPeerConnection, and
> > currently using clipboard for signaling which is not ideal though is
> > one way to exchange text data between different browsers, accessing
> > the monitor device at Chromium instance generated at Nightly
> > https://gist.github.com/guest271314/04a539c00926e15905b86d05138c113c.
> > That approach avoids writing and reading raw PCM to memory.
> With the amount of work you're seeming to have put into workarounds,
> maybe you would be better off writing a proper native application?
> > > No idea, I've never done it myself. The example listed in the online
> > > docs shows a simple stereo swap, so you could presumably adapt it by
> > > switching the channels to be non-swapped (and of course substitute your
> > > specific master source name).
> > Not sure precisely how to begin.
> > Am still trying to gather the specific commands in code that
> > pavucontrol uses when setting the stream at the UI. Am not certain
> > what to pass to pactl move-source-output at what time
> > https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/issues/91#note_590795.
> If you read the documentation (e.g. man pactl), it seems pretty
> > move-source-output ID SOURCE
> > Move the specified recording stream (identified by its numerical index) to the specified source (identified by its symbolic name or numerical index).
> So you need to find the specific source output index (ID) and your new
> target source (SOURCE). I started an audacity session recording my
> microphone, and ran the "pactl list source-outputs" command. This gave
> me the index. I then ran the "pactl list sources" to find my target
> source name. The switch command (for my setup) then looked like this:
> > pactl move-source-output 203 pulse_send_nofx.monitor
> pulseaudio-discuss mailing list
> pulseaudio-discuss at lists.freedesktop.org
More information about the pulseaudio-discuss