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 41 42
| Declare Function waveInOpen Lib "winmm.dll" Alias "waveInOpen" (ByVal lphWaveIn As Long, ByVal uDeviceID As Long, ByVal lpFormat As WAVEFORMAT, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Private Format As WAVEFORMAT
Structure WAVEFORMAT
Dim wFormatTag As Integer
Dim nChannels As Integer
Dim nSamplesPerSec As Long
Dim nAvgBytesPerSec As Long
Dim nBlockAlign As Integer
Dim wBitsPerSample As Integer
Dim cbSize As Integer
End Structure
Structure WAVEHDR
Dim lpData As Long
Dim dwBufferLength As Long
Dim dwBytesRecorded As Long
Dim dwUser As Long
Dim dwFlags As Long
Dim dwLoops As Long
Dim lpNext As Long
Dim Reserved As Long
End Structure
Public Structure WaveFormatEx
Public FormatTag As Int16
Public Channels As Int16
Public SamplesPerSec As Int32
Public AvgBytesPerSec As Int32
Public BlockAlign As Int16
Public BitsPerSample As Int16
Public ExtraDataSize As Int16
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Format = New WaveFormat()
Format.nChannels = 1
Format.nSamplesPerSec = 44100
Format.nAvgBytesPerSec = 44100
Format.nBlockAlign = 1
Format.wBitsPerSample = 8
Format.cbSize = 0
Dim hWaveIn As Long
Dim rc As Long = waveInOpen(hWaveIn, -1, Format, 0, 0, 0)
End Sub |
Partager