Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: Stonemonkey on May 15, 2007
-
Is it possible to play raw audio data stored in memory using the winapi?
Cheers,
Fryer.
-
If you are looking for playing wave files, I know one way to play it from memory using playsound:
//Play our sound
PlaySound( (const char *)soundData, NULL, SND_MEMORY);
Where "soundData" is your .wav file converted to C array buffer, something like this:
static unsigned char soundData[] = {
0x00,0x50,0x00,0x20,0x00,0x78,0x00,0x20,0x00,.....
...
...
};
-
If your data really is raw data without a header, you can use waveOut* functions. Check out the gm.dls code here http://dbfinteractive.com/index.php?topic=1702.0 (http://dbfinteractive.com/index.php?topic=1702.0) for a sample of how to do that.
Or if you want something different, you can use DirectSound http://dbfinteractive.com/index.php?topic=1540.0 (http://dbfinteractive.com/index.php?topic=1540.0)
Jim
-
Ah, good stuff. Thanks Jim and rbraz.