WaveOutOpen: Unterschied zwischen den Versionen

Aus API-Wiki
Wechseln zu: Navigation, Suche
(neu angelegt (draft))
(kein Unterschied)

Version vom 8. Januar 2009, 19:59 Uhr

Die API-Funktion waveOutOpen gibt Auskunft über XYZ.

Declare Function waveOutOpen lib "winmm.dll" _

                Alias "waveOutOpen" ( _
                ByRef lphWaveOut As Long, _
                ByVal uDeviceID As Long, _
                ByRef lpFormat As WAVEFORMAT, _
                ByVal dwCallback As Long, _
                ByVal dwInstance As Long, _
                ByVal dwFlags As Long) As Long


Parameter

lphWaveOut

Variable vom Datentyp Long welche das Device Handle erhält.

uDeviceID

ID des Devices welches geöffnet werden soll. Siehe auch waveOutGetDevCaps.

lpFormat

Struktur welche das Format der Daten definiert die dem Device zum Abspielen übergeben werden sollen.

dwCallback

Zeiger auf eine Callback Funktion. Vorsicht, bei Verwendung dürfen innerhalb dieser Funktion nur eingeschränkte Befehle verwendet werden!

dwInstance

Beschreibung

dwFlags

Beschreibung


Rückgabe(n)

Die Funktion gibt einen Wert des Types Long zurück. 0 bei Erfolg ansonsten Fehlercode


[OPTIONAL] Beispiel

Private Declare Function waveOutOpen Lib "winmm.dll" (hWaveOut As Long, _

       ByVal uDeviceID As Long, Format As Any, ByVal dwCallback As Long, _
       ByVal dwInstance As Long, ByVal dwFlags As Long) As Long

Private Type WAVEFORMATEX

   wFormatTag          As Integer
   nChannels           As Integer
   nSamplesPerSec      As Long
   nAvgBytesPerSec     As Long
   nBlockAlign         As Integer
   wBitsPerSample      As Integer
   cbSize              As Integer

End Type

Private Const WAVE_FORMAT_PCM As Long = 1 Private Const CALLBACK_FUNCTION As Long = &H30000 Private Const INVALID_HANDLE_VALUE As Long = -1

Private Sub OpenOutputDevice(DevID As Long, Samplerate As Long)

   Dim udtWaveFormat As WAVEFORMATEX
   
   With udtWaveFormat
       .cbSize = 0
       .wFormatTag = WAVE_FORMAT_PCM
       .nChannels = 1
       .nSamplesPerSec = Samplerate
       .wBitsPerSample = 16
       .nBlockAlign = .wBitsPerSample / 8
       .nAvgBytesPerSec = Samplerate * .nBlockAlign
   End With
   
   If waveOutOpen(hDevice, DevID, udtWaveFormat, AddressOf CallBack, 0, CALLBACK_FUNCTION) <> 0 Then
       'Failed
       hDevice = INVALID_HANDLE_VALUE
   Else
       'Success
       ReDim btWaveOutBuffer1(cSamplesPerCluster * (lBitDepth \ 8) - 1)
       ReDim btWaveOutBuffer2(cSamplesPerCluster * (lBitDepth \ 8) - 1)
       With udtBuffer1Hdr
           .lpData = VarPtr(btWaveOutBuffer1(0))
           .dwBufferLength = UBound(btWaveOutBuffer1) + 1
           .dwUser = 1
       End With
       With udtBuffer2Hdr
           .lpData = VarPtr(btWaveOutBuffer2(0))
           .dwBufferLength = UBound(btWaveOutBuffer2) + 1
           .dwUser = 2
       End With
       If waveOutPrepareHeader(hDevice, udtBuffer1Hdr, LenB(udtBuffer1Hdr)) Or _
               waveOutPrepareHeader(hDevice, udtBuffer2Hdr, LenB(udtBuffer2Hdr)) > 0 Then
           waveOutUnprepareHeader hDevice, udtBuffer1Hdr, LenB(udtBuffer1Hdr)
           waveOutUnprepareHeader hDevice, udtBuffer2Hdr, LenB(udtBuffer2Hdr)
           waveOutClose hDevice
           hDevice = INVALID_HANDLE_VALUE
       End If
   End If

End Sub


[PFLICHT] Quelle(n)

  • MSDN US-Libary