Re: Gestion de la carte son

Posté par drcharly93 le 29/7/2004 14:02:49
Salut,
Voir du coté du DirectSound directx
exemple de code en vb
Public DirectX As New DirectX7
Public DS As DirectSound
Public DSBuffer As DirectSoundBuffer

Private Sub Form_Load()
Set DS = DirectX.DirectSoundCreate("")
DS.SetCooperativeLevel Form1.hWnd, DSSCL_PRIORITY
End Sub

Sub LoadWave(File As String)
    Dim bufferDesc As DSBUFFERDESC
    Dim waveFormat As WAVEFORMATEX
    bufferDesc.lFlags = DSBCAPS_CTRLFREQUENCY Or DSBCAPS_CTRLPAN Or DSBCAPS_CTRLVOLUME Or DSBCAPS_STATIC
    
    waveFormat.nFormatTag = WAVE_FORMAT_PCM
    waveFormat.nChannels = 2
    waveFormat.lSamplesPerSec = 22050
    waveFormat.nBitsPerSample = 16
    waveFormat.nBlockAlign = waveFormat.nBitsPerSample / 8 * waveFormat.nChannels
    waveFormat.lAvgBytesPerSec = waveFormat.lSamplesPerSec * waveFormat.nBlockAlign

    Set DSBuffer = DS.CreateSoundBufferFromFile(File, bufferDesc, waveFormat)
End Sub

Sub DSStop ()
DSBuffer.Stop
End Sub

Sub DSPlay ()
DSBuffer.Play DSBPLAY_DEFAULT
End Sub 

Function Volume(vol As Long)
If vol > 0 Then vol = 0
If vol < -5000 Then vol = -5000
DSBuffer.SetVolume vol
End Function


.
pour gerer le son

Function Volume(vol As Long)
If vol > 0 Then vol = 0
If vol < -5000 Then vol = -5000
DSBuffer.SetVolume vol
End Function
.


Ces codes sont issues du site Visual Basic codes sources auteur : DxuTAleX

Cette contribution était de : http://old.wdforge.org/newbb/viewtopic.php?forum=12&topic_id=1172&post_id=4720