# Access to the audio device from a plugin

**URL:** <https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073>\
**Category:** Audio Plugins\
**Created:** [June 24, 2019, 5:45pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073 "2019-06-24T17:45:11Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [June 24, 2019, 5:45pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/1 "2019-06-24T17:45:11Z")

</div>

Is there a way to route audio to the audio device from a vst plugin?

![flow-plugin](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/1/17a88cd557eb48caca52d53b55c41d130ef67d10.png)

I want to do something like this (pseudocode):

> ```
> bufferFromDaw = getAudioBuffer()
> sendToAudioDeviceInput1 (bufferFromDaw)
> bufferFromAudioDevice = getFromAudioDeviceOutput()
> bufferFromDaw = bufferFromAudioDevice
> 
> ```

Thanks.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [June 24, 2019, 5:52pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/2 "2019-06-24T17:52:57Z")

</div>

That is a functionality your host provides. It is not available for plugins.  
You route a track to a physical output into your outboard, and route it back to record into a new track.

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [June 25, 2019, 1:44pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/3 "2019-06-25T13:44:04Z")

</div>

I suspected it, but nevertheless I found this: [https://www.kvraudio.com/product/vst\_interfaced\_asio\_host\_by\_christian\_budde](https://www.kvraudio.com/product/vst_interfaced_asio_host_by_christian_budde)

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [June 25, 2019, 1:50pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/4 "2019-06-25T13:50:19Z")

</div>

It’s possible to attempt all kinds of things, but it doesn’t mean the things will work well.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [June 25, 2019, 2:02pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/5 "2019-06-25T14:02:14Z")

</div>

Even if your audio driver allows multiple programs accessing the device (which you shouldn’t take for granted), the two programs have no guaranteed way of running synchronous…  
so something will run, but the results are unpredictable…  
If you plan to base a product around that, hire enough support people… 😉

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [June 25, 2019, 2:18pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/6 "2019-06-25T14:18:47Z")

</div>

It’s not my intention to work perfectly, it’s to run some hardware analysis, but I guess it will be better to do it from the host, but I have no idea how to do it

This host I have programmed without knowledge of how to make a host, so it may be very badly programmed, but it works perfect to analyze my plugins.

In the host audio loop:

```
void MainContentComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{

    bufferToFill.clearActiveBufferRegion();

    // Clear the buffers
    for (int i = 0; i < filterManagers.size(); ++i)
    {
        filterManagers[i]->setAudioBufferSamples (4, bufferToFill.buffer->getNumSamples());
        filterManagers[i]->getAudioBuffer()->clear();
    }
    
    if (analizer != nullptr)
        analizer->preProcess(); // send analizer test signal to the buffer

    // plugins
    for (int i=0; i < filterManagers.size(); i++)
    {
        filterManagers[i]->processBlock();
    }
    
    if (analizer != nullptr)
        analizer->process(); // fill processed buffers to display analysis
}

```

showing you this code you will realize why I was asking to do this from a plugin.

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [June 25, 2019, 2:51pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/7 "2019-06-25T14:51:52Z")

</div>

If you just want to analyze external hardware, doing your own audio app is going to be the easier way to go. Trying to do it from a plugin inside a 3rd party host by accessing the audio hardware directly isn’t going to work reliably.

However, if the host has suitable routing options of its own, you might be able to utilize those facilities. For example, you could develop separate plugins to do the analysis signal generation and analysis steps. For example : have the signal generator on one track, and make that track’s output go into the audio hardware. Then have another audio track with the analyzer plugin that receives the processed audio from the hardware. This however can get quite complicated if the signal generator and analysis plugins need to share data. Making your own stand alone application would at first thought seem to be the simpler solution.

---

<div class="post-metadata">

**Author:** ![myhrman](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@myhrman](https://forum.juce.com/u/myhrman)\
**Post date:** [June 25, 2019, 6:02pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/8 "2019-06-25T18:02:51Z")

</div>

If the host audio interface is different than the audio interface you want to connect to from inside the plugin, it will be a non-trivial task to resample the audio correspondingly in the plugin (since you’re dealing with multiple clocks).

---

<div class="post-metadata">

**Author:** ![JeffMcClintock](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jeffmcclintock/32/21430_2.png) [@JeffMcClintock](https://forum.juce.com/u/JeffMcClintock)\
**Post date:** [June 26, 2019, 12:45am UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/9 "2019-06-26T00:45:59Z")

</div>

> [@xeneize](#):
>
> I guess it will be better to do it from the host, but I have no idea how to do it

Perhaps writing a “standalone” JUCE app will make the job more straightforward, because then you have direct access to the soundcard.

---

<div class="post-metadata">

**Author:** ![xeneize](https://avatars.discourse-cdn.com/v4/letter/x/ce7236/32.png) [@xeneize](https://forum.juce.com/u/xeneize)\
**Post date:** [June 26, 2019, 1:48pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/10 "2019-06-26T13:48:03Z")

</div>

I will do it from the host (a juce app) now I will see if there is any more “abstract” way to interconnect channels.

Thanks guys!

---

<div class="post-metadata">

**Author:** ![ZioGuido](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zioguido/32/6975_2.png) [@ZioGuido](https://forum.juce.com/u/ZioGuido)\
**Post date:** [February 17, 2023, 9:45pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/11 "2023-02-17T21:45:36Z")

</div>

I’m trying do do something similar to what’s described here. It’s for a personal project, not to be released. It’s for Windows, and I need to get input from the plugin (the host uses ASIO drivers) and route the audio to the WDM device. Since both the ASIO driver and the WDM driver run on the same interface, there should be no clock sync issues.

How can I open the system default audio device directly from within the plugin?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 17, 2023, 9:57pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/12 "2023-02-17T21:57:50Z")

</div>

> [@ZioGuido](#):
>
> Since both the ASIO driver and the WDM driver run on the same interface, there should be no clock sync issues.

Famous last words 😉

There is no guarantee that the host processes in the sample rate the device is running on.  
I don’t know every threading model of the DAW and ASIO, but many DAWs run multiple threads for it’s DSP tasks that are mixed later. So there is no correlation to the clock.

Technically you can have an AudioDeviceManager in the plugin and open the device. But expect dragons…

---

<div class="post-metadata">

**Author:** ![ZioGuido](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zioguido/32/6975_2.png) [@ZioGuido](https://forum.juce.com/u/ZioGuido)\
**Post date:** [February 17, 2023, 10:29pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/13 "2023-02-17T22:29:49Z")

</div>

I could store the incoming audio (from the host) in a large buffer that slowly feeds the WDM outputs. I can have extra latency.

This plugin I’m making samples the audio coming from the host and I want to add a monitoring feature that can bridge the audio to the WDM output, so I can hear it remotely via AnyDesk.

---

<div class="post-metadata">

**Author:** ![ZioGuido](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zioguido/32/6975_2.png) [@ZioGuido](https://forum.juce.com/u/ZioGuido)\
**Post date:** [February 18, 2023, 1:45pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/14 "2023-02-18T13:45:14Z")

</div>

> [@daniel](#):
>
> Famous last words

Well… apparently I made it.

I am receiving audio from the host (ASIO, 44100, 256 buffers) and routing it to a WDM output on the same interface (but buffer size is 441) from within a plugin (only testing with the standalone, at the moment) and it’s working flawlessly.

I could post some code in case someone is interested…

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 18, 2023, 5:04pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/15 "2023-02-18T17:04:07Z")

</div>

Great, congrats. I would be hesitant to publish it though, since that sounds like something that could be different in other hosts…

---

<div class="post-metadata">

**Author:** ![CampbellR](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@CampbellR](https://forum.juce.com/u/CampbellR)\
**Post date:** [November 20, 2023, 2:36pm UTC](https://forum.juce.com/t/access-to-the-audio-device-from-a-plugin/34073/16 "2023-11-20T14:36:51Z")

</div>

I am looking to do what is described in this thread, that is to output audio from a VST plug-in (within Cakewalk DAW) to ASIO (my audio interface). I want the facility to be able to generate pre-FX outputs from Cakewalk tracks. Cakewalk does not provide this. Did anyone within this thread succeed in making a VST app which can do this?  
Thanks!
