I've got a problem where I need to "simulate" microphone output.
Data will be coming over the network, decoded into PCM and basically needs to be written into the mic - which then other programs can read/record/whatever.
I've been reading up on alsa but information is pretty sparse. The file plugin seemes promising - I was thinking of having a named pipe as "infile" which I could then deliver data to from my application. I can't get it to work however (vlc/audacity just segfault).
pcm.testing {
type file
slave {
pcm {
type hw
card 0
device 0
}
}
infile "/dev/urandom"
format "raw"
}
Are there any better ways of doing this? Any suggestions on alsa plug-ins (particularly the file plugin)?
Activate Virtual Mic by going to the menubar and finding Outputs ➝ Virtual Mic and switching it to On. If this is your first time using the feature, choose to install the Virtual Mic. Then, in the other app's camera menu, you'll see Ecamm Live Virtual Mic as a choice.
A virtual microphone is, in fact, a “real” microphone that relies on digital signal processing (DSP) to create facsimiles of the sound pickup characteristics and frequency response of another microphone.
Open the setting of one your microphone devices and enable "Listen to device", select your current output device from the list. Playback audio on that same output device. The mic signal equals the output signal.
It is a real microphone that uses digital signal processing (DSP) to artificially emulate the sound pickup characteristics and frequency response of another microphone. Virtual mics are essentially neutral and transparent sounding with an equally neutral mic preamplifier.
Your sound will come over the network and what would cache it until something wants to read? Or would data be discarded? In general something like the below (only barely tested) should work as a virtual mic, but I think that it will always read file from beginning when device opened and you need to check how does it handle end of file. Perhaps what you would try it using pipes but then caching/discarding incoming data needs to be handled by the app reading from network.
pcm.virtmic {
type file
format "raw"
slave.pcm "default"
file '/dev/null'
infile '/dev/urandom'
}
See alsa docs for more options.
Again, not sure if this tool is what you really need for the task. It would have been really nifty if you could start a command with the 'infile' option, like you can with 'file' but unfortunately you can't...
Hope that helps.
UPDATE: slave.pcm must not be "null" but some real device. It seems that is used for timing or I don't know but using null causes the recorder process to block forever. This device could force you at a given sample rate though so be careful. Using "default" is a sane default value. infile needs to provide a raw sound data with the correct/matching format and rate. btw you can look at alsa server and jackd and other sound systems and libraries for alternative solutions for your task
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With