Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DirectSound and Stream problems

Status
Not open for further replies.

abcfantasy

Programmer
Jun 3, 2006
110
DK
Hi, I've got a problem when creating a new DirectSound.Buffer object.

Wave files are saved as streams in a resources file and the following works perfectly:

Code:
soundBuffer = new Microsoft.DirectX.DirectSound.Buffer( Resources.wav1, device );

However, midi files are saved as an array of bytes. I try to copy that array in a stream, and then create the buffer but am getting an ArgumentException (Value does not fall within the expected range).

Code:
MemoryStream stream = new MemoryStream( Resources.midi1 );
soundBuffer = new Microsoft.DirectX.DirectSound.Buffer( stream, device );

What am I doing wrong?

Any help is greatly appreciated
Thanks
Andrew

ABC -
 
Have you looked at the

Microsoft.DirectX.AudioVideoPlayback class? I found it significantly easier to use than direct buffers.
 
I think the problem is that DirectSound supports only wave files, although not sure about this.

So it seems the only way is to use the AudioVideoPlayback class and extract the midi from the resources file.

If anyone knows another way of playing the midi files without having to extract them, kindly share your knowledge.

Thanks

ABC -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top