PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.43k stars 296 forks source link

CMake ASIO::host not found #837

Open aparks5 opened 12 months ago

aparks5 commented 12 months ago

Summary

Why do I care?

Input latency with other drivers doesn't feel right for my application (processing guitar and mic input) compared with other apps like Max/Renoise/Ableton that select ASIO as the driver with my USB interface.

Environment

Repro

I believe ASIO::host is some kind of system wide installation of ASIOSDK that I haven't figured out how to do (that I think should be covered by the FindASIO CMake module, which logging tells me it should build this lib). Since vcpkg asiosdk is broken I guess I'm not building the right thing. IDK. Portaudio wants to link a lib named ASIO::host but it can't find it anywhere.

Thank you for any help, truly. I am deeply indebted to PortAudio for helping bring my DSP ideas to reality.

aparks5 commented 12 months ago

As an aside, I tried forcing WASAPI instead of MME and had much better results with input latency. I wouldn't consider this closed but I'm less frustrated knowing that other host api's could suit my needs. My braindead thought process was that 'well ASIO is the only thing that ever feels right in other software so my software should support it'. I'm sure Cmake is effing this up.

dechamps commented 12 months ago

For what it's worth, I would strongly recommend you do not use PortAudio's ASIO Host API if you can avoid it. Depending on the specific set of ASIO drivers the end user happens to have installed on their system, enabling ASIO support can make PortAudio initialization surprisingly slow, disruptive and crash-prone (among other potential problems), even if no ASIO devices are actually used. This is due to fundamental design limitations of the way PortAudio initialization works and is unlikely to ever be fixed. See #696.

WASAPI is a good alternative. If you really need to support ASIO, consider interfacing with the ASIO API directly.

aparks5 commented 12 months ago

@dechamps thank you for the quick reply.

in all honesty, my need is for low input latency, not for a particular host. WASAPI seems to do much better than MME and it is trivial to select as priority (although of course this could be exposed via user input):

int hostNr = Pa_GetHostApiCount();
std::vector<const PaHostApiInfo*> infoVertex;
for (int t = 0; t < hostNr; ++t) {
    infoVertex.push_back(Pa_GetHostApiInfo(t));
}

int inputIndex = Pa_GetDefaultInputDevice();
inputParameters.device = inputIndex;

// look for WASAPI host api device if we can find one
for (auto & item: infoVertex) {
    printf("host: %s\n", item -> name);
    if (item->type == paWASAPI) {
        inputIndex = item->defaultInputDevice;
        index = item->defaultOutputDevice;
        inputParameters.device = inputIndex;
        outputParameters.device = index;
    }
}
RossBencina commented 11 months ago

I would strongly recommend you do not use PortAudio's ASIO Host API if you can avoid it. Depending on the specific set of ASIO drivers the end user happens to have installed on their system, enabling ASIO support can make PortAudio initialization surprisingly slow, disruptive and crash-prone (among other potential problems), even if no ASIO devices are actually used. This is due to fundamental design limitations of the way PortAudio initialization works and is unlikely to ever be fixed. See https://github.com/PortAudio/portaudio/issues/696.

Well, it works fine if you actually do want to use ASIO and you have compiled PortAudio ASIO-only and you take care with the installed ASIO drivers. I agree that there are certainly users out there for which this is too hard.

RossBencina commented 11 months ago

ASIOSDK folders copied to correct locations, select asio sources and headers added to project

I'm not sure that the docs are up to date on that. Search for tickets about this. I remember complaining at one stage that someone changed how this worked without changing the docs (and FWIW I think the old SDK location should be supported, if for no other reason than backward compatibility).

RossBencina commented 11 months ago

I think this one:

518

But also:

731

dmitrykos commented 8 months ago

I checked this issue but can not reproduce it. ASIO dependency was downloaded successfully, PA library was built and tests were running as expected by using ASIO devices. I configured PA for ASIO via cmake-gui by specifying ASIO as backend (PA_USE_ASIO option).

In case of CMake configuration ASIO dependency is downloaded and unzipped into CMake build folder, so this process is quite well automated but requires Internet availability to succeed of course.

Here is CMake configuration log:

ASIO SDK NOT found
Downloading ASIO SDK... E:/SVN/audio/portaudio_git/cmake_build_mingw/asiosdk.zip
[download 100% complete]
Extracting ASIO SDK ZIP archive: E:/SVN/audio/portaudio_git/cmake_build_mingw/asiosdk.zip
Found ASIO SDK: E:/SVN/audio/portaudio_git/cmake_build_mingw/asiosdk_2.3.3_2019-06-14
Configuring done

Here is build log:

E:\SVN\audio\portaudio_git\cmake_build_mingw>gmake
Consolidate compiler generated dependencies of target PortAudio
[  0%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_allocation.c.obj
[  1%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_converters.c.obj
[  2%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_cpuload.c.obj
[  3%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_debugprint.c.obj
[  3%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_dither.c.obj
[  4%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_front.c.obj
[  5%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_process.c.obj
[  6%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_ringbuffer.c.obj
[  7%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_stream.c.obj
[  7%] Building C object CMakeFiles/PortAudio.dir/src/common/pa_trace.c.obj
[  8%] Building C object CMakeFiles/PortAudio.dir/src/os/win/pa_win_coinitialize.c.obj
[  9%] Building C object CMakeFiles/PortAudio.dir/src/os/win/pa_win_hostapis.c.obj
[ 10%] Building C object CMakeFiles/PortAudio.dir/src/os/win/pa_win_util.c.obj
[ 11%] Building C object CMakeFiles/PortAudio.dir/src/os/win/pa_win_version.c.obj
[ 11%] Building C object CMakeFiles/PortAudio.dir/src/os/win/pa_win_waveformat.c.obj
[ 12%] Building CXX object CMakeFiles/PortAudio.dir/src/hostapi/asio/pa_asio.cpp.obj
[ 13%] Building CXX object CMakeFiles/PortAudio.dir/src/hostapi/asio/iasiothiscallresolver.cpp.obj
[ 14%] Building CXX object CMakeFiles/PortAudio.dir/asiosdk_2.3.3_2019-06-14/common/asio.cpp.obj
[ 15%] Building CXX object CMakeFiles/PortAudio.dir/asiosdk_2.3.3_2019-06-14/host/asiodrivers.cpp.obj
[ 15%] Building CXX object CMakeFiles/PortAudio.dir/asiosdk_2.3.3_2019-06-14/host/pc/asiolist.cpp.obj
[ 16%] Linking CXX shared library libportaudio.dll

Running one of the tests which used ASIO device:

Half amplitude. Should sound like sine wave.
before paHostApiInitializers[0].
ASIO names[0]:ASIO4ALL v2
PaAsio_Initialize: drv:0 name = ASIO4ALL v2
PaAsio_Initialize: drv:0 inputChannels       = 2
PaAsio_Initialize: drv:0 outputChannels      = 2
PaAsio_Initialize: drv:0 bufferMinSize       = 64
PaAsio_Initialize: drv:0 bufferMaxSize       = 2048
PaAsio_Initialize: drv:0 bufferPreferredSize = 512
PaAsio_Initialize: drv:0 bufferGranularity   = 32
PaAsio_Initialize: drv:0 defaultSampleRate = 44100.000000
PaAsio_Initialize: drv:0 defaultLowInputLatency = 0.011610
PaAsio_Initialize: drv:0 defaultLowOutputLatency = 0.011610
PaAsio_Initialize: drv:0 defaultHighInputLatency = 0.046440
PaAsio_Initialize: drv:0 defaultHighOutputLatency = 0.046440
ASIO names[1]:XMOS USB Audio 2.0 ST 3066
Skipping ASIO device:XMOS USB Audio 2.0 ST 3066
after paHostApiInitializers[0].
ASIOCanSampleRate(44100.000000):0
ASIOGetSampleRate:44100.000000
No Need to change SR
PaAsioOpenStream: framesPerHostBuffer :1024
ASIO Output type:18ASIOSTInt32LSB
PaAsio : ASIO InputLatency = 1102 (24 ms), added buffProc:0 (0 ms)
PaAsio : ASIO OuputLatency = 1102 (24 ms), added buffProc:0 (0 ms)
CPULoad = 0.001048
TerminateHostApis in
TerminateHostApis out

I was testing with MinGW but the same succeeds when configuring PA for MSVC.

I think this ticket needs to be closed as false-positive, there must be misconfiguration on reporter's side.

RossBencina commented 7 months ago

@aparks5 sorry this got closed. Could you please check @dmitrykos diagnosis and let us know whether you're still having the issue.