i am currently writing a script mod for Grand Theft Auto IV using Scripthook C++.
I have been playing audio files by using this template: Simple C++ MP3 Player Class
My problem starts by attempting to use files from resource.
I have no idea how to load them.
Every time i tried to load sound from resource using my code, game crashed.
Already spend hours browsing google about how to play DirectShow audio from resource without any result.
Inside resource files:
(resource.h) #define WAV_Sound 106
(resource.rc) WAV_Sound RCDATA "MySound.wav"
Loading files from HDD is working fine
Load(TEXT("MySound.wav"));
But game crashes when i try one of this:
// Load from resource #1
LPCWSTR file = MAKEINTRESOURCE(WAV_Sound);
Load(file);
// Load from resource #2
Load((LPCWSTR) WAV_Sound);
Hope someone can help me out, thanks !
Microsoft recommended using DirectX Audio to provides multilayer interfaces for developing game, namely XAudio2, X3DAudio, XACT, … etc, they are very powerful to process sound effect in 2d/3d game environment. Here is the link http://msdn.microsoft.com/en-us/library/ee415737%28v=vs.85%29
Please download and install the DirectX software development kit, and find the ‘XAudio2BasicSound’ example to open wave file from file or in resource or in dll and playback with IXAudio2 interface, it was very simple example but next step you can add sound effect to your game.