🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.csharpbuilder.multimedia
1 messages
1 total messages Started by Joe Gabriele Sat, 22 Apr 2006 03:47
Playing Audio from a memory array
#10
Author: Joe Gabriele
Date: Sat, 22 Apr 2006 03:47
37 lines
2125 bytes
Hi,

Is there a way to use DirectSound to create a SecondaryBuffer from a WAV 
file stored in memory?

I can create a wave file, write it to the hard drive and then play it back 
with DirectSound by first creating the buffer : sound = new 
SecondaryBuffer("\\test.wav",bDesc,sndDevice)  and then using the sound.Play 
method send it to the sound card.

What I want to do is create the wave file in memory and then create the 
SecondaryBuffer from that memory stream. I can successfully create the wave 
file in memory as follows:

MemoryStream stream = new MemoryStream();

I then use the stream.Write method to load the various part of the wave file 
(header info and data);

I finally transfer the stream to a byte array (though I don't know if this 
is necessary):

byte[] snd = stream.GetBuffer();

When I try to create the SecondaryBuffer to play the sound,

sound = new SecondaryBuffer(snd,dSound) or sound = new 
SecondaryBuffer(snd,fileSize,dSound);

it crashes. I know that the array snd has all the proper information as I 
can view it as it's being populated.

Any help would be greatly appreciated.

Thanks.

Joe Gabriele 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads