Re: [VB6] DirectSound. -> TLB
Hi Anatoly,
Seems the method odl for IDirectSoundBuffer8:GetObjectInPath() is incorrect.
I need it to set the parameters for the effects.
The VB compiler tells me that userdefined types cannot be set ByVal This is due to the two CLSID parameters for this method.
Your ODL:
Code:
HRESULT _stdcall GetObjectInPath(
[in] DXGUID rguidObject,
[in] long dwIndex,
[in] DXGUID rguidInterface,
[out, retval] IUnknown** ppObject);
I guess it should be:
Code:
HRESULT _stdcall GetObjectInPath(
[in] DXGUID * rguidObject,
[in] long dwIndex,
[in] DXGUID * rguidInterface,
[out, retval] IUnknown** ppObject);
By the way: If you eventually have some time left it would be great if you'd add the several effect structures (DSFXParamEq, DSFXWavesReverb, ...) to dsvb.tlb. :)
Re: [VB6] DirectSound. -> TLB
Quote:
Originally Posted by
SaschaT
Hi Anatoly,
Seems the method odl for IDirectSoundBuffer8:GetObjectInPath() is incorrect.
I need it to set the parameters for the effects.
The VB compiler tells me that userdefined types cannot be set ByVal This is due to the two CLSID parameters for this method.
Your ODL:
Code:
HRESULT _stdcall GetObjectInPath(
[in] DXGUID rguidObject,
[in] long dwIndex,
[in] DXGUID rguidInterface,
[out, retval] IUnknown** ppObject);
I guess it should be:
Code:
HRESULT _stdcall GetObjectInPath(
[in] DXGUID * rguidObject,
[in] long dwIndex,
[in] DXGUID * rguidInterface,
[out, retval] IUnknown** ppObject);
By the way: If you eventually have some time left it would be great if you'd add the several effect structures (DSFXParamEq, DSFXWavesReverb, ...) to dsvb.tlb. :)
Thank you. I'll update soon.
1 Attachment(s)
Re: [VB6] DirectSound. -> TLB
Thank you. I'll update soon.
Hope you did not already begin that. I rewrote the odl myself.
I attach the tlb and the odl which I derived from yours but altered several things beneath adding the structures and interfaces for the effects. (E.g. removed any helpstrings).
I tested it and all effects work. At the moment having no time to upload a demo cause I am on vacation for the next three weeks.
So I'll do that later. (I have encapsulated your DS module and some code of the form into just one class. Two buffers can then be played and handled independantly using effects. In addition the two mp3s can be merged, faded together. Let's see...)
Cheers!
Re: [VB6] DirectSound. -> TLB
Just a short code snippet showing the principle before I leave here ยด....
Code:
Sub SetEQ(DSBuf As DSVBLib.IDirectSoundBuffer8)
Dim effdesc As DSVBLib.DSEFFECTDESC
Dim uidEff As DSVBLib.DXGUID
Dim uidAllEff As DSVBLib.DXGUID
Dim IUnkEffEQ As DSVBLib.IDirectSoundFXParamEq
Dim TEffEQ As DSVBLib.DSFXParamEq
Dim ret As Long
effdesc.dwSize = Len(effdesc)
effdesc.dwFlags = DSVBLib.DSFX_LOCSOFTWARE
DSBuf.Stop 'pause the buffer
IIDFromString StrPtr(DSVBLib.IID_All_Objects), uidAllEff
IIDFromString StrPtr(DSVBLib.CLSID_DSFX_STANDARD_PARAMEQ), effdesc.guidDSFXClass
IIDFromString StrPtr(DSVBLib.IID_IDirectSoundFXParamEq), uidEff
'Set effect on buffer:
DSBuf.SetFX 1, effdesc, ret
'Note: more effects could be set at once!
'effdesc then had to be an array of type DSEFFECTDESC
'Get the interface of the DMO effect object:
'(This is a search in the underlying filter graph)
Set IUnkEffEQ = DSBuf.GetObjectInPath(uidAllEff, 0&, uidEff)
'Note: Throws an automation error if something's wrong!
'(Look for the Err.Number in enum DSVBLib.DS_ERR)
If Not IUnkEffEQ Is Nothing Then
'Get the default parameters of the effect:
IUnkEffEQ.GetAllParameters TEffEQ
With TEffEQ
Debug.Print "EQ Params:", .fBandwidth, .fCenter, .fGain
'Change default params to kinda bass woofer
.fCenter = 150 'Hz
.fBandwidth = 8 'semitones
.fGain = 15 'full bandpass amplification; (range -15...15)
End With
'Set the altered params to the effect:
IUnkEffEQ.SetAllParameters TEffEQ
End If
'Play the paused buffer:
'effect change now takes place immediately resuming at last play position
DSBuf.Play 0, 0, 0
Set IUnkEffEQ = Nothing
End Sub
Bye!
4 Attachment(s)
Re: [VB6] DirectSound. -> TLB
Hi,
as annonced I attach my DirectSound demo here including the type library I created extending TheTricks one.
I had to split it in two files due to the upload limitations. So please first extract DSoundDemo.zip and then the contents of FurtherMP3s.zip into the subfolder \SampleMP3\ of the demo.
The project uses a single class cDirectSound derived from Anatolys class that doesn't need any other components except the type library. The main intent was to control the effect parameters and to play files in parallel.
Just start the project (ActiveX.exe) in the IDE. Looks like this:
Attachment 188221
1. is to play all the MP3 files in the sample folder
2. does the same but crossfades the songs
3. You can select an effect to apply to the song and set the available parameters. There is a control form for this to set the values. Here with the I3D-Reverb selected:
Attachment 188222
(The controls in this form are loaded at runtime according to the file effects.txt which alternatively could also be included in a resource file.)
4. A complete stack of effects can be applied to a playing file. Demo starts without effects and after 6 seconds they come in.
5. Effect parameters can be controlled at runtime. Use the slider to adjust the reverb time while playing the song in loop.
You can click Stop at every time.
mdlTestDS contains some routines that also demonstrate the usage of the class.
Another extention to the class is the implementation of IDirectSoundNotify. Just a demonstration on how to implement and use it. I didn't find many cases where it would be needed as it does not raise real events. Simple timer loops my be sufficient. (Maybe MsgWaitForMultipleObjectsEx should be used instead of WaitForMultipleObjects to generate events?)
I have not tested the whole thing extensively. The usercontrol for the sliders may have some bugs and the sequence of played files in the demo can interfere and end in a mess if you click the play buttons before every song ended. (Two DSound buffers are used in parallel!)
As for me I am using the class now in a DJing application.
Thanks, Anatoly , for your work!