Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One for the VFP whiz kids
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
00977520
Message ID:
00978066
Vues:
55
This message has been marked as a message which has helped to the initial question of the thread.
Well, it's not going to be an easy ride. Here's a starter, two classes that partially implement Mixer and MixerLine objects. I'll be working on a more or less complete version; Grady and Herman many thanks for the idea.
LOCAL mixer As TMixer, mixerline As TMixerLine
mixer = CREATEOBJECT("TMixer")

IF mixer.errorno = 0
	? mixer.fullname
	FOR nIndex=0 TO mixer.destinations-1
		mixerline = mixer.GetMixerLine(nIndex)
		? mixerline.fullname
	NEXT
ENDIF

* end of main

DEFINE CLASS TMixer As Session
#DEFINE MMSYSERR_NOERROR 0
#DEFINE MIXER_SHORT_NAME_CHARS 16
#DEFINE MIXER_LONG_NAME_CHARS 64
#DEFINE MAXPNAMELEN 32
#DEFINE MIXERCAPS_SIZE 48

PROTECTED hmixer
	errorno=0
	manufacturerid=0
	productid=0
	driverversion=0
	fullname=""
	destinations=0
	
PROCEDURE Init
	THIS.declare
	THIS.MixOpen

PROTECTED PROCEDURE MixOpen
* retrieves values from MIXERCAPS structure
	LOCAL hMixer, cMIXERCAPS
	hMixer=0
	THIS.errorno = mixerOpen(@m.hMixer, 0,0,0,0)
	THIS.hmixer = m.hMixer

	IF THIS.errorno = MMSYSERR_NOERROR
		cMIXERCAPS = REPLICATE(CHR(0), MIXERCAPS_SIZE)
		THIS.errorno = mixerGetDevCaps(THIS.hmixer,;
			@cMIXERCAPS, MIXERCAPS_SIZE)

		IF THIS.errorno = MMSYSERR_NOERROR
			THIS.manufacturerid = buf2word(SUBSTR(cMIXERCAPS, 1,2))
			THIS.productid = buf2word(SUBSTR(cMIXERCAPS, 3,2))
			THIS.driverversion = buf2word(SUBSTR(cMIXERCAPS, 5,2))

			THIS.fullname = SUBSTR(cMIXERCAPS, 9,MAXPNAMELEN)
			THIS.fullname = SUBSTR(THIS.fullname, 1,;
				AT(CHR(0),THIS.fullname)-1)

			THIS.destinations = buf2dword(SUBSTR(cMIXERCAPS, 45,4))
		ENDIF
	ENDIF
	
FUNCTION GetMixerLine(nIndex) As TMixerLine
	LOCAL oMixerLine
	oMixerLine = CREATEOBJECT("TMixerLine",;
		THIS.hmixer, nIndex)
	THIS.errorno = oMixerLine.errorno
RETURN m.oMixerLine

PROCEDURE Destroy
	THIS.MixClose

PROTECTED PROCEDURE MixClose
	IF THIS.hmixer <> 0
		= mixerClose(THIS.hmixer)
		THIS.hmixer=0
	ENDIF

PROCEDURE declare
	DECLARE INTEGER mixerGetDevCaps IN winmm;
		INTEGER uMxId, STRING @pmxcaps, INTEGER cbmxcaps

	DECLARE INTEGER mixerOpen IN winmm;
		INTEGER @phmx, INTEGER uMxId, INTEGER dwCallback,;
		INTEGER dwInstance, INTEGER fdwOpen

	DECLARE INTEGER mixerClose IN winmm INTEGER hmx

	DECLARE INTEGER mixerGetLineInfo IN winmm;
		INTEGER hmxobj, STRING @pmxl, INTEGER fdwInfo
ENDDEFINE

DEFINE CLASS TMixerLine As Session
* implements MIXERLINE structure
	errorno=0
	destination=0
	source=0
	lineid=0
	channels=0
	shortname=""
	fullname=""

PROCEDURE Init(hMixer, nDestination)
#DEFINE MIXERLINE_SIZE 168
#DEFINE MIXER_GETLINEINFOF_DESTINATION 0
	LOCAL cMIXERLINE

	cMIXERLINE = PADR(num2dword(MIXERLINE_SIZE) +;
		num2dword(nDestination), MIXERLINE_SIZE, CHR(0))

	THIS.errorno = mixerGetLineInfo(hMixer,;
		@cMIXERLINE, MIXER_GETLINEINFOF_DESTINATION)

	IF THIS.errorno <> MMSYSERR_NOERROR
		RETURN
	ENDIF

	THIS.destination = nDestination
	THIS.source = buf2dword(SUBSTR(cMIXERLINE, 9,4))
	THIS.lineid = buf2dword(SUBSTR(cMIXERLINE, 13,4))
	THIS.channels = buf2dword(SUBSTR(cMIXERLINE, 29,4))

	THIS.shortname = SUBSTR(cMIXERLINE, 41,;
		MIXER_SHORT_NAME_CHARS)
	THIS.shortname = SUBSTR(THIS.shortname, 1,;
		AT(CHR(0),THIS.shortname)-1)

	THIS.fullname = SUBSTR(cMIXERLINE, 57,;
		MIXER_LONG_NAME_CHARS)
	THIS.fullname = SUBSTR(THIS.fullname, 1,;
		AT(CHR(0),THIS.fullname)-1)
ENDDEFINE

********** static routines ************
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
	BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
	BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
	BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)

FUNCTION buf2word(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
       Asc(SUBSTR(lcBuffer, 2,1)) * 256

FUNCTION num2dword(lnValue)
#DEFINE m0  256
#DEFINE m1  65536
#DEFINE m2  16777216
	IF lnValue < 0
		lnValue = 0x100000000 + lnValue
	ENDIF
	LOCAL b0, b1, b2, b3
	b3 = Int(lnValue/m2)
	b2 = Int((lnValue - b3*m2)/m1)
	b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
	b0 = Mod(lnValue, m0)
RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform