-
February 8th, 2013, 10:41 AM
#1
Help! VB6 with DirectSound8 jumps out of sub just before setting BufferBytes.
I am trying to use DirectSound8 to play the interference wave between two sinusoidal tones, 110 and 111 Hz. I would like to record 2.0 seconds worth of this sound, sampled at 11025 samples per second. To do so, I try to set lBufferBytes to the number of samples with the following code:
Dim BB As Long
BB = CLng((intSmpl - intShift) * DsDesc.fxFormat.nBlockAlign)
DsDesc.lBufferBytes = BB
However, the line BB = CLng... never executes. VB6 just jumps out of the sub.
The value of DsDesc.fxFormat.nBlockAlign is 4.
The value of (intSmpl -intShift) is 22050.
Any ideas?
-
February 8th, 2013, 02:49 PM
#2
Re: Help! VB6 with DirectSound8 jumps out of sub just before setting BufferBytes.
I just answered my own question.
The line
BB = CLng((intSmpl - intShift) * DsDesc.fxFormat.nBlockAlign)
should be:
BB = CLng(intSmpl - intShift) *CLng( DsDesc.fxFormat.nBlockAlign)
Then vb6 does not jump out of the subroutine.
This same multiplication of CLng * CLng is also needed in the following WriteBuffer statement:
DSBuffer.WriteBuffer _
0, _
CLng(intSmpl - intShift) * CLng(DsDesc.fxFormat.nBlockAlign), _
stereoBuf(0).intLeft, _
DSBLOCK_DEFAULT
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|