Documentation
¶
Overview ¶
Package wav reads WAV files (SPEC §28.3): RIFF files with linear PCM of 8, 16, 24 or 32 bits (also in the WAVE_FORMAT_EXTENSIBLE form) or IEEE float of 32 or 64 bits, with 1 to 8 channels. The samples come out as float32, ready for audio.Stream.Put. Other codecs (ADPCM, Ogg Vorbis, MP3, Opus) are not in Glutter: an app decodes them itself and puts the samples. Flutter has no audio.
It follows the subset of src/audio/SDL_wave.c of SDL 3 (zlib license, third_party/sdl/LICENSE) that the format list above is, translated to Go and changed: the chunks are read one after another, those that are not "fmt " and "data" are skipped, and a data chunk that is longer than the file (a file written to a pipe has the size 0 or 0xFFFFFFFF) takes what there is.
Flutter: no counterpart
Index ¶
Constants ¶
const ( // TagInvalid is the tag of the error of a file that is not a WAV file of the subset this package reads: a message says what is // wrong (the magic, a chunk, the format, the rate, the channels, the size of the data). // // Flutter: no counterpart TagInvalid = "WAVInvalid" // TagReadFailed is the tag of the error of a reader that failed, or whose context ended, while the file was read. // // Flutter: no counterpart TagReadFailed = "WAVReadFailed" )
The tags of the errors of this package (SPEC §28.7).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Audio ¶
type Audio struct {
// Format is the sample rate and the number of channels.
Format audio.Format
// Samples are the interleaved samples from -1 to 1, a whole number of frames.
Samples []float32
// BitsPerSample is the size of the samples in the file, and Float says that they were IEEE float.
BitsPerSample int
Float bool
}
Audio is a decoded WAV file.
Flutter: no counterpart
func Decode ¶
Decode reads a WAV file from r. It fails with WAVInvalid when the file is not a WAV file of the subset above (with a message that says what is wrong), with WAVReadFailed when r fails or ctx ends, and the data it did read is dropped.
Flutter: no counterpart
func DecodeBytes ¶
DecodeBytes reads a WAV file that is in memory. The errors are those of Decode (it does no I/O, so it never fails with WAVReadFailed).
Flutter: no counterpart