Hi,
I'm trying to stream a wave with PrepareStreamingWave() but im not sure what all the entries in the WAVEBANKENTRY struct should be and I can't find any help anywhere.
The XACTCodeDriven sample doesnt give proper values as they're all hard coded, I'm getting data from the wave and filling the struct with these only im not sure what they all should be. I'm finding that waves don't play till the end.
i'll compare the sample with my own. I'm getting the values by filling out a WAVEFORMATEX with the wave's details and then putting them into the WAVEBANKENTRY.
sample
DWORD dwBlockAlign = dwChannels * dwBits / 8;
DWORD dwTotalNumBytes = dwSeconds * dwSampleRate * dwBlockAlign;
// Initialize WAVEBANKENTRY struct
WAVEBANKENTRY entry;
entry.Format.wFormatTag = WAVEBANKMINIFORMAT_TAG_PCM;
entry.Format.wBitsPerSample = ( dwBits == 16 ) ? WAVEBANKMINIFORMAT_BITDEPTH_16 : WAVEBANKMINIFORMAT_BITDEPTH_8;
entry.Format.nChannels = dwChannels;
entry.Format.wBlockAlign = dwChannels * ( dwBits / 8 );
entry.Format.nSamplesPerSec = dwSampleRate;
entry.Duration = dwSeconds * dwSampleRate;
entry.LoopRegion.dwStartSample = 0;
entry.LoopRegion.dwTotalSamples = 0;
entry.PlayRegion.dwOffset = 0;
entry.PlayRegion.dwLength = dwTotalNumBytes;
entry.dwFlags = 0;
my own
m_pwfx is the waveformatex
DWORD dwBlockAlign = m_pwfx->nChannels * m_pwfx->wBitsPerSample / 8;
DWORD dwTotalNumBytes = m_pwfx->wBitsPerSample/2/*m_pwfx->nBlockAlign*/ * m_pwfx->nSamplesPerSec * dwBlockAlign;
//Initialize WAVEBANKENTRY struct
WAVEBANKENTRY entry;
entry.Format.wFormatTag = WAVEBANKMINIFORMAT_TAG_PCM;
entry.Format.wBitsPerSample = ( m_pwfx->wBitsPerSample == 16 ) ? WAVEBANKMINIFORMAT_BITDEPTH_16 : WAVEBANKMINIFORMAT_BITDEPTH_8;
entry.Format.nChannels = m_pwfx->nChannels;
entry.Format.wBlockAlign = m_pwfx->nChannels * ( m_pwfx->wBitsPerSample / 8 );
entry.Format.nSamplesPerSec = m_pwfx->nSamplesPerSec;
entry.Duration = (m_pwfx->wBitsPerSample/2) * m_pwfx->nSamplesPerSec;
entry.LoopRegion.dwStartSample = 0;
entry.LoopRegion.dwTotalSamples = 0;
entry.PlayRegion.dwOffset = 0;
entry.PlayRegion.dwLength = dwTotalNumBytes;
entry.dwFlags = 0;
I think what i'm getting wrong is the dwTotalNumBytes and the entry.Duration values. This is because the sample gives dwSeconds a hard coded value of 8, however when i loaded in the same wave file into my own game and looked at the WAVEFORMATEX values after they'd been filled in, nothing had the value of 8 so i have no idea where they've got that value from.
The reason I tried m_pwfx->wBitsPerSample/2 is because wBitsPerSample was 16 which obviously gives the total, 8.
This worked out fine however with any other wave files it doesnt, they get cut off part way through and so obviously this value is still incorrect.
If anyone knows what these values mean and can tell me what to use, I'd appreciate the help.
Thanks