GetWaveInfo
If you've ever wondered how sound applications can show the kilohertz and samples per second information about a waveform file (.WAV), the answer lies in the RIFF file format. The RIFF file format is designed to be as generic as possible. It is used for waveform, AVI, palette, and other information standards that may need to be mixed and used together. Generally speaking, though, any file with a WAV extension will only contain waveform data. RIFF provides information in chunks and subchunks. The header for each chunk describes the length of the chunk and the type of data the chunk contains (WAVE, for instance, is the string identifying a WAVE chunk). The Wave subchunk is immediately followed by the WAVE Format Chunk. It is this small chunk that defines the structure of the waveform data that will follow. It defines the format of the waveform, the number of channels used (with 0 being mono, 1 being stereo), the sampling rate, the kilohertz at which is was recorded, and the data block size. Of these, only mono/stereo and the sampling rate are likely to be of interest unless you intend to write your own custom waveform player.
Tóm tắt bởi AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Public Function GetWaveInfo(Byval filename As String, Byref w As WAVInfo) _
As Boolean
Dim ff As Integer
ff = FreeFile
On Error GoTo ehandler
Open filename For Binary Access Read As #ff
On Error GoTo ehandler_fo
Get #ff, , w
Close #ff
On Error GoTo ehandler
If w.Riff_Format = RIFF_ID And w.ChunkID = _
RIFF_WAVE And w.fmt = RIFF_FMT Then
GetWaveInfo = True
Else
GetWaveInfo = False
End If
Exit Function
ehandler_fo:
Close #ff
ehandler:
GetWaveInfo = False
End Function
Upload