0
0

Hi there.

I’m working for hours for a scope, but without success.
What do I wrong?

Here my piece of code:

=================
Private Sub Command1_Click()
‘switch the scope ON

ReDim sngScopeData(0 To FSOUND_DSP_GetBufferLength) As Single
lngScopeUnit = FSOUND_DSP_Create(AddressOf ScopeCallback, SOUND_DSP_DEFAULTPRIORITY_MUSICUNIT, 0)

FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, True
FSOUND_DSP_SetActive lngScopeUnit, True

tmrSpec.Enabled = True

End Sub

=================
Private Sub tmrSpec_TIMER()

Dim intX As Integer
GetScopeFPU sngScopeData

picSpec.CurrentY = picSpec.ScaleHeight / 2
picSpec.CurrentX = 0

For intX = 0 To UBound(sngScopeData) / 16

lngVal = intX * (picSpec.ScaleWidth / (UBound(sngScopeData) / 16)) * 3
picSpec.Line (picSpec.CurrentX, picSpec.CurrentY)-(lngVal, picSpec.ScaleHeight / 2) + Val(sngScopeData(intX * 16)) * (picSpec.ScaleHeight / 100000)), vbBlue

Next intX

End Sub

=====================
Public Function GetScopeFPU(ByRef Scope() As Single)
On Error Resume Next
Dim nrOfVals As Long

If UBound(Scope) > 1023 Then nrOfVals = 1024 Else nrOfVals = UBound(Scope) + 1

If (lngScopeBuffer = 0) Then Exit Function
CopyMemory Scope(0), ByVal lngScopeBuffer, nrOfVals * 4

End Function

=====================
Public Function ScopeCallback(ByVal originalbuffer As Long, ByVal newbuffer As Long, ByVal length As Long, ByVal param As Long) As Long
On Error Resume Next

lngScopeBuffer = newbuffer
ScopeCallback = newbuffer

End Function

  • You must to post comments
0
0

what is the problem that you are having? does the code not compile/crash/show no scope etc..

  • You must to post comments
0
0

The function “GetScopeFPU” returns an array with too low values.
For ex.:
-4,23454E+37
-3,87633E+34
5,26372E-34
2,97366E-35

Or the array contains values like: “-1,#QNAN”

This value causes a runtime error.
Any idea, where the problem is?

Thanx

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.