我目前正在构建一个使用DS sdk的应用程序,我需要弄清楚如何从音频源不断获取振幅以绘制可视化器或某种类型的光谱。我一直在努力研究如何在音频上实现样本采集器,但我发现的所有信息都已经过时,并且无益。经过几十次尝试,这就是我目前所拥有的:
ISampleGrabber pGrabber = (ISampleGrabber)pSampleGrabber;
hr = pGraph.ConnectDirect(GetPin(pInfinitePinTeeFilterAudio, "Output3"), GetPin(pSampleGrabber, "Input"), null);
checkHR(hr, "1040");
if (hr < 0) return false;
hr = pGraph.ConnectDirect(GetPin(pSampleGrabber, "Output"), GetPin(pNullRenderer, "In"), null);
checkHR(hr, "1041");
if (hr < 0) return false;
AMMediaType media = new AMMediaType();
media.formatType = FormatType.WaveEx;
pGrabber.GetConnectedMediaType(media); //gets and sets media type into media
pGrabber.SetBufferSamples(true);
int cbbuffer = 0;
hr = pGrabber.GetCurrentBuffer(ref cbbuffer, IntPtr.Zero);
如何读取当前缓冲区上的内容,并继续读取缓冲区中的内容?