# Windows, How to map output device to spectral monitor

**URL:** <https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308>\
**Category:** Uncategorized\
**Created:** [September 13, 2018, 5:24am UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308 "2018-09-13T05:24:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghidra](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@ghidra](https://discourse.libcinder.org/u/ghidra)\
**Post date:** [September 13, 2018, 5:24am UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308/1 "2018-09-13T05:24:49Z")

</div>

I am having trouble on windows specifically in just adding a spectral monitor to the speakers audio.

I am not generating audio, I just want to get the output from whatever is playing on the machine. In linux this has been fine, as speakers are seen as input devices as well.  
But so far on windows, I can not figure out how to pipe the output node into a spectal monitor, or any monitor for that matter.

The [input analyzer example](https://github.com/cinder/Cinder/blob/master/samples/_audio/InputAnalyzer/src/InputAnalyzerApp.cpp) crashes when it tries to find an input as well.

Any help is greatly appreciated.

---

<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:** [September 13, 2018, 8:58am UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308/2 "2018-09-13T08:58:16Z")

</div>

I think I had a similar issue which as solved by @rich.e in this post [Changin audio output](https://discourse.libcinder.org/t/changin-audio-output/1199/2)

You can look a code sample I wrote for selecting audio inputs/outputs, it might help

> **[xumo/CinderAudioSelector](https://github.com/xumo/CinderAudioSelector)**
>
> Example on how to select audio output and input devices with Cinder - xumo/CinderAudioSelector

---

<div class="post-metadata">

**Author:** ![felixfaire](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/felixfaire/32/168_2.png) [@felixfaire](https://discourse.libcinder.org/u/felixfaire)\
**Post date:** [September 13, 2018, 11:11am UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308/3 "2018-09-13T11:11:51Z")

</div>

It sounds like you are trying to capture sound not generated from your app (ie other sounds playing on the machine).

As far as I know Windows does not have native functionality for this and even on Mac OS you need to use a tool called [SoundFlower](https://github.com/mattingalls/Soundflower) (or [Loopback](https://rogueamoeba.com/loopback/) which is paid) to do this. This allows you to set your default system audio output device to “Soundflower” and you can then listen to this device as an input in your Cinder app.

There might be windows tools to achieve this (some hardware audio interfaces even have this feature) but unfortunately this is not something that can be solved in Cinder alone.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![ghidra](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@ghidra](https://discourse.libcinder.org/u/ghidra)\
**Post date:** [September 14, 2018, 5:08am UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308/4 "2018-09-14T05:08:17Z")

</div>

Thanks @xumo  
I took a look at your code (I was not able to compile. I think I was using a different imgui block), but wanted to try and implement what you were showing with the ctx-\>disable();

However, I still get the same failure.

```
auto device = audio::Device::findDeviceByName("MY DEVICE");

ctx->disable();
mOutputDeviceNode = ctx->createOutputDeviceNode(device);
ctx->setOutput(mOutputDeviceNode);
ctx->enable();

////

mInputDeviceNode = ctx->createInputDeviceNode(device);
if (mInputDeviceNode) 
{
    mInputDeviceNode->getChannelMode();
    .....///SET UP SPECTRAL NODES PER FOUND CHANNEL (0 by the way)
     //THIS IS WHERE I CRASH
    mInputDeviceNode->enable();
}

```

This code produces this error:

> Exception thrown at 0x00007FFA8B3FA388 in Test.exe: Microsoft C++ exception: cinder::audio::msw::WasapiExc at memory location 0x0000000000149AA0.

> |fatal | cinder::app::AppBase::executeLaunch[197] Uncaught exception, type: class cinder::audio::msw::WasapiExc, what: Failed to check if format is supported (HRESULT: 80070057, ‘E\_INVALIDARG’)

@felixfaire  
I’m a little optimistic, that surely this must not be so complicated…  
Thanks again for helping out.

---

<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:** [September 14, 2018, 3:00pm UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308/5 "2018-09-14T15:00:25Z")

</div>

I tried this code and had the same error “Error Format unsupported by IAudioClient” at  
`input->enable();` and that’s because you are trying to initialize a input device node with a reference to an output device.  
I think you can only create input node with input devices. It’s like the input node expects a “reader” and not a “writer”.

---

<div class="post-metadata">

**Author:** ![ghidra](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@ghidra](https://discourse.libcinder.org/u/ghidra)\
**Post date:** [September 14, 2018, 3:39pm UTC](https://discourse.libcinder.org/t/windows-how-to-map-output-device-to-spectral-monitor/1308/6 "2018-09-14T15:39:39Z")

</div>

I just dug a little deeper in your example to illustrate something I just realized I misunderstood. At first I thought that you were hooking up outputs to spectral nodes…  
But then found that you had mDevices separate from mAudioOutputDevices.  
So it appears then that I can not connect the output to spectral then at this point. Perhaps @felixfaire is correct.
