• Welcome to Dark Bit Factory & Gravity.
 

playing sound using winapi?

Started by Stonemonkey, May 15, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Stonemonkey

Is it possible to play raw audio data stored in memory using the winapi?

Cheers,
Fryer.

Rbz

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,.....
...
...
};
Challenge Trophies Won:

Jim

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 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

Jim
Challenge Trophies Won:

Stonemonkey

Ah, good stuff. Thanks Jim and rbraz.