Option Explicit
Private Type WaveHeader ' 12 bytes riff As String * 4 bytes As Long wave As String * 4 End Type ' Private Type WaveFormat ' 22 bytes fmt As String * 4 chunkSize As Long formatTag As Integer channels As Integer samplesPerSecond As Long aveBytesPerSecond As Long blockAlign As Integer bitsPerSample As Integer End Type ' Private Sub ShowWavHeaderDetails(ByVal sWavFileName As String) ' Dim FileNum As Integer Dim wh As WaveHeader Dim wf As WaveFormat FileNum = FreeFile ' If Len(sWavFileName) > 0 Then Open sWavFileName For Binary As FileNum Get #FileNum, , wh Get #FileNum, , wf Close FileNum Debug.Print w.riff Debug.Print "Bytes: " & CStr(wh.bytes + 8) Debug.Print wh.wave Debug.Print wf.fmt Debug.Print CStr(wf.chunkSize) & " (bytes per chunk)" Debug.Print IIf(wf.formatTag = 1, "Uncommpressed", "Compressed") Debug.Print IIf(wf.channels = 1, "Mono", "Stereo") 'can be mutiple channels too (i.e. Quad) Debug.Print "Sampling Rate: " & CStr(wf.samplesPerSecond) Debug.Print "Bytes Per Second: " & CStr(wf.aveBytesPerSecond) Debug.Print "Sample size in bytes: " & CStr(wf.blockAlign) Debug.Print CStr(wf.bitsPerSample) & " Channels" 'not correct for Layer3 WAV Debug.Print CStr((wh.bytes - 26) / wf.aveBytesPerSecond) & " seconds" End If End Sub |