ACMDriverEnum
Publié : sam. 10/avr./2004 3:02
Pour ceux qui veulent bricoler avec le "Audio Compression Manager", un début de code permettant de lister les drivers disponibles :
Pour servir et valoir ce que de droit.
Code : Tout sélectionner
; ACMDRIVERENUM
#WAVE_FORMAT_ADPCM = 2
#WAVE_FORMAT_ALAW = 6
#WAVE_FORMAT_MULAW = 7
#WAVE_FORMAT_DVI_ADPCM = 17
#WAVE_FORMAT_G723_ADPCM = $0014
#WAVE_FORMAT_DIALOGIC_OKI_ADPCM = $0017
#WAVE_FORMAT_TRUESPEECH = $0022
#WAVE_FORMAT_GSM610 = $0031
#WAVE_FORMAT_G721_ADPCM = $0040 ;* Antex Electronics G.721 */
#WAVE_FORMAT_G728_CELP = $0041
#WAVE_FORMAT_MSG723 = $0042
#WAVE_FORMAT_MPEG = $0050 ;/* MPEG Layer 1,2 */
#WAVE_FORMAT_MPEGLAYER3 = $0055 ;/* MPEG Layer 3 (MP3)*/
#WAVE_FORMAT_VOXWARE = $0062
#WAVE_FORMAT_VOXWARE_BYTE_ALIGNED = $0069
#WAVE_FORMAT_VOXWARE_RT24 = $0074
#WAVE_FORMAT_VOXWARE_RT29 = $0075
#ACM_DRIVERENUMF_NOLOCAL = $40000000
#ACM_DRIVERENUMF_DISABLED = $80000000
;
#ACMDRIVERDETAILS_SHORTNAME_CHARS =32
#ACMDRIVERDETAILS_LONGNAME_CHARS =128
#ACMDRIVERDETAILS_COPYRIGHT_CHARS =80
#ACMDRIVERDETAILS_LICENSING_CHARS =128
#ACMDRIVERDETAILS_FEATURES_CHARS =512
;
#ACMFILTERDETAILS_FILTER_CHARS =128
#ACM_FILTERENUMF_DWFILTERTAG =$00010000
;
#ACMFORMATDETAILS_FORMAT_CHARS =128
#ACMFILTERTAGDETAILS_FILTERTAG_CHARS =48
;
#WAVE_FILTER_UNKNOWN = 0
#WAVE_FORMAT_UNKNOWN = 0
;
#ACMDRIVERDETAILS_SUPPORTF_CODEC =$00000001
#ACMDRIVERDETAILS_SUPPORTF_CONVERTER =$00000002
#ACMDRIVERDETAILS_SUPPORTF_FILTER =$00000004
#ACMDRIVERDETAILS_SUPPORTF_HARDWARE =$00000008
#ACMDRIVERDETAILS_SUPPORTF_ASYNC =$00000010
#ACMDRIVERDETAILS_SUPPORTF_LOCAL =$40000000
#ACMDRIVERDETAILS_SUPPORTF_DISABLED =$80000000
;
#ACM_FORMATENUMF_WFORMATTAG =$00010000
#ACM_FORMATENUMF_NCHANNELS =$00020000
#ACM_FORMATENUMF_NSAMPLESPERSEC =$00040000
#ACM_FORMATENUMF_WBITSPERSAMPLE =$00080000
#ACM_FORMATENUMF_CONVERT =$00100000
#ACM_FORMATENUMF_SUGGEST =$00200000
#ACM_FORMATENUMF_HARDWARE =$00400000
#ACM_FORMATENUMF_INPUT =$00800000
#ACM_FORMATENUMF_OUTPUT =$01000000
Structure ACMDRIVERDETAILS
cbStruct.l
fccType.l
fccComp.l
wMid.w
wPid.w
vdwACM.l
vdwDriver.l
fdwSupport.l
cFormatTags.l
cFilterTags.l
hicon.l
szShortName.b[#ACMDRIVERDETAILS_SHORTNAME_CHARS];
szLongName.b[#ACMDRIVERDETAILS_LONGNAME_CHARS];
szCopyright.b[#ACMDRIVERDETAILS_COPYRIGHT_CHARS];
szLicensing.b[#ACMDRIVERDETAILS_LICENSING_CHARS];
szFeatures.b[#ACMDRIVERDETAILS_FEATURES_CHARS];
EndStructure
Structure ACMFILTERDETAILS
cbStruct.l
dwFilterIndex.l
dwFilterTag.l
fdwSupport.l
pwfltr.l
cbwfltr.l
szFilter.b[#ACMFILTERDETAILS_FILTER_CHARS];
EndStructure
Structure ACMFILTERTAGDETAILS
cbStruct.l
dwFilterTagIndex.l
dwFilterTag.l
cbFilterSize.l
fdwSupport.l
cStandardFilters.l
szFilterTag.b[#ACMFILTERTAGDETAILS_FILTERTAG_CHARS];
EndStructure
Structure ACMFORMATDETAILS
cbStruct.l
dwFormatIndex.l
dwFormatTag.l
fdwSupport.l
pwfx.l
cbwfx.l
szFormat.b[#ACMFORMATDETAILS_FORMAT_CHARS];
EndStructure
Structure WAVEFILTER
cbStruct.l
dwFilterTag.l
fdwFilter.l
dwReserved.l[5];
EndStructure
Structure WAVEFORMATEX
wFormatTag.w ; Waveform-audio format type. A complete list of format tags can be found in the Mmreg.h header file. For one- Or two-channel PCM data, this value should be WAVE_FORMAT_PCM.
nChannels.w ; Number of channels in the waveform-audio data. Monaural data uses one channel and stereo data uses two channels.
nSamplesPerSec.l ; Sample rate, in samples per second (hertz). If wFormatTag is WAVE_FORMAT_PCM, then common values for nSamplesPerSec are 8.0 kHz, 11.025 kHz, 22.05 kHz, and 44.1 kHz. For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.
nAvgBytesPerSec.l ; Required average data-transfer rate, in bytes per second, for the format tag. If wFormatTag is WAVE_FORMAT_PCM, nAvgBytesPerSec should be equal to the product of nSamplesPerSec and nBlockAlign. For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag.
nBlockAlign.w ; Block alignment, in bytes. The block alignment is the minimum atomic unit of data for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM or WAVE_FORMAT_EXTENSIBLE, nBlockAlign must be equal to the product of nChannels and wBitsPerSample divided by 8 (bits per byte). For non-PCM formats, this member must be computed according to the manufacturer's specification of the format tag. :Software must process a multiple of nBlockAlign bytes of Data at a time. Data written To And Read from a device must always start at the beginning of a block. For example, it is illegal To start playback of PCM Data in the middle of a sample (that is, on a non-block-aligned boundary).
wBitsPerSample.w ; Bits per sample for the wFormatTag format type. If wFormatTag is WAVE_FORMAT_PCM, then wBitsPerSample should be equal to 8 or 16. For non-PCM formats, this member must be set according to the manufacturer's specification of the format tag. If wFormatTag is WAVE_FORMAT_EXTENSIBLE, this value can be any integer multiple of 8. Some compression schemes cannot define a value for wBitsPerSample, so this member can be zero.
cbSize.w ; Size, in bytes, of extra format information appended to the end of the WAVEFORMATEX structure. This information can be used by non-PCM formats to store extra attributes for the wFormatTag. If no extra information is required by the wFormatTag, this member must be set to zero. For WAVE_FORMAT_PCM formats (and only WAVE_FORMAT_PCM formats), this member is ignored.
EndStructure
Structure ACMFILTERCHOOSE
cbStruct.l;
fdwStyle.l;
hwndOwner.l;
pwfltr.l;
cbwfltr.l;
pszTitle.l;
szFilterTag.b[#ACMFILTERTAGDETAILS_FILTERTAG_CHARS];
szFilter.b[#ACMFILTERDETAILS_FILTER_CHARS];
pszName.l;
cchName.l;
fdwEnum.l;
pwfltrEnum.l;
hInstance.l;
pszTemplateName.l;
lCustData.l;
pfnHook.l;
EndStructure
Procedure DebugError(e.l)
tx.s = ""
Select e
Case #MMSYSERR_INVALFLAG
tx = "INVALIDE FLAG"
Case #MMSYSERR_INVALHANDLE
tx = "INVALIDE HANDLE"
Case #MMSYSERR_INVALPARAM
tx = "INVALIDE PARAM"
Case #MMSYSERR_NODRIVER
tx = "NO DRIVER"
EndSelect
If tx
Debug tx
EndIf
EndProcedure
Procedure acmFiltTagCallBack (*hadid.l,*paftd.ACMFILTERTAGDETAILS ,dwInstance.l,fdwSupport.l)
Debug "******** "+PeekS(@*paftd\szFilterTag[0])
ProcedureReturn #true
EndProcedure
Procedure acmFiltCallBack (*hadid.l,*pafd.ACMFILTERDETAILS ,dwInstance.l,fdwSupport.l)
Debug "******** "+PeekS(@*pafd\szFilter[0])
ProcedureReturn #true
EndProcedure
Procedure acmFmtCallBack (*hadid.l,*pafd2.ACMFORMATDETAILS,dwInstance.l,fdwSupport.l)
Select *pafd2\dwFormatTag
Case #WAVE_FORMAT_PCM
tx.s = "PCM"
Case #WAVE_FORMAT_ALAW
tx = "ALAW"
Case #WAVE_FORMAT_MULAW
tx = "MULAW"
Case #WAVE_FORMAT_ADPCM
tx = "ADPCM"
Case #WAVE_FORMAT_DVI_ADPCM
tx = "DVI ADPCM"
Case #WAVE_FORMAT_DVI_ADPCM
tx = "Dialogic OKI ADPCM"
Case #WAVE_FORMAT_GSM610
tx = "GSM610"
Case #WAVE_FORMAT_TRUESPEECH
tx = "TRUESPEECH"
Case #WAVE_FORMAT_G723_ADPCM
tx = "G723 ADPCM"
Case #WAVE_FORMAT_MPEG
tx = "MPEG"
Case #WAVE_FORMAT_MSG723
tx = "MSG723"
Case #WAVE_FORMAT_MPEGLAYER3
tx = "MP3"
Case #WAVE_FORMAT_VOXWARE
tx = "VOXWARE"
Case #WAVE_FORMAT_VOXWARE_BYTE_ALIGNED
tx = "VOXWARE BYTEALIGNED"
Case #WAVE_FORMAT_VOXWARE_RT24
tx = "VOXWARE RT24"
Case #WAVE_FORMAT_VOXWARE_RT29
tx = "VOXWARE RT29"
Case 304
tx = "ACELP.net"
Default
tx = "FormatTag #"+Str(*pafd2\dwFormatTag)
EndSelect
Debug " "+Str(*pafd2\dwFormatIndex)+"- "+tx +" : "+PeekS(@*pafd2\szFormat[0])
ProcedureReturn #true
EndProcedure
Procedure acmCallback(*hadid.l,dwInstance.l,fdwSupport.l)
fdwDetails.l = 0 ; reserved - must be 0
padd.ACMDRIVERDETAILS\cbStruct = SizeOf(ACMDRIVERDETAILS)
If acmDriverDetails_(*hadid,@padd,fdwDetails) = 0
svar.s = PeekS(@padd\szLongName[0])+" : "+ PeekS(@padd\szFeatures[0])
Debug svar
svar = " "+PeekS(@padd\szCopyright[0])+" - License : "+ PeekS(@padd\szLicensing[0])
If PeekS(@padd\szLicensing[0]) = ""
svar = svar + "ND"
EndIf
Debug svar
fdwSupport = @padd\fdwSupport
svar = ""
If (fdwSupport & #ACMDRIVERDETAILS_SUPPORTF_ASYNC): SVar = "Async conversions " : EndIf
If (fdwSupport & #ACMDRIVERDETAILS_SUPPORTF_CODEC)
If Svar: Svar = Svar + " + " : EndIf
Svar = Svar+"Different format conversions"
EndIf
If (fdwSupport & #ACMDRIVERDETAILS_SUPPORTF_CONVERTER)
If Svar: Svar = Svar + " + " : EndIf
Svar = Svar+"Same format conversions"
EndIf
If (fdwSupport & #ACMDRIVERDETAILS_SUPPORTF_FILTER)
If Svar: Svar = Svar + " + " : EndIf
Svar = Svar+"Filtering"
EndIf
If Svar: Debug " Can do : " +Svar: EndIf
acmDriverOpen_(@*phad,*hadid, 0)
dwInstance.l = 0
paftd.ACMFILTERTAGDETAILS
RtlZeroMemory_(@paftd,SizeOf(ACMFILTERTAGDETAILS));
paftd\cbStruct = SizeOf(ACMFILTERTAGDETAILS)+200
paftd\dwFilterTag = #WAVE_FORMAT_PCM
paftd\cbFilterSize = 2000
paftd\fdwSupport =0
e = acmFilterTagEnum_(*phad,@paftd,@acmFiltTagCallBack(),@dwInstance,0)
Wf.WAVEFILTER\cbStruct = SizeOf(WAVEFILTER)+200
Wf\dwFilterTag =#WAVE_FORMAT_PCM; #WAVE_FILTER_UNKNOWN;
pafd.ACMFILTERDETAILS\cbStruct = SizeOf(ACMFILTERDETAILS)
pafd\pwfltr = @wf
pafd\cbwfltr = SizeOf(WAVEFILTER)+200
pafd\dwFilterTag = #WAVE_FORMAT_PCM; #WAVE_FILTER_UNKNOWN;
fdwEnum = #ACM_FILTERENUMF_DWFILTERTAG
e = acmFilterEnum_(*phad, @pafd,@acmFiltCallBack(),@dwInstance,fdwEnum)
wfx.WAVEFORMATEX ; Wave Format Structure
RtlZeroMemory_(@wfx,SizeOf(WAVEFORMATEX));
wfx\wFormatTag = #WAVE_FORMAT_UNKNOWN; #WAVE_FORMAT_PCM;
wfx\nChannels = 2 ;dwPrimaryChannels;
wfx\nSamplesPerSec = 44100 ;dwPrimaryFreq;
wfx\wBitsPerSample = 16 ;dwPrimaryBitRate;
wfx\nBlockAlign = (wfx\wBitsPerSample / 8 * wfx\nChannels)
wfx\nAvgBytesPerSec = (wfx\nSamplesPerSec * wfx\nBlockAlign)
pafd2.ACMFORMATDETAILS\cbStruct = SizeOf(ACMFORMATDETAILS )
pafd2\pwfx = @wfx
pafd2\cbwfx = SizeOf(WAVEFORMATEX )+200
pafd2\dwFormatTag = #WAVE_FORMAT_UNKNOWN;#WAVE_FORMAT_PCM;
;pafd2\fdwSupport = fdwSupport
fdwEnum.l = #ACM_FORMATENUMF_INPUT|#ACM_FORMATENUMF_OUTPUT
acmFormatEnum_(*phad, @pafd2,@acmFmtCallBack(),dwInstance,fdwEnum)
Wf.WAVEFILTER\cbStruct = SizeOf(WAVEFILTER)
Wf\dwFilterTag = #WAVE_FORMAT_PCM;
pszName.s = ""
fc.ACMFILTERCHOOSE\cbStruct = SizeOf(ACMFILTERCHOOSE)
fc\fdwStyle =0
fc\hwndOwner=0
fc\pwfltr =@Wf
fc\cbwfltr = SizeOf(WAVEFILTER)
fc\pszTitle =0
;fc\szFilterTag.b[#ACMFILTERTAGDETAILS_FILTERTAG_CHARS];
;fc\szFilter.b[#ACMFILTERDETAILS_FILTER_CHARS];
fc\pszName = @pszName
fc\cchName =0
fc\fdwEnum =0;
fc\pwfltrEnum=0
fc\hInstance=0
fc\pszTemplateName=0
fc\lCustData=0
fc\pfnHook=0
acmDriverClose_(*phad, 0)
EndIf
ProcedureReturn #true
EndProcedure
Procedure DSCallback(lpGuid,lpcstrDescription,lpcstrModule,lpContext)
svar.s = PeekS(lpcstrDescription)
Debug svar
ProcedureReturn #true
EndProcedure
Debug "**** PERIPHERIQUES ****"
If OpenLibrary(0,"dsound.DLL")
If IsFunction(0, "DirectSoundEnumerateA")
lp = 1
CallFunction(0,"DirectSoundEnumerateA",@DSCallback(),@lp)
Else
Debug "not a fonction"
EndIf
Else
Debug "not a library"
EndIf
Debug ""
Debug "**** DRIVERS ****"
v.l = 0
fdwEnum.l = 0;#ACM_DRIVERENUMF_DISABLED|#ACM_DRIVERENUMF_NOLOCAL
acmDriverEnum_(@acmCallback(),@v,fdwEnum )