TargetFileMediaFoundation: Failed to create SinkWriter from URL


Hi, I have an issue writing audio files in Windows 7. It works great in my develop setup with Windows 10, VS2013 and VS2017, cinder 9.1 and dev9.2. But when deploying to a windows 7 machine it breaks, throws AudioFileExc.

I modified the InputAnalyzer to see if my messy code was to blame, but its the same.
The audio file gets to be created, but with 0 Kb, then it throws the exception.

Here is the code:
new funtions and member variables:

void keyDown(KeyEvent event) override;
void startRecord();
void stopRecord();

ci::audio::BufferRecorderNodeRef	mRecorder;
ci::audio::GainNodeRef				mGain;

In setup():

// InputDeviceNode (and all InputNode subclasses) need to be enabled()'s to process audio. So does the Context:
        //Begins edit
	mRecorder = ctx->makeNode(new ci::audio::BufferRecorderNode(2 * ctx->getSampleRate()));
	mRecorder->setNumSeconds(20); // can also set seconds afterwards, which causes a lock and buffer resize
	mGain = ctx->makeNode(new ci::audio::GainNode(0.6f));

	mMonitorSpectralNode >> mGain >> mRecorder;
        //Ends edit

The new functions:

void InputAnalyzer::keyDown(KeyEvent event){
	if (event.getCode() == event.KEY_SPACE){

	}else if (event.getCode() == event.KEY_s){

void InputAnalyzer::startRecord(){


void InputAnalyzer::stopRecord(){
	ci::fs::path audioFile = getDocumentsDirectory() / ("audioTest.wav");	
	mRecorder->writeToFile(audioFile, ci::audio::SampleType::INT_16);

If anyone has come with this kind of situation any hints would be appreciated. For now I think wi will just look for anothe machine.


This is unexpected, though we can hunt for more information to see what’s going wrong. Can you catch the exception and log some information about it? An easy way to do that is to use the CI_LOG_EXCEPTION() macro, like done here. Even better, if you can install Visual Studio and debug your application directly on that Windows 7 PC, then you can place a breakpoint on exceptions and get much more useful information.

Minor nit on your stopRecord() method, you probably want to disable() it before calling writeToFile(), though I doubt it matters too much in practice.


Thanks Rich, will do that. For now we just move to Winows 10. Writing audio files has no more problems.