# TargetFileMediaFoundation: Failed to create SinkWriter from URL

**URL:** <https://discourse.libcinder.org/t/targetfilemediafoundation-failed-to-create-sinkwriter-from-url/715>\
**Category:** Using Cinder\
**Created:** [June 6, 2017, 10:15am UTC](https://discourse.libcinder.org/t/targetfilemediafoundation-failed-to-create-sinkwriter-from-url/715 "2017-06-06T10:15:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xumo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/xumo/32/75_2.png) [@xumo](https://discourse.libcinder.org/u/xumo)\
**Post date:** [June 6, 2017, 10:15am UTC](https://discourse.libcinder.org/t/targetfilemediafoundation-failed-to-create-sinkwriter-from-url/715/1 "2017-06-06T10:15:50Z")

</div>

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:
	mInputDeviceNode->enable();
        //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
	ctx->enable();

```

The new functions:

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

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

void InputAnalyzer::startRecord(){
	mRecorder->enable();
	mRecorder->start();

};

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

```

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.

---

<div class="post-metadata">

**Author:** ![rich.e](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/rich.e/32/1025_2.png) [@rich.e](https://discourse.libcinder.org/u/rich.e)\
**Post date:** [June 6, 2017, 4:10pm UTC](https://discourse.libcinder.org/t/targetfilemediafoundation-failed-to-create-sinkwriter-from-url/715/2 "2017-06-06T16:10:10Z")

</div>

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](https://github.com/cinder/Cinder/blob/06824fa1c71bae8d994c752b6a24cca52aae5f31/samples/ImageFileBasic/src/ImageFileBasicApp.cpp#L30-L32). 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.

---

<div class="post-metadata">

**Author:** ![xumo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/xumo/32/75_2.png) [@xumo](https://discourse.libcinder.org/u/xumo)\
**Post date:** [June 6, 2017, 4:32pm UTC](https://discourse.libcinder.org/t/targetfilemediafoundation-failed-to-create-sinkwriter-from-url/715/3 "2017-06-06T16:32:57Z")

</div>

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