从directshow过滤器图中访问原始wav数据

时间:2015-06-20 22:25:39

标签: c++ audio directshow

下面的代码很乐意在mp3中加载并播放它,但我需要检索原始的wav数据,如果可能的话,浮动。我怎样才能做到这一点?我知道如何使用IAMMultiMediaStream做到这一点,但微软建议在图表上使用过滤器是首选方式,我无法找到任何文档或示例。我原本以为播放声音文件是最困难的部分,访问原始数据很容易。

    IGraphBuilder* pGraph;

// Use its member function CoCreateInstance to 
//create the COM object and obtain the IGraphBuilder pointer.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);

if(FAILED(hr)){ /*... handle hr error*/ }

// Use the overloaded -> operator to call the interface methods.
std::wstring ws;
ws.assign(rInFilename.begin(), rInFilename.end());
hr = pGraph->RenderFile(ws.c_str(), NULL);
if(FAILED(hr)){ /*... handle hr error*/ }

// Declare a second smart pointer and use it to  
// obtain another interface from the object.
IMediaControl* pControl;
IMediaEvent* pEvent;

hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

// Use the second interface.
hr = pControl->Run();
if(FAILED(hr)){ /*... handle hr error*/ }

// Use the third interface. 
long evCode = 0;
pEvent->WaitForCompletion(INFINITE, &evCode);

编辑:我应该链接到显示如何使用流

执行此操作的microsoft文档

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317593%28v=vs.85%29.aspx

0 个答案:

没有答案