Hello.
This error gives me a headache, I have no idea what's causing it.
Ok, this is a program which uses DirectX8 (or, rather, its VB6 wrapper libraries) to playback/record sound.
Everything worked ok, I then decided to add a VU meter to visualize recording process.
I am using a couple of shapes whose size I'm setting dynamically according to the signal level.
Here's the code:
'dscBuf is a DX8 capture buffer
Dim aSample(2) as Integer
dscBuf.GetCurrentPosition capCURS 'retrieve current writing position in the buffer
readPtr = capCURS.lWrite - 8 'step back a couple of samples (16 bit stereo, each sample is 4 bytes)
If readPtr < 0 Then readPtr = 0 ' to avoid error
dscBuf.ReadBuffer readPtr, 4, aSample(0), DSCBLOCK_DEFAULT 'read 4 bytes into the buffer (should result in two integers)
sScale = (1035 / 32768) * 3 'calculate scale, mult by 3 to produce bigger VU level
If sScale * Abs(aSample(0)) > leftVU.Width Then leftVU.Width = sScale * Abs(aSample(0)) ' <<< OVERFLOW ERROR
'only apply new value if new value is larger than current VU value
'I have a timer routine which moves VU's down automatically (to simulate physical VU and make them look realistic)
Ok, now, this code is running fine on my machine. However, when the client runs it on their machine, he's
getting the Overflow Err #6. He has VB6 installed, so I asked him to run the code and he tells me the error occurs
on the line shown above.
It depends on signal level. If he records silence, it's fine. When he starts to sing into his mic, overflow occurs.
I gave a thorough analisys to this and I can't understand what's happening.
Is it possible that DX API puts some erroneous values into the array and when I'm trying to read them as integers an
error occurs?
It does not make sense. Wave format uses signed integers to represent sound levels. 0 is middle level, 32767 is loudest,
-32768 is quietest.
I cannot come up with any explanation. The only thing I can say is on my machine (Due to sound card configuration)
the level never reaches absolute max or absolute min, meaning max value never gets to 32767 and min never gets
to -32768. Level is somehow limited on my machine. On the clients machine, however, it's possible for the level to
reach absolute min and max...
So... Any ideas?
This is very urgent, I will be doing my own research, but if anyone suggest an explanation, or a work around or
just a lead to a working solution, I will grant the points to that person.
Thank you!
Regards,
- Jimmy
Start Free Trial