Quelle API pour modifier l'accélération matérielle de la carte son ?

Résolu
JMC70 Messages postés 77 Date d'inscription samedi 9 novembre 2002 Statut Membre Dernière intervention 6 juillet 2014 - 1 sept. 2008 à 22:29
JMC70 Messages postés 77 Date d'inscription samedi 9 novembre 2002 Statut Membre Dernière intervention 6 juillet 2014 - 4 sept. 2008 à 07:59
Par défaut, Windows XP ajuste l'accélération matérielle de la carte son au maximum. Or avec certains PC équipés de cartes de début de gamme, des problèmes peuvent se poser lors de la lecture de sons (notamment compressés car le son est lu avant d'être prêt - enfin, je suppose que le problème vient de là). C'est le cas d'un de mes programmes dont les débuts des sons mp3 sont parfois tronqués sur environ 1/2 sec (comme ils durent 2 ou 3 sec, c'est pour le moins gênant). J'indique aux utilisateurs qui me soumettent le problème qu'il leur suffit d'aller diminuer d'un ou deux crans l'accélération matérielle depuis le panneau de configuration, ce qui suffit généralement mais n'est pas très pratique.
J'aimerais donc récupérer la valeur de l'accélération courante au lancement du programme, la mettre ensuite sur "aucune" et enfin la remettre à sa valeur d'origine en quittant le programme. Je suppose qu'une API le gère puisque cela fonctionne très bien depuis le panneau de configuration.
Je n'ai rien trouvé après plusieurs recherches sur ce sujet traité dans différents forums (ou on conseille simplement de passer par le panneau de configuration). Si vous avez une idée...

JMC70

12 réponses

orellabac Messages postés 4 Date d'inscription mardi 2 septembre 2008 Statut Membre Dernière intervention 4 septembre 2008
4 sept. 2008 à 00:45
Je teste avec le suivante code:
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, cbName As Long, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias _
    "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
    ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, _
    ByVal cbData As Long) As Long

Public Enum DirectSoundAccel
    Emulation
    Basic
    Standard
    Full
End Enum

Public Enum HKeys
    HKEY_CLASSES_ROOT = &H80000000
    HKEY_CURRENT_USER = &H80000001
    HKEY_LOCAL_MACHINE = &H80000002
    HKEY_USERS = &H80000003
    HKEY_PERFORMANCE_DATA = &H80000004
    HKEY_CURRENT_CONFIG = &H80000005
    HKEY_DYN_DATA = &H80000006
End Enum

'Registry Type's
Private Const REG_NONE = 0
Private Const REG_SZ = 1
Private Const REG_EXPAND_SZ = 2
Private Const REG_BINARY = 3
Private Const REG_DWORD = 4
Private Const REG_DWORD_LITTLE_ENDIAN = 4
Private Const REG_DWORD_BIG_ENDIAN = 5
Private Const REG_LINK = 6
Private Const REG_MULTI_SZ = 7
Private Const REG_RESOURCE_LIST = 8
Private Const REG_FULL_RESOURCE_DESCRIPTOR = 9
Private Const REG_RESOURCE_REQUIREMENTS_LIST = 10
'Right's for the OpenRegistry
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const SYNCHRONIZE = &H100000
Private Const KEY_READ = &H20009
Private Const KEY_WRITE = &H20006
Private Const KEY_READ_WRITE = ( _
KEY_READ _
Or _
KEY_WRITE _
)

Function ObtenirDirectSound(ByVal hKey As Long)
    Dim handle As Long
    Dim length As Long
    Dim index As Long
    Dim subKeyNameBuffer As String
    Dim res As Long
    ' result collection
    Dim iPCISubEntries As Integer
    ObtenirDirectSound = 0
    iPCISubEntries = 0
    Do
        ' this is the max length for a key name
        length = 260
        subKeyNameBuffer = Space$(length)
       
        res = RegEnumKey(hKey, iPCISubEntries, subKeyNameBuffer, length)
        If res = 0 Then
             'PCI \ SubEntrie
             res = RegOpenKeyEx(hKey, subKeyNameBuffer, iPCISubEntries, KEY_READ_WRITE, hPCISubEntrie)
             If res <> 0 Then
                ' Errour c'est le fin
                Exit Function
             Else
              'PCI \ SubEntrie \ SubSubEntrie \ DirectSound
              subKeyNameBuffer = Space$(length)
              res = RegEnumKey(hPCISubEntrie, 0, subKeyNameBuffer, length)
              If res = 0 Then
                Dim hPCISubSubEntrie
                res = RegOpenKeyEx(hPCISubEntrie, subKeyNameBuffer, 0, KEY_READ_WRITE, hPCISubSubEntrie)
                If res = 0 Then
                    Dim hDirectSound
                    res = RegOpenKeyEx(hPCISubSubEntrie, "DirectSound", 0, KEY_READ_WRITE, hDirectSound)
                    If res = 0 Then
                        RegCloseKey (hPCISubSubEntrie)
                        RegCloseKey (hPCISubEntrie)
                        ObtenirDirectSound = hDirectSound
                        Exit Function
                    End If
                End If
                RegCloseKey (hPCISubSubEntrie)
              End If
              RegCloseKey (hPCISubEntrie)
             End If
          
        Else
            Exit Function
        End If
       
        ' preparer le suivant
        iPCISubEntries = iPCISubEntries + 1
    Loop
  
    ' Close the key, if it was actually opened
    If handle Then RegCloseKey handle
       
End Function

Sub ChangerLeAccelerationMaterielle(neuAcceleration As Integer)
    Dim hPCIKey As Long
    Dim res As Long
    Dim value As Long
    res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\ControlSet001\Hardware Profiles\Current\System\CurrentControlSet\Enum\PCI", 0, KEY_READ_WRITE, hPCIKey)
    If res <> 0 Then
    GoTo Error
    End If
   
    'Reviser tout les entrees
    Dim hDirectSound
    hDirectSound = ObtenirDirectSound(hPCIKey)
    If hDirectSound Then
        Dim hDevicePresence
        Dim hMixerDefaults
       
        RegOpenKeyEx hDirectSound, "Device Presence", 0, KEY_WRITE Or KEY_SET_VALUE, hDevicePresence
        RegOpenKeyEx hDirectSound, "Mixer Defaults", 0, KEY_WRITE, hMixerDefaults
       
        Select Case neuAcceleration
            Case Emulation
                value = 0
                RegSetValueEx hDevicePresence, "VxD", 0, REG_DWORD, value, 4
                RegSetValueEx hDevicePresence, "WDM", 0, REG_DWORD, value, 4
                RegSetValueEx hMixerDefaults, "Acceleration", 0, REG_DWORD, &HF, 4
            Case Basic
                value = 1
                RegSetValueEx hDevicePresence, "VxD", 0, REG_DWORD, value, 4
                RegSetValueEx hDevicePresence, "WDM", 0, REG_DWORD, value, 4
                value = &HF
                RegSetValueEx hMixerDefaults, "Acceleration", 0, REG_DWORD, value, 4

            Case Standard
                value = 1
                RegSetValueEx hDevicePresence, "VxD", 0, REG_DWORD, value, 4
                RegSetValueEx hDevicePresence, "WDM", 0, REG_DWORD, value, 4
                value = &H8
                RegSetValueEx hMixerDefaults, "Acceleration", 0, REG_DWORD, value, 4
           
            Case Full
                value = 1
                RegSetValueEx hDevicePresence, "VxD", 0, REG_DWORD, value, 4
                RegSetValueEx hDevicePresence, "WDM", 0, REG_DWORD, value, 4
                value = 0
                RegSetValueEx hMixerDefaults, "Acceleration", 0, REG_DWORD, value, 4
           
        End Select
    RegCloseKey (hDirectSound)
    RegCloseKey (hMixerDefaults)
    RegCloseKey (hDirectSound)
    End If
   
    RegCloseKey (hPCIKey)
    Exit Sub
Error:
    MsgBox "Desolee"

End Sub
Sub Main()

    ChangerLeAccelerationMaterielle (Emulation)
    MsgBox "Check"
    ChangerLeAccelerationMaterielle (Full)
End Sub
3
gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
1 sept. 2008 à 23:24
ça doit être noté dans une clé du registre


tu pourrais essayer de la retrouver










Bonjour chez vous !
0
orellabac Messages postés 4 Date d'inscription mardi 2 septembre 2008 Statut Membre Dernière intervention 4 septembre 2008
2 sept. 2008 à 01:19
tu pourrais essayer

Private Declare Function EnumDisplaySettings Lib "user32" _
   Alias "EnumDisplaySettingsA" _
   (ByVal lpszDeviceName As Long, _
   ByVal iModeNum As Long, _
   lpDevMode As Any) As Boolean
  
Private Declare Function ChangeDisplaySettings Lib "user32" _
   Alias "ChangeDisplaySettingsA" _
   (lpDevMode As Any, _
   ByVal dwflags As Long) As Long

Private Type DEVMODE
   dmDeviceName As String * CCDEVICENAME
   dmSpecVersion As Integer
   dmDriverVersion As Integer
   dmSize As Integer
   dmDriverExtra As Integer
   dmFields As Long
   dmOrientation As Integer
   dmPaperSize As Integer
   dmPaperLength As Integer
   dmPaperWidth As Integer
   dmScale As Integer
   dmCopies As Integer
   dmDefaultSource As Integer
   dmPrintQuality As Integer
   dmColor As Integer
   dmDuplex As Integer
   dmYResolution As Integer
   dmTTOption As Integer
   dmCollate As Integer
   dmFormName As String * CCFORMNAME
   dmUnusedPadding As Integer
   dmBitsPerPel As Integer
   dmPelsWidth As Long
   dmPelsHeight As Long
   dmDisplayFlags As Long
   dmDisplayFrequency As Long
End Type

Public Sub ChangeRes(iWidth As Single, iHeight As Single)
   Dim blnWorked As Boolean
   Dim i As Long
   Dim DevM As DEVMODE
  
   i = 0
  
   Do
       blnWorked = EnumDisplaySettings(0&, i, DevM)
       i = i + 1
   Loop Until (blnWorked = False)
      
   With DevM
       .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
       .dmPelsWidth = iWidth
       .dmPelsHeight = iHeight
   End With
  
   Call ChangeDisplaySettings(DevM, 0)
End Sub

tu peux changer "refresh rate" avec cettes functions
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
2 sept. 2008 à 07:34
salut,

orellabac -> ton code sert à changer la résolution de l'écran ^^

jmc70 -> par API peut-être...
par registre là par contre bonne change, y'a pas mal de boulot...

Valeurs modifiées :18
HKLM\SOFTWARE\Microsoft\Cryptography\RNG\Seed:
93 AD D6 C4 EE 88 44 C6 0E 9F 56 07 9E 72 A3 E4 50 07 5E 46 5D 19 A0 8B
A4 39 CA E1 08 CC B4 86 0D 49 28 DB D0 C2 40 EB 61 EF C6 35 3C BF B6 B2
8B D4 96 36 A4 CD A6 E5 07 4D A6 6D 99 42 98 B9 EE 15 7D 87 DB 78 8A 5E
B7 CB B1 B2 F9 45 DB A8
HKLM\SOFTWARE\Microsoft\Cryptography\RNG\Seed: 2F BA DF
DD 56 4A 4C C3 E1 12 91 A4 98 A7 EA 4D 11 55 A7 01 25 AD D5 45 80 56 A9
54 7A 30 D5 73 9B 61 CC E0 D6 00 8D 02 D3 11 39 8C E3 8E 57 4C D2 0E 61
8E 8A C7 AB 5F 27 A5 14 BC 61 4E 6A E6 BC D0 7C 43 14 A9 57 F7 51 07 8D
9C 5B 37 A0 D0
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000001
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000000
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000001
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000000
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x00000008
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x0000000F
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000001
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000000
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000001
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000000
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x00000008
HKLM\SYSTEM\ControlSet001\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x0000000F
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000001
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000000
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000001
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000000
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x00000008
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x0000000F
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000001
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\VxD: 0x00000000
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000001
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Device
Presence\WDM: 0x00000000
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x00000008
HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration: 0x0000000F
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHACNGU:
71 00 00 00 FB 01 00 00 10 B5 B3 E4 BB 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHACNGU:
71 00 00 00 FC 01 00 00 60 D5 E2 F9 BB 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHACNGU:P:\JVAAG\Flfgrz32\EHAQYY32.RKR:
71 00 00 00 96 00 00 00 40 0C B1 98 BA 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHACNGU:P:\JVAAG\Flfgrz32\EHAQYY32.RKR:
71 00 00 00 97 00 00 00 60 D5 E2 F9 BB 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHAPCY:
71 00 00 00 1D 00 00 00 40 0C B1 98 BA 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHAPCY:
71 00 00 00 1E 00 00 00 00 5C E4 F9 BB 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHAPCY:"P:\JVAAG\flfgrz32\ZZFLF.PCY",@0:
71 00 00 00 13 00 00 00 40 0C B1 98 BA 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count\HRZR_EHAPCY:"P:\JVAAG\flfgrz32\ZZFLF.PCY",@0:
71 00 00 00 14 00 00 00 00 5C E4 F9 BB 0C C9 01
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap\ConfigureCount:
0x00000009
HKU\S-XXXXX\Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap\ConfigureCount:
0x0000000A

Nombre de modifications :18

je regarderai avec les API (sans promesse)
++
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp  
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Kevin.Ory Messages postés 840 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 7 janvier 2009 11
2 sept. 2008 à 10:39
Salut,
En même temps, si ces sons sont correctement lus pas un lecteur audio (Winamp, WMP...) même sur des PC équipés de cartes son d'entrée de gamme, cela veut dire que ce problème est lié à autre chose. Je doute que Winamp ou WMP réduisent l'accélération matériel de la carte son lors de leur lancement...
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
2 sept. 2008 à 12:15
encore que winamp n'est pas le bon exemple (puisqu'il fait des fondus entre les pistes en option par défaut) mais tu as tout à fait raison.

allez un peu de pub par les API mci
http://www.vbfrance.com/codes/JOUER-SON-WAV-MP3-MID-SYSTEM-NOTE-UNIQUEMENT_36041.aspx

++
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp  
0
orellabac Messages postés 4 Date d'inscription mardi 2 septembre 2008 Statut Membre Dernière intervention 4 septembre 2008
3 sept. 2008 à 01:51
Pardon. Mon errour.

Tu peut changer le registre directement:
Pour example dans mon ordinateur ces sont les changes pour acceleration ON:

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_8086&DEV_27DE&SUBSYS_01AD1028&REV_01\3&172e68dd&0&F2\DirectSound\Mixer Defaults]
"Acceleration"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_8086&DEV_27DE&SUBSYS_01AD1028&REV_01\3&172e68dd&0&F2\DirectSound\Device Presence]
"VxD"=dword:00000001
"WDM"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{34469DE2-6C55-49A6-A579-0D3C2F9EAB34}\0000]
"Acceleration.Level"=-

et OFF:

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_8086&DEV_27DE&SUBSYS_01AD1028&REV_01\3&172e68dd&0&F2\DirectSound\Mixer Defaults]
"Acceleration"=dword:0000000f

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Hardware Profiles\0001\System\CurrentControlSet\Enum\PCI\VEN_8086&DEV_27DE&SUBSYS_01AD1028&REV_01\3&172e68dd&0&F2\DirectSound\Device Presence]
"VxD"=dword:00000000
"WDM"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{34469DE2-6C55-49A6-A579-0D3C2F9EAB34}\0000]
"Acceleration.Level"=dword:00000005
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
3 sept. 2008 à 02:10
orellabac
->

CurrentControlSet\Control\Video\{344

même erreur, tu parles de l'accélération GRAPHIQUE, tandis que la question est l'accélération AUDIO (DirectSound)

<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp  
0
orellabac Messages postés 4 Date d'inscription mardi 2 septembre 2008 Statut Membre Dernière intervention 4 septembre 2008
3 sept. 2008 à 18:25
Pardon pour la confussion and mercu beaucoup pour l'explication

Si tu lis http://msdn.microsoft.com/fr-fr/library/ms790572(en-us).aspx
on peut voir que il n'existe pas un API pour change l'acceleration materriele
Mais tu peut employeer le code si desous:

Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Module module1

    Enum DirectSoundAccelerationLevels
        ProgramError
        EmulationOnly
        Basic
        Standard
        Full
    End Enum

    Function ObtenirAccelerationMaterielle() As DirectSoundAccelerationLevels
        'Cette Example est sur pour PCI
        Using registrySYSTEM As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SYSTEM")
            Using registryControlSet001 As RegistryKey = registrySYSTEM.OpenSubKey("ControlSet001")
                Using registryHardwareProfiles As RegistryKey = registryControlSet001.OpenSubKey("Hardware Profiles")
                    Using registry0001 As RegistryKey = registryHardwareProfiles.OpenSubKey("Current")
                        Using registrySystem2 As RegistryKey = registry0001.OpenSubKey("System")
                            Using registryCurrentControlSet As RegistryKey = registrySystem2.OpenSubKey("CurrentControlSet")
                                Using registryEnum As RegistryKey = registryCurrentControlSet.OpenSubKey("Enum")
                                    Using registryPCI As RegistryKey = registryEnum.OpenSubKey("PCI")
                                        Using directSound As RegistryKey = RegistryEntryAvecDirectSound(registryPCI)
                                            Dim devicePresence As RegistryKey = directSound.OpenSubKey("Device Presence", True)
                                            Dim mixerDefault As RegistryKey = directSound.OpenSubKey("Mixer Defaults", True)
                                            If devicePresence.GetValue("VxD") = 0 Then
                                                Return DirectSoundAccelerationLevels.EmulationOnly
                                            Else                                                If devicePresence.GetValue("VxD") 1 AndAlso devicePresence.GetValue("VxD") 1 AndAlso mixerDefault.GetValue("Acceleration") = &HF Then
                                                    Return DirectSoundAccelerationLevels.Basic
                                                End If
                                                Select Case mixerDefault.GetValue("Acceleration")
                                                    Case &H0
                                                        Return DirectSoundAccelerationLevels.Full
                                                    Case &H8
                                                        Return DirectSoundAccelerationLevels.Standard
                                                    Case &HF
                                                        Return DirectSoundAccelerationLevels.EmulationOnly
                                                End Select
                                                Return DirectSoundAccelerationLevels.ProgramError
                                            End If

                                        End Using
                                    End Using
                                End Using
                            End Using
                        End Using
                    End Using
                End Using
            End Using
        End Using
    End Function

    Sub ChangezAccelerationMaterielle(ByVal newState As DirectSoundAccelerationLevels)
        'Cette Example est sur pour PCI
        Using registrySYSTEM As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SYSTEM")
            Using registryControlSet001 As RegistryKey = registrySYSTEM.OpenSubKey("ControlSet001")
                Using registryHardwareProfiles As RegistryKey = registryControlSet001.OpenSubKey("Hardware Profiles")
                    Using registry0001 As RegistryKey = registryHardwareProfiles.OpenSubKey("Current")
                        Using registrySystem2 As RegistryKey = registry0001.OpenSubKey("System")
                            Using registryCurrentControlSet As RegistryKey = registrySystem2.OpenSubKey("CurrentControlSet")
                                Using registryEnum As RegistryKey = registryCurrentControlSet.OpenSubKey("Enum")
                                    Using registryPCI As RegistryKey = registryEnum.OpenSubKey("PCI")
                                        Using directSound As RegistryKey = RegistryEntryAvecDirectSound(registryPCI)
                                            Dim devicePresence As RegistryKey = directSound.OpenSubKey("Device Presence", True)
                                            Dim mixerDefault As RegistryKey = directSound.OpenSubKey("Mixer Defaults", True)
                                            Select Case newState
                                                Case DirectSoundAccelerationLevels.EmulationOnly
                                                    mixerDefault.SetValue("Acceleration", &HF)
                                                    devicePresence.SetValue("VxD", 0)
                                                    devicePresence.SetValue("WDM", 0)
                                                Case DirectSoundAccelerationLevels.Basic
                                                    mixerDefault.SetValue("Acceleration", &HF)
                                                    devicePresence.SetValue("VxD", 1)
                                                    devicePresence.SetValue("WDM", 1)
                                                Case DirectSoundAccelerationLevels.Standard
                                                    mixerDefault.SetValue("Acceleration", &H8)
                                                    devicePresence.SetValue("VxD", 1)
                                                    devicePresence.SetValue("WDM", 1)
                                                Case DirectSoundAccelerationLevels.Full
                                                    mixerDefault.SetValue("Acceleration", 0)
                                                    devicePresence.SetValue("VxD", 1)
                                                    devicePresence.SetValue("WDM", 1)
                                            End Select
                                        End Using
                                    End Using
                                End Using
                            End Using
                        End Using
                    End Using
                End Using
            End Using
        End Using

    End Sub

    Sub main()
        ChangezAccelerationMaterielle(DirectSoundAccelerationLevels.EmulationOnly)
        MsgBox("Check")
        ChangezAccelerationMaterielle(DirectSoundAccelerationLevels.Basic)
        MsgBox("Check")
        ChangezAccelerationMaterielle(DirectSoundAccelerationLevels.Standard)
        MsgBox("Check")
        ChangezAccelerationMaterielle(DirectSoundAccelerationLevels.Full)
    End Sub

    Function RegistryEntryAvecDirectSound(ByVal root As RegistryKey) As RegistryKey
        'Les PCI Keys sont comme
        ' + - VEN_14E4&DEV_1677&SUBSYS_01AD1028&REV_01
        '      + ---- 3&172e68dd&0&F2
        For Each keyName As String In root.GetSubKeyNames()
            Using SubKey As RegistryKey = root.OpenSubKey(keyName)
                If SubKey.SubKeyCount > 0 Then
                    Using subSubKey As RegistryKey = SubKey.OpenSubKey(SubKey.GetSubKeyNames()(0))
                        If Array.IndexOf(subSubKey.GetSubKeyNames(), "DirectSound") <> -1 Then
                            'trouve
                            Return subSubKey.OpenSubKey("DirectSound")
                        
                        End If
                    End Using

                End If
            End Using
        Next
        Return Nothing
    End Function

End Module
0
JMC70 Messages postés 77 Date d'inscription samedi 9 novembre 2002 Statut Membre Dernière intervention 6 juillet 2014
3 sept. 2008 à 18:50
Merci à Orellabac (et à tous les intervenants). Je vais essayer de traduire cela en VB6 (si j'y arrive, je mettrai le code à disposition). Je sais maintenant où intervenir dans la base de registres et j'exclus donc le recours aux API.
Je regarde cela dès que j'ai un peu de temps (je ne valide pas la réponse pour l'instant).

JMC70
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
3 sept. 2008 à 19:01
au final çà correspond à cette clé (comme indiqué au dessus) :

HKLM\SYSTEM\CurrentControlSet\Hardware
Profiles\Current\System\CurrentControlSet\Enum\PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C\DirectSound\Mixer
Defaults\Acceleration

testé manuellemement avec 0, 8 et F (en hexa), OK

seulement je n'ai réussi à trouver PCI\VEN_1039&DEV_7018&SUBSYS_70181039&REV_02\3&61AAA01&0&0C QUE par WMI, (WIN32_SoundDevice), ce qui est alors trop long d'accès

si quelqu'un a une piste j'adapterai....

(à noter que çà correspond dans ton code orellabac à RegistryEntryAvecDirectSound(registryPCI))

++
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp  
0
JMC70 Messages postés 77 Date d'inscription samedi 9 novembre 2002 Statut Membre Dernière intervention 6 juillet 2014
4 sept. 2008 à 07:59
Nickel ! Je n'ai même pas eu besoin de faire la conversion en VB6. Il manquait simplement :
dim hPCISubEntrie
dans ObtenirDirectSound()
Je vais tester avec plusieurs versions de windows.
Merci !

JMC70
0
Rejoignez-nous