DirectSoundBuffer8 how to get buffer size?

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

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 on other sites
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 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 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 on other sites
Quote:
 Original post by PromitYou 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...

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 14
• Forum Statistics

• Total Topics
632155
• Total Posts
3004477

×