# Need WASAPI fix

**URL:** <https://forum.juce.com/t/need-wasapi-fix/11061>\
**Category:** JUCE Jobs\
**Created:** [March 3, 2011, 6:51pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061 "2011-03-03T18:51:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 3, 2011, 6:51pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/1 "2011-03-03T18:51:51Z")

</div>

Juce is a multiplatform application framework ([http://www.rawmaterialsoftware.com](http://www.rawmaterialsoftware.com)).

Currently the audio implementation for WASAPI and DirectSound input and output is flawed. It treats each stereo channel as an individual device. As only one input and output device can be selected at a time, this makes outputting to more than one stereo channel simultaneously impossible. A single device such as the FireFace 400, show up as many individual devices of one stereo channel each (for example Analog 1+2, Analog 3+4, Analog 5+6, ADAT 1+2, ADAT 3+4, etc…), instead of one device with many input and output channels.

Juce correctly implements the ASIO interface. When an ASIO device is selected, all of its inputs and outputs are correctly enumerated by the library.

This job is to modify the WASAPI and DirectSound implementations (which are Windows-specific) to correctly identify individual devices, and treat their end points as a set of available channels rather than separate devices.

UPDATE

Here are some screenshots of a third party program, and a Juce program, to illustrate this behavior:

The correct approach is to group multiple endpoints with the same hardware device ID as one. These endpoints can be identified because they all have the same PKEY\_DeviceInterface\_FriendlyName (but different PKEY\_Device\_DeviceDesc)

[attachment=1]1.jpg[/attachment]

After selecting a group, the list of available channels is created by enumerating all endpoints with the corresponding PKEY\_DeviceInterface\_FriendlyName. In this screenshot, the text of each channel comes from the value retrieved using PKEY\_Device\_DeviceDesc.

[attachment=0]2.jpg[/attachment]

Unfortunately, Juce treats each endpoint as if it was a separate hardware device, and displays the PKEY\_Device\_FriendlyName instead. This is what it looks like:

[attachment=2]3.jpg[/attachment]

All of these problems exist for DirectSound as well. Here is a small sketch of the changes that need to be made:

[quote=“Vinnie”]Alright upon further investigation I believe that the following is true:

- Under WASAPI, each stereo pair belonging to a hardware device appears as its own audio endpoint
- Juce currently only implements one audio endpoint for output, and one endpoint for input

Therefore

- Juce cannot output more than 2 channels at a time in WASAPI

I poked around the WASAPI calls and traced these values for the first endpoint in my Fireface 400 setup:

GetValue (PKEY\_Device\_FriendlyName,…) == "Speakers (RME Fireface 400)"  
GetValue (PKEY\_Device\_DeviceDesc,…) == “Speakers”

and

GetValue (PKEY\_DeviceInterface\_FriendlyName,…) == “RME Fireface 400”

So here is what I am thinking needs to be done, so far:

1. Change WASAPIAudioIODeviceType to allow for an array of active endpoints for both input and output
2. Modify scanForDevices() to identify unique instances of the PKEY\_DeviceInterface\_FriendlyName and treat the whole set of endpoints as a single device
3. Add code to build a list of input or output channels for a given PKEY\_DeviceInterface\_FriendlyName by enumerating all the endpoints, collecting the ones that match
4. Change the input and output channel names to use PKEY\_Device\_DeviceDesc instead of PKEY\_Device\_FriendlyName[/quote]

---

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [March 8, 2011, 6:52am UTC](https://forum.juce.com/t/need-wasapi-fix/11061/2 "2011-03-08T06:52:05Z")

</div>

I would immediately have done it if I was a WASAPI/DirectSound expert, but I’m not.

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 8, 2011, 11:22am UTC](https://forum.juce.com/t/need-wasapi-fix/11061/3 "2011-03-08T11:22:30Z")

</div>

NO one responded to my elance job posting either, India, Pakistan, Russia, etc… no one.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 8, 2011, 11:40am UTC](https://forum.juce.com/t/need-wasapi-fix/11061/4 "2011-03-08T11:40:30Z")

</div>

I would try on the PortAudio ML

HTH

---

<div class="post-metadata">

**Author:** ![Happy](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@Happy](https://forum.juce.com/u/Happy)\
**Post date:** [March 22, 2011, 8:45am UTC](https://forum.juce.com/t/need-wasapi-fix/11061/5 "2011-03-22T08:45:23Z")

</div>

I m willing to do it…Please send me a mail regarding this.

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 22, 2011, 5:48pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/6 "2011-03-22T17:48:15Z")

</div>

> [@Happy](#):
>
> I m willing to do it…Please send me a mail regarding this.

Is there anything in the original post that is unclear ??

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 22, 2011, 5:56pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/7 "2011-03-22T17:56:39Z")

</div>

I Updated the original post to include screenshots, and some more description of the technical details.

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 22, 2011, 6:00pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/8 "2011-03-22T18:00:39Z")

</div>

Let me add that debugging using the ASIO driver instead of WASAPI (which I would prefer) is REALLY ANNOYING because when my app crashes, or if I force-terminate, I usually have to power cycle the audio device and also my music player stops working, I have to close all my porn and youtube browser instances, and 20% of the time the system is left in a condition that requires a reboot.

I would LOVE to be able to use WASAPI because a crash in shared mode does not disturb the rest of the apps that are using audio resources.

To be clear, the Juce ASIO implementation works perfectly from the standpoint of being able to correctly enumerate distinct ASIO devices, and then further distinguish the individual channels belonging to a particular device.

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 29, 2011, 2:27pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/9 "2011-03-29T14:27:15Z")

</div>

[quote]

- Under WASAPI, each stereo pair belonging to a hardware device appears as its own audio endpoint[/quote]

mmh not sure if its helpful, but with my 30€ china-interface ([http://trust.com/products/product.aspx?artnr=14134](http://trust.com/products/product.aspx?artnr=14134)) i can use 6 stereo channels simultaneously with WASAPI (so its maybe a more driver related issue?)

[attachment=0]interface.png[/attachment]

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 29, 2011, 2:33pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/10 "2011-03-29T14:33:46Z")

</div>

> [@chkn](#):
>
> mmh not sure if its helpful, but with my 30€ china-interface ([http://trust.com/products/product.aspx?artnr=14134](http://trust.com/products/product.aspx?artnr=14134)) i can use 6 stereo channels simultaneously with WASAPI (so its maybe a more driver related issue?)

Whoa…I have to study juce\_win32\_WASAPI.cpp and see how this is possible because I’m getting something different!

On a side note that’s a pretty nice multi-channel interface, what’s the highest sample rate and lowest buffer size you can sustain?

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 29, 2011, 2:45pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/11 "2011-03-29T14:45:55Z")

</div>

> [@TheVinn](#):
>
> On a side note that’s a pretty nice multi-channel interface, what’s the highest sample rate and lowest buffer size you can sustain?

did not checked yet (bought today), i even was suprised that it just works, also with Windows 7 64bit 🙂  
If you buy one, please be careful there different hardware revisions, only the new ones seem to have Windows 7/64 bit drivers

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 29, 2011, 2:48pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/12 "2011-03-29T14:48:41Z")

</div>

> [@](#):
>
> juce\_win32\_WASAPI.cpp and see how this is possible because I’m getting something different!

maybe its just because its handled as one 5.1 surround device

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [March 29, 2011, 2:51pm UTC](https://forum.juce.com/t/need-wasapi-fix/11061/13 "2011-03-29T14:51:25Z")

</div>

> [@chkn](#):
>
> maybe its just because its handled as one 5.1 surround device

Hmm…well obviously the device is presenting itself differently if juce is seeing it as one large group of channels. But either way, juce needs to be improved to recognize the Fireface channels as one device, since it works in other programs.

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [February 1, 2021, 9:39am UTC](https://forum.juce.com/t/need-wasapi-fix/11061/14 "2021-02-01T09:39:27Z")

</div>


