Bonjour,

Je voudrais trouver un exemple de programme Dev-C++ qui avec lequel je pourrais régler automatiquement le son du volume pour le périphérique Hauts-parleurs.

Je travaille avec Windows Vista 32 et Seven 32 et 64, ainsi que Dev-C++ en version 4.9.9.2

Je met ci-dessous un code qui fonctionne mais qui ne mer règle pas le volume des HP, mais me crée un nouveau périphérique audio ( je lance ce cede avec le mélangeur de volume ouvert)

Merci à ceux qui ont une idée.

Bernard

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
#include <windows.h>
 
int main(int argc, char *argv[])
{
    int volume = 10;
    WORD wPas  = 65535/100; 
    DWORD Xvol = MAKEWPARAM(volume * wPas ,volume * wPas); 
    HWAVEOUT phwo; 
    MMRESULT BmRetour;
    WAVEFORMATEX pwfx;
 
    pwfx.wFormatTag = WAVE_FORMAT_PCM;
    pwfx.nChannels = 2;
    pwfx.nSamplesPerSec = 44100;
    pwfx.cbSize = 0;
    pwfx.wBitsPerSample = 16;
    pwfx.nBlockAlign = (pwfx.wBitsPerSample >> 3) * pwfx.nChannels;
    pwfx.nAvgBytesPerSec = pwfx.nSamplesPerSec * pwfx.nBlockAlign;
 
    BmRetour = waveOutOpen(&phwo, 0, &pwfx, 0 , 0, WAVE_MAPPED);
 
    if (BmRetour != MMSYSERR_NOERROR)
    {
        MessageBox(0, "Erreur ouverture audio.", 0, 0x10);
        return EXIT_SUCCESS;
    }
 
    BmRetour = waveOutSetVolume(phwo, Xvol);
    if (BmRetour != MMSYSERR_NOERROR)
    {
        MessageBox(0, "Erreur réglage du son", 0, 0x10);
        return EXIT_SUCCESS;
    }
 
    MessageBox(NULL, "OK", "Test BmGetFile", 0);
    waveOutClose(phwo);
 
    return EXIT_SUCCESS;
}