0
0

Hi, when I have my Oscilliscope unit running it seems like the data is being displayed offset by maybe 20 ms. I will start the song and about 20 ms before there is any sound coming through I will get data from the Scope unit. How do I sync my oscilliscope with the sound output???

  • You must to post comments
0
0

Well, after looking at the C++ code I found out that I need to buffer the data. What I did was, in my callback I set it up to hold the current block in a variable called ScopeBlock. Then in my plotting function I used that to create an offset value which would be the offset of the oscilliscope so that it would display according to the audible music. Now, I cant figure out how to buffer the data using the offset. Heres my code:

Callback:
[code:2u8lqnsq]
Public Function ScopeCallback(ByVal originalbuffer As Long, ByVal newbuffer As Long, ByVal length As Integer, ByVal param As Integer) As Long

TotalBlocks = FSOUND_DSP_GetBufferLengthTotal() / FSOUND_DSP_GetBufferLength()

ScopeBlock = ScopeBlock + 1
If ScopeBlock >= TotalBlocks Then
    ScopeBlock = 0
End If

RealtimeBuf = originalbuffer
ScopeCallback = newbuffer

End Function
[/code:2u8lqnsq]
Plotting of the oscilliscope:
[code:2u8lqnsq]
Public Sub Vis_DisplayScope()

On Error Resume Next
Dim Mixer As Integer
Dim X As Integer
Dim offset As Long
Dim SrcInt() As Integer
Dim SrcFPU() As Single
Dim Step As Long

Mixer = Settings.MixerType

frmMain.picVisuals.Cls

offset = (ScopeBlock + 1) * FSOUND_DSP_GetBufferLength()
If (offset >= FSOUND_DSP_GetBufferLengthTotal()) Then
    offset = offset - FSOUND_DSP_GetBufferLengthTotal()
End If

Step = FSOUND_DSP_GetBufferLength() / frmMain.picVisuals.Width

ReDim SrcInt(offset)
ReDim SrcFPU(offset)

If Mixer <> 0 Then 'MMX P5/6
    GetScopeINT SrcInt
    For X = 0 To frmMain.picVisuals.Width

        LineTo frmMain.picVisuals.hdc, X, (SrcInt(X + Step) + 32768) / 65536 * frmMain.picVisuals.Height

    Next X
Else 'FPU
    GetScopeFPU SrcFPU
    For X = 0 To frmMain.picVisuals.Width

        LineTo frmMain.picVisuals.hdc, X, (SrcFPU(X + Step) + 32768) / 65536 * frmMain.picVisuals.Height

    Next X
End If

frmMain.picVisuals.Refresh

On Error GoTo 0

End Sub
[/code:2u8lqnsq]
I hope somebody can help!

  • You must to post comments
0
0

Ok, I took this from the documentation.

[quote:6ekb1qvk]
If you are thinking of plotting the data to sync with the audible output, it is wise to buffer the data in a circular buffer, for the number of samples specified by FSOUND_DSP_GetBufferLengthTotal. This length is divisible by the DSP callback length (always a multiple of 25ms).
From this point then you would plot the block of data preceeding the one you are filling, which is the one playing at that point in time!
See the FMOD example in the /samples/fmod directory for source code that does this, and many other examples of DSP processing.
[/quote:6ekb1qvk]

How do I buffer the data in a circular buffer in VB??

  • You must to post comments
0
0

Someone should be able to tell me something about this, lol. 😀 Anybody?

  • You must to post comments
0
0

Here you ll find a class for manipulating data inside a circular buffer, hope it ll help you :

http://www.wheelmud.org/ftproot/downloa … ctures.zip

  • You must to post comments
0
0

Hey, thanks!! That works perfectly, now my inly problem is speed, if I can get it to display faster without any lag than it will be finished!! Thanks again.

  • You must to post comments
0
0

Very good idea! What you want to make is incorporate in some way what a “FSOUND_DSP_ACCURATE” would call, making that the unit DSP reads data later.

Now then, I propose the opposite. That it would happen if I wanted to have those data 3 or 4 seconds before listening the sound. It would be appropriate to create a waveform that leaves creating in advance. This without increasing the FSOUND mix buffer for not increasing the latency.

The idea would be to put a buffer before Fmod.
He would have to take, for example, the value of FSOUND_Stream_GetPosition, to determine in what place of the file Fmod is, to this to add him the equivalent of 4,1 seconds (4 seconds + 100 milisecons of the buffer, position where would read the buffer) and read the data ahead +/- 3 seconds of Fmod. These data would be passed the DSP.

The problem is that I don’t believe that can make because it would be necessary to break the chain of the system DSP unit. Although if you can put back the process of DSP, perhaps it can be ahead…

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.