0
0

I thought that I might make a simple VB Oscilliscope example, just because some people probably want to see an example of this without downloading my whole media player. ๐Ÿ˜€ Anyways, so if you’re interested than here’s the link:
[url:ifqkgcgk]http://members.aol.com/libertyed1986/oscexample2.zip[/url:ifqkgcgk]

  • You must to post comments
0
0

MemoryCopy’s have to be exact, so you have to make sure that you are never copying outside any boundaries.

Are you sure that the EchoBuff array, which doesn’t seem to be initialized here has the correct length and such?

  • You must to post comments
0
0

I re-wrote the functions convert VB arrays to pointers and I added new functions to convert pointers back into VB arrays. So you can use this to modify an array of data, then convert it back into a pointer and use the MixBuffer function to mix the DSP newbuffer with your altered buffer. Tell me if it works because I wrote it out quickly! ๐Ÿ˜€

Converting a pointer to VB array:
[code:u9htcg5w]
Public Function GetDataINT(ByVal Buffer As Long, ByRef IntBuffer() As Integer)

Dim nrOfVals As Long
If UBound(IntBuffer) > 1023 Then nrOfVals = 1024 Else nrOfVals = UBound(IntBuffer) + 1
CopyMemory IntBuffer(0), ByVal Buffer, nrOfVals * 2

End Function

Public Function GetDataFPU(ByVal Buffer As Long, ByRef FpuBuffer() As Single)

Dim nrOfVals As Long
If UBound(FpuBuffer) > 1023 Then nrOfVals = 1024 Else nrOfVals = UBound(FpuBuffer) + 1
CopyMemory FpuBuffer(0), ByVal Buffer, nrOfVals * 4

End Function
[/code:u9htcg5w]
Convert VB array to pointer:
[code:u9htcg5w]
Public Function SendDataINT(ByVal Buffer As Long, ByRef IntBuffer() As Integer)

Dim nrOfVals As Long
If UBound(IntBuffer) > 1023 Then nrOfVals = 1024 Else nrOfVals = UBound(IntBuffer) + 1
CopyMemory ByVal Buffer, IntBuffer(0), nrOfVals * 2

End Function

Public Function SendDataFPU(ByVal Buffer As Long, ByRef FpuBuffer() As Single)

Dim nrOfVals As Long
If UBound(FpuBuffer) > 1023 Then nrOfVals = 1024 Else nrOfVals = UBound(FpuBuffer) + 1
CopyMemory ByVal Buffer, FpuBuffer(0), nrOfVals * 4

End Function
[/code:u9htcg5w]

Peter: How did you alter the buffer??

  • You must to post comments
0
0

EchoBuff is a pointer to an array, and it is initialized. The memory copy’s are taken straight from the C example so they should be within the boundaries.

  • You must to post comments
0
0

Ok, I’ve come to the conclusion that my functions to convert VB arrays to pointers doesnt work! Does anyonw know what my mistake was??

edit: woops! I just reallized that I forgot to allocate memory for the pointer!

  • You must to post comments
0
0

[quote="Paranoid_Android":2f8p7ij8]Ok, I’ve come to the conclusion that my functions to convert VB arrays to pointers doesnt work! Does anyonw know what my mistake was??

edit: woops! I just reallized that I forgot to allocate memory for the pointer![/quote:2f8p7ij8]

You’re right I have changed it and it works now.
Also I’m still busy converting the DSP formulas to VB, the problem is that it is more difficult than I thirst thougt….

  • You must to post comments
0
0

It showed the main window, then crashed for me. It didn’t even give me time to click the “Open” button before crashing the entire VB IDE…

  • You must to post comments
0
0

What are the difficulties?? Yeah, converting C++ formulas to VB is a bit difficult, bit it can be done.

  • You must to post comments
0
0

Add this in the ShowScope sub :

[code:3ly1ftp0]
‘——————————-
Dim nch As Long

nch = FSOUND_GetChannelsPlaying
If (nch = 0) Then
    Exit Sub
End If

‘——————————-
‘set the total blocks
TotalBlocks = FSOUND_DSP_GetBufferLengthTotal / FSOUND_DSP_GetBufferLength
...

[/code:3ly1ftp0]

  • You must to post comments
0
0

Here is the DSP example I’ve made from Android’s scope code, it’s simple but it works :)

[url:rx30g5mp]http://www.home.zonnet.nl/hebels13/dspexample.zip[/url:rx30g5mp]

  • You must to post comments
0
0

Ok, I updated the zip. I didnt have any problems with it before so I dont know what the problem was for Bruce.

  • You must to post comments
0
0

Ok, I’ve changed the DSP example a bit, the sound runs trough the DSP engine, but no modifications are made to it.

Also if anyone can translate the DSP formulas from the C++ example to VB, please let me know because I can’t get it to work :(

Please note that the ReverseB and Echo functions are not yet working, this is mainly because the problem with the DSP formulas.

Here is the download:
[url:30zpwfs3]http://www.home.zonnet.nl/hebels13/dspexample.zip[/url:30zpwfs3]

Greets,

Peter Hebels

  • You must to post comments
0
0

Does the new zip work??

  • You must to post comments
0
0

If I copy the echo callback code directly from the C example and convert it to VB I get:
[code:20xavypy]
Function EchoCallback(ByVal originalbuffer As Long, ByVal newbuffer As Long, ByVal Length As Long, ByVal param As Long) As Long

ReDim VBEchoBuff(Length) As Integer

GetDataINT originalbuffer, VBEchoBuff

If (EchoOffset + Length > EchoLen) Then
    TailLen = EchoLen - EchoOffset
    StartLen = Length - TailLen

    SendDataINT EchoBuff, VBEchoBuff
    FSOUND_DSP_MixBuffers newbuffer, EchoBuff + (EchoOffset * 2), TailLen, 44100, 128, FSOUND_STEREOPAN, FSOUND_STEREO Or FSOUND_16BITS
    FSOUND_DSP_MixBuffers newbuffer + (TailLen * 2), EchoBuff, StartLen, 44100, 128, FSOUND_STEREOPAN, FSOUND_STEREO Or FSOUND_16BITS

    CopyMemory EchoBuff + (EchoOffset * 2), newbuffer, TailLen * 2
    CopyMemory EchoBuff, newbuffer + (TailLen * 2), StartLen * 2
Else
    FSOUND_DSP_MixBuffers newbuffer, EchoBuff + (EchoOffset * 2), Length, 44100, 128, FSOUND_STEREOPAN, FSOUND_STEREO Or FSOUND_16BITS
    CopyMemory EchoBuff + (EchoOffset * 2), newbuffer, Length * 2
End If

EchoOffset = EchoOffset + Length
If EchoOffset >= EchoLen Then
    EchoOffset = EchoOffset - EchoLen
End If

EchoCallback = newbuffer

End Function
[/code:20xavypy]
Which crashes the VB IDE… ๐Ÿ˜ก

  • You must to post comments
0
0

Yes Android, the Zip work fine… for me.

  • You must to post comments
0
0

Have you tried stepping through it in debug mode to see at which point it crashes, that would probably make it a bit easier to find the error.

  • You must to post comments
0
0

Well, I got a bit farther this time… I opened an MP3 and hit play, it started playing, then crashed. Nothing showed up in the vis window either–it stayed black the whole 2 seconds before it crashed.

By the way, the crash was in ntdll.dll, which on XP usually indicates a buffer overrun (i.e. writing past the end of a block of allocated memory) or another low-level memory access problem…

[b:2dlqqx9r]edit[/b:2dlqqx9r] Disregard, false alarm. I forgot about Windows searching the PATH variable first. I keep forgetting, I have my regular fmod.dll as part of my PATH, so Windows found that first. Yours uses the stdcall version of FMOD, so the two DLLs were very incompatible–and the mismatched calling conventions were causing the crash. When I compiled the app as an exe in the same dir as the stdcall fmod.dll, it worked fine. It’s nice; good job!

[b:2dlqqx9r]P.S.[/b:2dlqqx9r] The stdcall version of FMOD should be named fmodstd.dll and placed in the same distribution as the regular FMOD–this way both DLLs can coexist and I don’t have to deal with these annoying problems anymore.

  • You must to post comments
0
0

Yes, this doesnt work though, stepping through a callback using StdCall version of FMOD results in a crash of the IDE.

  • You must to post comments
0
0

Works Great!

PS: Did you already know you can add DSP effects to music with this, I was able to alter the sound output just by changing the buffer a little and using the ‘FSOUND_DSP_MixBuffers’ function on it.

Some results I got was a knackering sound, I am sure that if I copy the formulas from the C++ example to your Scope project I can add the same DSP effects.

Greets,

Peter Hebels

  • You must to post comments
0
0

Ok, I just tried bretts Idea, and the callback is crashing the IDE because of the MixBuffers routine and the CopyMemory function. Hmmm, Im going to mess around with it a bit to see if I can fix any bugs…

  • You must to post comments
0
0

Yeah, I’ve been trying to do some DSP effects, but I’m going to have to do some research on the mixbuffer routine first! ๐Ÿ˜€ Thanks for the good comments. If you alter my example to use the DSP effect formulas from the C++ example could you send me a copy to look at it?? But what I’m trying to do right now is to sync the scope with the audible music, because if you increase the buffersize the music being played will not sync with the scope, can anyone help me with this??

  • You must to post comments
Showing 20 results
Your Answer

Please first to submit.