模拟麦克风(MIC虚拟) [英] Simulate Microphone (virtual mic)

查看:8931
本文介绍了模拟麦克风(MIC虚拟)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我需要模拟麦克风输出的一个问题。

I've got a problem where I need to "simulate" microphone output.

数据将是未来在网络上,德coded到PCM基本上需要被写进麦克风 - 然后其他程序可以读取/记录/不管

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.

我一直在ALSA,但信息读取起来是pretty稀疏。该文件的插件seemes有前途的 - 我想有一个命名管道为INFILE,我可以再从我的应用程序提供的数据的。我不能然而,它的工作(VLC /大言不惭只是段错误)。

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"
}

是否有这样做的更好的方法呢? ALSA上的插件任何建议(特别是文件插件)?

Are there any better ways of doing this? Any suggestions on alsa plug-ins (particularly the file plugin)?

推荐答案

您的声音会在网络上,直到事情想读什么能缓存呢?或将数据被丢弃?
一般来说像下面的(仅勉强测试)应该工作作为一个虚拟的麦克风,但我认为它会始终读取开始文件设备打开时,你需要检查它如何处理文件结束。也许你会尝试使用管道但随后缓存/丢弃传入数据需要由应用程序从网络读取来处理。

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'
}

请参阅 ALSA文档了更多的选择

再次不知道这个工具是你真正需要的任务。这本来是真漂亮,如果你能启动命令的'INFILE'选项,比如你可以用'文件',但可惜你不能...

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...

希望有所帮助。

更新:slave.pcm不能为空,但一些真正的设备。看来,用于定时或我不知道,但使用空导致刻录过程永远阻塞。该设备可以迫使你在给定的采样率虽然所以要小心。使用默认是一个通情达理的默认值。 infile中需要提供具有正确/匹配的格式和速率的原始声音数据。顺便说一句,你可以看看ALSA服务器和jackd等音响系统和替代解决方案库你的任务

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

这篇关于模拟麦克风(MIC虚拟)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆