录制音频 在一定水平上视觉c++ 2008(32位)
我正在尝试制作一个从输入音频设备(例如:麦克风)录制音频的程序 但仅当信号处于活动状态时(意味着仅当有人在麦克风中讲话时) 并另存为mp3格式 我尝试过,但太难了,请帮助我
I'm trying to make a program that record audio from an input audio device (expample: microphone)
but only when the signal is active (means only when some one is talking in the mic)
and save it as mp3 format
and i tried but it is so hard please help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道一种方法可以实现这一点,尽管我不确定这是否是最好的方法:如果您不熟悉 DirectShow,这不一定很容易,因为它需要您学习该技术的许多方面。您可以使用 DirectShow 设置媒体管道,大致如下所示:
Capture Source ->样本采集器 ->音频渲染器
这是一个简单的播放图。在样本采集器中,您可以在样本通过管道时拦截样本。例如,在这里您可以处理样本以查看它是否是静音。如果您做对了,请尝试设置一个看起来像这样的图表:
Capture Source ->样本采集器 -> mp3 编码器 -> filewriter
不确定 filewriter(如果它适用于 mp3 编码数据):需要做更多的作业。
然后使用 GMFBridge 您可以设置多个图表。
1) 捕获源->样本采集器 -> GMF桥水槽
2)GMFBridgeSource-> mp3 编码器 ->文件编写器
3)GMFBridgeSource->渲染器(或其他东西)
GMFBridge 允许您在播放期间动态地在图形之间切换。
因此,1) 通常会连接到 3),直到您检测到一定级别的音频,然后桥接到 2)。一旦音频电平回落至 3)。
我不知道这是否是最好的解决方案,但它是一个解决方案或起点。也许其他人可以建议另一种方法。祝你好运。
I know of a way to accomplish this, although I'm not sure if this is the best way to do it: this will not necessarily be easy if you are not familiar with DirectShow as it requires you to learn many aspects of the technology. You could use DirectShow to set up a media pipeline that looks roughly as follows:
Capture Source -> SampleGrabber -> Audio Renderer
This is a simple playback graph. In the sample grabber you can intercept samples as they pass through the pipeline. Here for example you could process the sample to see whether it is silence or not. When you've got that right, try setting up a graph that looks something like this
Capture Source -> SampleGrabber -> mp3 encoder -> filewriter
Not sure about the filewriter (if that works for mp3 encoded data): more homework for you.
Then using the GMFBridge you could set up multiple graphs.
1) Capture Source -> SampleGrabber -> GMFBridgeSink
2) GMFBridgeSource -> mp3 encoder -> filewriter
3) GMFBridgeSource -> renderer (or something)
GMFBridge allows you to switch between graphs dynamically during playback.
So 1) would typically be connected to 3) until you detect a certain level of audio, then bridges to 2). Once the audio level drops back to 3).
I don't know if this is the best solution, but it is a solution or starting point. Perhaps someone else can suggest another way. Good luck.