Jump to content
  • Advertisement
Sign in to follow this  

DirectSoundBuffer8 how to get buffer size?

This topic is 3718 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

I'm writing a simple audio player, I can play a WAV file and I'm now trying to program the slider control to control to position of the sound buffer. I can GetCurrentPosition of the buffer and set that as the slider position, but how do I get the full size of the buffer so I have a MAX value for the slider control? I know it is something ridiculous because just a second of playing my sound the position is at about 100,000 in terms of the slider range.
	nD8BufP->GetCurrentPosition(&plgC,NULL);
	m_Slider.SetRange(Min, Max);
	m_Slider.SetPos(plgC);
I hope that makes sense

Share this post


Link to post
Share on other sites
Advertisement
Can't you keep track of the buffer size when you create the buffer? As far as I can see, there's no GetBufferDesc function or similar in either IDirectSoundBuffer or IDirectSoundBuffer8...

Share this post


Link to post
Share on other sites
The answer is, "Whatever you made it". If the sound sample is two seconds long at 11,025 Hz, single track (mono), and 8-bits per sample then your buffer's size in bytes is all of that multiplied together (make sure to convert 8 bitsPerSec to 1 bytePerSec).

If you are looking for the length of a song it should not be the same size as the buffer! The buffer should only be big enough to hold a few seconds worth of data while you program continues to stream more in as it's played. Just figure out how big the song is with the above information and the given info in the file header. On a side note, I imagine many compressed formats give the total time in the initial header otherwise you would have to parse then entire file to figure it out.



Share this post


Link to post
Share on other sites
You guys are blind. It's in the DSBCAPS structure returned by GetCaps. You can use the sample rate of the buffer and the size to figure out the length of the buffer in human time.

[Edited by - Promit on March 17, 2008 9:14:35 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
You guys are blind. It's in the DSBCAPS structure returned by GetCaps. You can use the sample rate of the buffer and the size to figure out the length of the buffer in human time.
Ah ha... The name "GetCaps" threw me off; it's not just caps - it looks exactly like the sort of information you'd get from a GetBufferDesc() style function.

Oh well...

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!