Documentation ¶
Index ¶
- Variables
- func BatchSamples(data Wave, seconds float64) [][]Frame
- func WriteFrames(samples []Frame, wfmt WaveFmt, file string) error
- func WriteWaveFile(samples []Frame, wfmt WaveFmt, file string) error
- func WriteWaveToWriter(samples []Frame, wfmt WaveFmt, writer io.Writer) error
- type Frame
- type Wave
- type WaveData
- type WaveFmt
- type WaveHeader
Constants ¶
This section is empty.
Variables ¶
var ( ChunkID = []byte{0x52, 0x49, 0x46, 0x46} // RIFF BigEndianChunkID = []byte{0x52, 0x49, 0x46, 0x58} // RIFX WaveID = []byte{0x57, 0x41, 0x56, 0x45} // WAVE Format = []byte{0x66, 0x6d, 0x74, 0x20} // FMT Subchunk2ID = []byte{0x64, 0x61, 0x74, 0x61} // DATA )
Consts that appear in the .WAVE file format
Functions ¶
func BatchSamples ¶
BatchSamples batches the samples per requested timespan expressed in seconds
func WriteFrames ¶
WriteFrames writes the slice to disk as a .wav file the WaveFmt metadata needs to be correct WaveData and WaveHeader are inferred from the samples however..
Types ¶
type Frame ¶
type Frame float64
Frame is a single float64 value of raw audio data
func FloatsToFrames ¶
FloatsToFrames turns a slice of float64 to a slice of frames
type Wave ¶
type Wave struct { WaveHeader WaveFmt WaveData }
Wave represents an entire .wav audio file
func ReadWaveFile ¶
ReadWaveFile parses a .wave file into a Wave struct
type WaveData ¶
type WaveData struct { Subchunk2ID []byte // Identifier of subchunk Subchunk2Size int // size of raw sound data RawData []byte // raw sound data itself Frames []Frame }
WaveData contains the raw sound data
type WaveFmt ¶
type WaveFmt struct { Subchunk1ID []byte // should contain "fmt" Subchunk1Size int // 16 for PCM AudioFormat int // PCM = 1 (Linear Quantization), if not 1, compression was used. NumChannels int // Mono 1, Stereo = 2, .. SampleRate int // 44100 for CD-Quality, etc.. ByteRate int // SampleRate * NumChannels * BitsPerSample / 8 BlockAlign int // NumChannels * BitsPerSample / 8 (number of bytes per sample) BitsPerSample int // 8 bits = 8, 16 bits = 16, .. :-) ExtraParamSize int // if not PCM, can contain extra params ExtraParams []byte // the actual extra params. }
WaveFmt describes the format of the sound-information in the data subchunks
func NewWaveFmt ¶
NewWaveFmt can be used to generate a complete WaveFmt by calculating the remaining props
func (*WaveFmt) SetChannels ¶
SetChannels changes the FMT to adapt to a new amount of channels
type WaveHeader ¶
type WaveHeader struct { ChunkID []byte // should be RIFF on little-endian or RIFX on big-endian systems.. ChunkSize int Format string // sanity-check, should be WAVE (//TODO: keep as []byte?) }
WaveHeader describes the header each WAVE file should start with