eiz / SynchronousAudioRouter

Low latency application audio routing for Windows
http://sar.audio/
GNU General Public License v3.0
1.02k stars 136 forks source link

Can't use Synchronous Audio Router as an ASIO Device with Jack #22

Open euwbah opened 7 years ago

euwbah commented 7 years ago

First of all, thank you @eiz for making this amazing software. Honestly, there isn't any other 'virtual cable' software that does what SAR does, which is why I so desperately want to get this working!

I'm using a newer version of SAR from here https://github.com/eiz/SynchronousAudioRouter/issues/13#issuecomment-294436985, because the 'official' v0.12 beta doesn't work on windows 10 + anniversary update (not on my computer at least).

Running jackd -RSv -d portaudio -d "ASIO::Synchronous Audio Router" -P 95 -p 64 gives me this:

jackdmp 1.9.11
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
Drivers/internals found in : C:\WINDOWS
Drivers/internals found in : C:\WINDOWS
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Jack: JackWinThread::StartImp : create non RT thread
Jack: JackWinThread::ThreadHandler : start
Jack: Initializing PortAudio...
Cannot connect to named pipe after wait = \\.\pipe\server_jack_default_0 err = 2
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Open error: is JACK server running?
jack_deactivate called with a NULL client
jack_deactivate called with a NULL client
jack_client_close called with a NULL client
Jack: JackPortAudioDriver::Open nframes = 64 in = 0 out = 0 capture name = ASIO::Synchronous Audio Router playback name
= ASIO::Synchronous Audio Router samplerate = 44100
Jack: JackDriver::Open capture_driver_name = ASIO::Synchronous Audio Router
Jack: JackDriver::Open playback_driver_name = ASIO::Synchronous Audio Router
Jack: Check protocol client = 8 server = 8
Jack: JackEngine::ClientInternalOpen: name = system
Jack: JackEngine::AllocateRefNum ref = 0
Jack: JackWinSemaphore::Allocate name = jack_pipe.default_system val = 0
Jack: JackEngine::NotifyAddClient: name = system
Jack: JackGraphManager::SetBufferSize size = 64
Jack: JackConnectionManager::DirectConnect first: ref1 = 0 ref2 = 0
Jack: JackGraphManager::ConnectRefNum cur_index = 0 ref1 = 0 ref2 = 0
Jack: JackDriver::SetupDriverSync driver sem in normal mode
Jack: JackPortAudioDriver::Open fInputDevice = -1, fOutputDevice 10
Jack: JackPortAudioDriver::Open setup max in channels = 0
Jack: JackPortAudioDriver::Open setup max out channels = 18
Jack: JackPortAudioDriver::OpenStream buffer_size = 64
Cannot connect to named pipe after wait = \\.\pipe\server_jack_default_0 err = 2
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Open error: is JACK server running?
E0710 23:51:46.888397  1076 wrapper.cpp:398] Invalid buffer size: larger than system audio engine periodicity
jack_deactivate called with a NULL client
jack_deactivate called with a NULL client
jack_client_close called with a NULL client
Pa_OpenStream error = Unanticipated host error
Jack: JackDriver::Close
Jack: JackConnectionManager::DirectDisconnect last: ref1 = 0 ref2 = 0
Jack: JackGraphManager::DisconnectRefNum cur_index = 0 ref1 = 0 ref2 = 0
Jack: JackEngine::ClientInternalClose ref = 0
Jack: JackEngine::ClientCloseAux ref = 0
Jack: JackGraphManager::RemoveAllPorts ref = 0
Jack: JackWinSemaphore::Destroy jack_pipe.default_system
Can't open default PortAudio device
Jack: Terminate PortAudio...
Jack: ~JackDriver
Cannot initialize driver
Jack: no message buffer overruns
Jack: JackWinThread::Stop
Jack: JackWinThread::ThreadHandler : exit
JackServer::Open failed with -1
Jack: Succeeded in unlocking 82280346 byte memory area
Jack: JackShmMem::delete size = 0 index = 0
Jack: ~JackDriver
Jack: Succeeded in unlocking 1187 byte memory area
Jack: JackShmMem::delete size = 0 index = 1
Jack: Cleaning up shared memory
Jack: Cleaning up files
Jack: Unregistering server `default'
Failed to open server
PS C:\WINDOWS\system32>

However, starting Jack normally using -d "ASIO::ASIO4ALL v2" as the ASIO device then using SAR as the playback device on a DAW (I've tried Bitwig, Reaper, and FL Studio -- the lattermost to no avail), lets me create virtual playback / recording devices.

Thing is, I've seen tutorial videos on YouTube (here and here) showing that it is possible to just start jack with SAR so that I can just connect the virtual audio sink nodes with jack / catia directly, instead of having to go through a DAW. I'd definitely would prefer to do all my routing within Jack and use my DAW solely for music production.

I'm pretty sure the main issue here is this: E0710 23:51:46.888397 1076 wrapper.cpp:398] Invalid buffer size: larger than system audio engine periodicity. Thing is, my buffer size is already at 64 frames, which should really be "small enough". I even tried bringing it down to 16 frames, and it still shows the same error. This error doesn't appear when using -d "ASIO::ASIO4ALL v2".

There are also issues when using SAR on FL Studio. When using SAR as the playback device for FL Studio 12 (64 bit), I get this error: image

When using SAR as the playback device for FL Studio 12 (32 bit), I get this error: image

Those issues make SAR incompatible with FL Studio for any purpose, I'm unable to get system sounds to play on FL Studio.

As for Bitwig and Reaper, I am able to use SAR as the playback device, create virtual playback devices to act as a sink for system sounds (OS sounds, browser audio etc), and create live audio channels to get system sounds to actually play on the speakers via Jack which uses ASIO4ALL. But it really doesn't make sense for me to use a DAW just to re-route system sounds such that it can be concurrently sounded while I'm using FL Studio (which is my main DAW).

Is it no longer possible to use SAR as an ASIO device to use directly with Jack? Or am I doing something wrong here? I have very little experience in dealing with audio drivers, routing and such, especially on Windows, so any help would be appreciated.

cjunekim commented 7 years ago

Well, it works just fine on my machine.

I'm using JACK, SAR, tascam audio interface as the asio driver backend of SAR, and Reaper on windows 10. The buffer size I provide to SAR is 64, which is also the minimum size of tascam audio interface driver.

dalegaard commented 6 years ago

Just wanted to drop a note here for others with this problem: If your ASIO device reports a minimum latency of >10 ms, Portaudio(which is used by Jack in this setup) will decide a minimum buffer size matching that latency, no matter what you set using the -p option. In my case, using an XR18 mixer, I managed to fix the problem in the control panel of its ASIO driver where the latency was settable.

cdhowie commented 5 years ago

I was not able to use SAR with Jack until using another program (Ardour) which supports opening ASIO driver configuration panels. The problem was that SAR was never configured. After using another program to configure SAR, Jack plays with SAR just fine.

LuvToRekord commented 4 years ago

I have a STRANGE issue that occurs now and then and is unfortunately an issue right now.

I do weekly livestreams and play guitar at the top of each livestream. I run a licensed version of Reaper and have the Syncronous Audio Router installed to send the main out from the SARS output endpoints (using the ASIO driver for my Behringer UMC404HD interface of course) to Windows which is then captured in Streamlabs OBS as an audio input source on my scene. If you use OBS or Streamlabs you know what I mean

Crazy thing is that every now and then, (once every few months maybe at most) even though I haven't touched ONE THING in ANY application to change this audio routing, Windows stops receiving any audio from the output so, in turn, Streamlabs isn't getting any audio as well. WTH?!

I feel like I've tried everything, uninstalled SARS, reinstalled SARS (latest version), reconfigued Reaper, played with the Windows properties for the SARS audio output (Windows does see these SARS outputs AND inputs as soon as I launch Reaper and when I close Reaper, these disappear from Windows so Windows IS seeing it.

So frustrating as I use this a LOT and never make changes to the configuration that worked the day before and it just stops working. Has anyone else ever experienced this? Do you have any suggestions I can try? There are no wrong answers, just people helping people. Thank you in advance for your help.

indiamcq commented 3 years ago

I was not able to use SAR with Jack until using another program (Ardour) which supports opening ASIO driver configuration panels. The problem was that SAR was never configured. After using another program to configure SAR, Jack plays with SAR just fine.

I found this utility helped me see and configure some ASIO tools on Windwos 10: https://sourceforge.net/projects/asiocpl/

MPeti1 commented 3 years ago

Until earlier today I had the same problem as the issue creator. By now I managed to make it working (sort of, more on it beloew).

First of all, asiocpl and such is good, but these won't add the audio endpoints to the system, they just maintain a configuration file in %APPDATA%\SynchronousAudioRouter\default.json. To make the endpoints appear, you need to use an ASIO client (is this the good term?) that will initialize the SAR ASIO server (again, is this the good term, or did these just stick to me from JACK? From now on I'll assume it is). Such cleants are DAWs like Reaper, and also JACK, which can be managed with QjackCtl (packed in JACK Windows installer) or Catia or a few other managers. With any client you want to use, you need to set it up so it will use the SAR audio server. In QjackCtl, this happens in the setup->settings\parameters\interface, which you should change to ASIO::SynchronousAudioRouter, then OK and Start, or in Reaper, it's Toolbar->Options\Preferences\Device, audio system to ASIO and ASIO Driver to SynchronousAudioRouter, then additionally also select the range from the dropdowns (both for placback and recording) which ones to open up, but here you don't need to press "start", because it (re)connects as soon as you close the ASIO config dialog. In my very fresh so possibly wrong experience QjackCtl (or JACK itself, who knows) automatically opens up all channels, whether there is a configuration for that I don't know, but Setup->Settings\Advanced has some settings that might be it. If you received erros here, read the last pharagraph.

As I haven't used Reaper anymore, I can't say much more about it, but in QjackCtl's Graph window, after starting the JACK server, I was able to see all the playback devices per channel, and also in the Sound window (mmsys.cpl). With this graph window you can make connections between playback and capture devices, and so you already achieved what Virtual Audio CAble from vb-audio can do, just without any limits. (except hardware limits, now only they apply).

Probably that's known among the earlier adopters, but it's not easy to find so I document it here: in the last signed version of SAR (0.13.1), there's a deadlock bug that will cause any ASIO clients and other software that deals with audio endpoints on the system to stop responding. This also means that any such software will hang around until you restart the system, because even with PsKill with SYSTEM privileges, you won't be able to stop them. This bug is triggered if an ASIO client tries to disconnect from SAR. With QjackCtl this happens when you stop the JACK server, and in the case of Reaper it can happen a lot earlier, because as I mentioned earlier going into the ASIO config dialog and changing settings will make Reaper to reconnect to SAR, which is a disconnect, and then a reconnect, of course.

There is also another bug in that version that breaks autodetecting changes to the SAR config file, which means that if you added or removed endpoints while SAR was being used by something, it won't detect the changes (or in a better case it does but very slowly, under a few minutes time). With these 2 bugs coupled you must deal with the settings very carefully in production, because you can crash your sound system very easily. But as I read here and on the discord chat, these have been fixed in 1.13.2

To the dev: I did not wanted to whine about bugs in the older version, I just waned to collect my findings here so if someone finds it, they may spend less time on setting up SAR :)

Also, for anyone wondering about the signing problem: no, you can't sign the driver yourself. In the case of Windows 10, it's hardcoded (as far as I know, feel free to fix me if I'm wrong) into the system that the driver signature's sig chain's root cert should be a specific one from microsoft, and it's very unlikely that anyone will every obtain that.

If you had problems with Reaper or JACK when setting the interface to SAR: Although my sound hardware had a Realtek ASIO driver by default (by this I mean even before I started setting up this new audio system, probably from the official drivers for my motherboard), I needed to install ASIO4ALL because with the realtek ASIO interface SAR just wouldn't work, because Reaper would throw me with errors all the time, not speaking about JACK being unable to start. By installing ASIO4ALL 2, and setting that as the hardware device for SAR, it started coming together: Reaper was able to use the SAR audio interface and the endpoints I set up in SAR's configurator appeared in the Windows Sound menu. From that on I was also able to connect to SAR with JACK, as I described above.