Le son de Windows

nem02004 Messages postés 47 Date d'inscription vendredi 21 mai 2004 Statut Membre Dernière intervention 23 avril 2007 - 7 juil. 2006 à 22:38
SAKingdom Messages postés 3212 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 16 février 2009 - 8 juil. 2006 à 16:46
#include <mmsystem.h>

int main () {
waveOutSetVolume(NULL, (DWORD)0x0000);
}

Je voudrais couper le son de l'ordi, mais ca marche pas, comment faire svp ?

2 réponses

SAKingdom Messages postés 3212 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 16 février 2009 15
8 juil. 2006 à 16:44
Essais ça:

#include <windows.h>

#pragma comment(lib, "winmm.lib")

void CALLBACK WaveProc(HWAVEOUT hWo, UINT Msg, DWORD dwInst, DWORD dwP1, DWORD dwP2)
{
    switch(Msg)
    {
    case WOM_OPEN:
        MessageBox(0, "Device Audio is open !", 0, 0x40);
        return;

    case WOM_CLOSE:
        MessageBox(0, "Audio Device is closed !", 0, 0x40);
        return;
    }
}

BOOL SetToZero(void)
{
    MMRESULT mRsl;
    HWAVEOUT hWo;
    WAVEFORMATEX wFormat;
  
    wFormat.cbSize = sizeof(WAVEFORMATEX);
    wFormat.nSamplesPerSec = 44100;
    wFormat.wBitsPerSample = 16;
    wFormat.nChannels = 2;
    wFormat.wFormatTag = WAVE_FORMAT_PCM;
    wFormat.nBlockAlign = wFormat.nChannels * wFormat.wBitsPerSample / 8;
    wFormat.nAvgBytesPerSec = wFormat.nSamplesPerSec * wFormat.nBlockAlign;

    mRsl = waveOutOpen(&hWo, 0, &wFormat, (DWORD)WaveProc, 0,
                        CALLBACK_FUNCTION );

    if (mRsl != MMSYSERR_NOERROR)
    {
        MessageBox(0, "Erreur during opening Audio Device.", 0, 0x10);
        return FASLE;
    }

    waveOutSetVolume(hWo, 0);
    Sleep(5000);
    waveOutSetVolume(hWo, 0x7FFF7FFF);
  
    waveOutClose(hWo);
    return TRUE;
}

Va lire la documentation sur waveOutSetVolume ici

_______________________________________
Venez débattre de sujets touchant à la programmation ici
0
SAKingdom Messages postés 3212 Date d'inscription lundi 7 novembre 2005 Statut Membre Dernière intervention 16 février 2009 15
8 juil. 2006 à 16:46
Oups petite erreure avec le return FALSE. J'ai écrit return FASLE.

_______________________________________
Venez débattre de sujets touchant à la programmation ici
0
Rejoignez-nous