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:
- Paranoid_Android asked 14 years ago
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.
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.
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??
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:
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
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
Convert VB array to pointer:
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
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
Peter: How did you alter the buffer??
[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….
Add this in the ShowScope sub :
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
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:
If I copy the echo callback code directly from the C example and convert it to VB I get:
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
Which crashes the VB IDE… 😡
Please login first to submit.