Cinder Forum ARCHIVE
the debug error is :
TargetFileMediaFoundation: Failed to create SinkWriter from URL: d:\\record.wav
Is the path "d:\\record.wav" not appropriate??
'CinderProject3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\atigktxx.dll'. Cannot find or open the PDB file.
'CinderProject3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded.
'CinderProject3.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'CinderProject3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\clbcatq.dll'. Symbols loaded.
'CinderProject3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\MMDevAPI.dll'. Symbols loaded.
'CinderProject3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\AudioSes.dll'. Symbols loaded.
First-chance exception at 0x76CAC52F in CinderProject3.exe: Microsoft C++ exception: cinder::audio::AudioFileExc at memory location 0x0018C2D0.
|error | cinder::app::AppBase::executeLaunch[137] Uncaught exception, type: class cinder::audio::AudioFileExc, what : TargetFileMediaFoundation: Failed to create SinkWriter from URL: record.wav
First-chance exception at 0x76CAC52F in CinderProject3.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Unhandled exception at 0x76CAC52F in CinderProject3.exe: Microsoft C++ exception: cinder::audio::AudioFileExc at memory location 0x0018C2D0.
audio::InputDeviceNodeRef mInputDeviceNode;
audio::MonitorSpectralNodeRef mMonitorSpectralNode;
vector<float> mMagSpectrum;
audio::InputNodeRef mInputNode;
audio::TargetFileRef mTargetFile;
audio::BufferRecorderNodeRef mBufferRecoder;
audio::GainNodeRef mGain;
2. in setup(), the code is like below:
auto ctx = audio::Context::master();
mGain = ctx->makeNode(new ci::audio::GainNode(0.9f));
mGain->connect(ctx->getOutput());
mBufferRecoder = ctx->makeNode(new ci::audio::BufferRecorderNode);
mInputDeviceNode = ctx->createInputDeviceNode();
auto monitorFormat = audio::MonitorSpectralNode::Format().fftSize(2048).windowSize(1024);
mMonitorSpectralNode = ctx->makeNode(new audio::MonitorSpectralNode(monitorFormat));
mInputDeviceNode >> mMonitorSpectralNode;
getWindow()->setTitle(mInputDeviceNode->getDevice()->getName());
mGain >> mMonitorSpectralNode;
mMonitorSpectralNode >> mBufferRecoder;
mBufferRecoder->enable();
mBufferRecoder->setNumSeconds(10);
// InputDeviceNode (and all InputNode subclasses) need to be enabled()'s to process audio. So does the Context:
mInputDeviceNode->enable();
ctx->enable();
3. in mouseDown() method, start to write to file:
mBufferRecoder->start();
std::string filePath = "record.wav";
mBufferRecoder->writeToFile(filePath );