I'm trying to integrate SoundTouch (https://www.surina.net/soundtouch/) as a shared library into a cross-platform Qt app. The version in the Ubuntu repos seems to provide a C++ interface like this:
this->soundTouchHandle = new SoundTouch();
this->soundTouchHandle->setSampleRate(44100);
this->soundTouchHandle->setChannels(2);
this->soundTouchHandle->setSetting(SETTING_USE_AA_FILTER, 1);
this->soundTouchHandle->setPitch(this->pitchScalingFactor);
But it seems like the normal way to use it on Windows is through the SoundTouchDLL C wrapper (which provides the __cdecl
exports):
this->soundTouchHandle = soundtouch_createInstance();
soundtouch_setSampleRate(this->soundTouchHandle, 44100);
soundtouch_setChannels(this->soundTouchHandle, 2);
soundtouch_setSetting(this->soundTouchHandle, SETTING_USE_AA_FILTER, 1);
soundtouch_setPitch(this->soundTouchHandle, this->pitchScalingFactor);
If I understand correctly, Linux doesn't need the __cdecl
annotations, the C-based SoundTouchDLL interface is specifically for windows. SoundTouchDLL.h clearly contains windows-specific code (e.g. #include <windows.h>
). On the other hand, the core C++ SoundTouch library doesn't include annotations for exporting any symbols with __cdecl
, so it can't be used as a shared library (DLL) on Windows, the C interface is required.
Have I understood this correctly? Is it really normal to use the C API for SoundTouch on Windows, but use the C++ API on Linux? Is there any way to use the same API on both platforms (preferably without having to modify SoundTouch)?