Linking library with Visual Studio

148 views
Skip to first unread message

Daniel Lagula

unread,
Nov 13, 2019, 9:40:20 AM11/13/19
to SoLoud audio engine
Hello! This audio engine looks great and features pretty much everything I require for our game project (mp3/ogg support, low/high-pass filters) but I have trouble linking the library to our Visual Studio project. I'd love to get some guidance on how to properly do the linkage, or even the "lazy way" when you just add all of the sources to the project. Thank you for your time!

What I have tried: 
- Running the genie.lua file using Lua53 and typing in windows powershell ".\lua53.exe genie.lua --with-sdl --with-tools vs2019" and what I get is an error that sais:

attempt to call a nil value (field 'is')
stack traceback:
        genie.lua:17: in main chunk
        [C]: in ?

- I have also tried to just copy the "src" and "include" folders to my project and include the "include" folder in Visual Studio under "Properties > C/C++ > General > Additional Include Directories". This makes the project find all of the .h/.cpp files but gives linker errors when trying to compile the program (LNK2019 unresolved external symbol "public: __cdecl SoLoud::Soloud::). 

Philip Bennefall

unread,
Nov 13, 2019, 10:05:12 AM11/13/19
to Daniel Lagula, SoLoud audio engine

Hi Daniel,

First, I am not the author of SoLoud - I am just a regular user and I build SoLoud the lazy way.

It sounds like it is not finding the SoLoud class itself. For a minimal installation of SoLoud, aside from showing the compiler where the headers are which you've already done, I have to add all source files in the core directory, at least one audio source (I only use the one called wav), and at least one backend (I wrote my own because I had issues with all the ones provided for Windows). Of course, if you want the biquad filter you'll need to add that as well. If you need the exact list of files, I can give you my setup.

Kind regards,

Philip Bennefall

--
You received this message because you are subscribed to the Google Groups "SoLoud audio engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to soloud+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/soloud/bfd770b5-8144-488d-9dbb-e064dc0187c7%40googlegroups.com.

Daniel Lagula

unread,
Nov 14, 2019, 6:16:47 AM11/14/19
to SoLoud audio engine
Thank you for the reply!
I believe I now figured out how to properly link SoLoud the lazy way but now I have trouble linking one of the backends :/
I've tried to use winmm and even though I have included it pretty much everywhere in my project it gives another linking error with winmm. 
(LNK2019 unresolved external symbol "unsigned int __cdecl SoLoud::winmm_init(class SoLoud::Soloud *,unsigned int,unsigned int,unsigned int,unsigned int)" (?winmm_init@SoLoud@@YAIPEAVSoloud@1@IIII@Z) referenced in function "public: unsigned int __cdecl)

What I did was to just find a winmm.lib file and winmm.dll file which I found somewhere in my windows folders, and then added them to the core directory.

Every location that I have tried to link it:
Configuration Properties > VC++ Directories > Include Directories,
Configuration Properties > VC++ Directories > Library Directories,
Configuration Properties > C/C++ > General > Additional Include Directories
Configuration Properties > Linker > General > Additional Library Directories
Configuration Properties > Linker > Input > Additional Dependencies

Philip Bennefall

unread,
Nov 14, 2019, 8:45:39 AM11/14/19
to SoLoud audio engine

I recommend that you stay as far away from Winmm as you possibly can. WaveOut, which is what Winmm exposes, is a very old interface from the days of Windows 95 and usually introduces *at least* 200 milliseconds of latency. Go for Wasapi, hands down. If you need to support Windows XP for whatever reason, have DirectSound as a fallback.


Are you adding the source file from the backend folder to the project, not just the header? Your linker error indicates that it's not there.


Kind regards,


Philip Bennefall

--
You received this message because you are subscribed to the Google Groups "SoLoud audio engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to soloud+un...@googlegroups.com.

Daniel Lagula

unread,
Nov 14, 2019, 1:03:32 PM11/14/19
to SoLoud audio engine
The same second I finally got it to work with Winmm you posted your reply :p
And as you said, the sound seems to be a tiny bit delayed and multiple sounds played at the same frame seems to only play the first one. 
Dont know if this is an issue with Winmm or if it's a parameter/function I have to use in SoLoud. (Soloud.playClocked() seemed like it but didn't fix the issue)
As with Wasapi, I dont really understand how to include it to the project. Is it the same as with winmm (that you just include the winmm.lib file) or is there something more I have to include?
Thank you once again for your reply!

The error I get when trying to use Wasapi (in StopVoice() in soloud_core_voiceops.cpp):

Exception thrown: read access violation.
this->**mResampleDataOwner** was 0x111011101110112.

Philip Bennefall

unread,
Nov 14, 2019, 1:29:44 PM11/14/19
to SoLoud audio engine

An access violation in the resampler should have nothing to do with Wasapi as far as I can see. Jari will have to comment on this one.


Kind regards,


Philip Bennefall

--
You received this message because you are subscribed to the Google Groups "SoLoud audio engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to soloud+un...@googlegroups.com.

Jari Komppa

unread,
Nov 14, 2019, 1:33:05 PM11/14/19
to SoLoud audio engine
I'd need to see more of the code to make an educated guess. Does this happen during teardown? Could be some out of order deallocation thing?

Daniel Lagula

unread,
Nov 15, 2019, 5:13:37 AM11/15/19
to SoLoud audio engine
The soloud.init() function works without any errors, and loading and playing a sound works without crashing, but there is no sound playing (can't hear the sound). 
Then if I try to play a second sound using the same SoLoud::Wav sample it crashes with the same error at StopVoice() in soloud_core_voiceops.cpp 
(Exception thrown: read access violation. this->**mResampleDataOwner** was 0x111011101110112.)

There is also an issue where the program crashes with the exact same error if no sound device exists/is plugged into the computer (have only been able to test this using winmm).

Daniel Lagula

unread,
Nov 19, 2019, 5:26:53 AM11/19/19
to SoLoud audio engine
Ok I finally got it to work using xaudio2 but still have an issue where rapid audio wont be played accurately. 
I've tried using both play() and playClocked() by sending deltaTime into the first parameter but to no success. 
The way it sounds now when playing fast successive audio is that it sounds like there is a maximum speed that the audio can be played.
When using the playClocked() it just makes certain sounds sound slightly delayed but most of them still gets played similar to that max play speed.

I also get memory leaks which scales with the amount of voices, which seems a bit weird since I use deinit().
I've tried to manually call the deinit function after the main gameloop, and I've tried to delete soloud, but to no success.

Jari Komppa

unread,
Nov 19, 2019, 5:30:49 AM11/19/19
to Daniel Lagula, SoLoud audio engine
The audio is always sent to the backends in chunks, and the chunk size depends on the backend. So yes, there's a speed limit on how often a sound can start. The clocked version adds a delay so while you got latency, the relative time between the sounds starting exists (to avoid the same sample being played 5 times over itself in a shmup, for example).

--
You received this message because you are subscribed to the Google Groups "SoLoud audio engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to soloud+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages