Jump to content
  • Advertisement
Sign in to follow this  
Golgari

Problem with reading wav files into a DSound buffer

This topic is 4316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, at first I wrote a class for all the DirectSound inizialisation and buffer creation. Then I also wrote a function to load a RIFF file in wave format. I had no problems with reading the header and fmt sub-chunks. I use fread() to read the sound data into a BYTE* array and there are no errors from the compiler. The problem is that I can't allocate the memory for the Array variable. I use the new operator to allocate the memory: WaveFileData.soundbuffer = new BYTE[WaveFileData.data_size]; //sprintf(str,"Datasize %d",WaveFileData.data_size); //MessageBox(hwnd,str,"CAP",MB_OK); if(WaveFileData.soundbuffer==NULL) { MessageBox(hwnd,"mem alloc failed","CAP",MB_OK); return false; } else { fread(WaveFileData.soundbuffer, sizeof(BYTE), WaveFileData.data_size, soundfile); } I use a structure(WaveFileData) to hold the header information and the sound data (lpbysoundbuffer) before I copy the data into a DirectSound buffer. I got no compiler errors so far. When I verify the Array if(lpbsoundbuffer==NULL) it is always NULL and I can't proceed with loading the data to the Soundbuffer. I used the same method to read and load a 24 bit bitmap file and it works fine. I've checked the size of the sound data also ... it runs but not like it should. And is there any harm if I call the "delete" not in the same function as the "new" (but in the same class of course)? It is a DirectSound problem so I think this is the best place to ask, else feel free to put it in the right section. [Edited by - Golgari on September 29, 2006 4:02:49 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!