Documentation
¶
Overview ¶
Package wave implements a basic audio data library.
Index ¶
- Variables
- func RegisterDecoder(builder DecoderBuilder) error
- type Audio
- type ChunkInfo
- type Decoder
- type DecoderBuilder
- type DecoderBuilderFunc
- type DecoderFunc
- type EditableAudio
- type Float32Interleaved
- func (a *Float32Interleaved) At(i, ch int) Sample
- func (a *Float32Interleaved) ChunkInfo() ChunkInfo
- func (a *Float32Interleaved) SampleFormat() SampleFormat
- func (a *Float32Interleaved) Set(i, ch int, s Sample)
- func (a *Float32Interleaved) SetFloat32(i, ch int, s Float32Sample)
- func (a *Float32Interleaved) SubAudio(offsetSamples, nSamples int) *Float32Interleaved
- type Float32NonInterleaved
- func (a *Float32NonInterleaved) At(i, ch int) Sample
- func (a *Float32NonInterleaved) ChunkInfo() ChunkInfo
- func (a *Float32NonInterleaved) SampleFormat() SampleFormat
- func (a *Float32NonInterleaved) Set(i, ch int, s Sample)
- func (a *Float32NonInterleaved) SetFloat32(i, ch int, s Float32Sample)
- func (a *Float32NonInterleaved) SubAudio(offsetSamples, nSamples int) *Float32NonInterleaved
- type Float32Sample
- type Format
- type Int16Interleaved
- func (a *Int16Interleaved) At(i, ch int) Sample
- func (a *Int16Interleaved) ChunkInfo() ChunkInfo
- func (a *Int16Interleaved) SampleFormat() SampleFormat
- func (a *Int16Interleaved) Set(i, ch int, s Sample)
- func (a *Int16Interleaved) SetInt16(i, ch int, s Int16Sample)
- func (a *Int16Interleaved) SubAudio(offsetSamples, nSamples int) *Int16Interleaved
- type Int16NonInterleaved
- func (a *Int16NonInterleaved) At(i, ch int) Sample
- func (a *Int16NonInterleaved) ChunkInfo() ChunkInfo
- func (a *Int16NonInterleaved) SampleFormat() SampleFormat
- func (a *Int16NonInterleaved) Set(i, ch int, s Sample)
- func (a *Int16NonInterleaved) SetInt16(i, ch int, s Int16Sample)
- func (a *Int16NonInterleaved) SubAudio(offsetSamples, nSamples int) *Int16NonInterleaved
- type Int16Sample
- type Int64Sample
- type RawFormat
- type Sample
- type SampleFormat
Constants ¶
This section is empty.
Variables ¶
var ( Int16SampleFormat = SampleFormatFunc(func(s Sample) Sample { if _, ok := s.(Int16Sample); ok { return s } return Int16Sample(s.Int() >> 16) }) Float32SampleFormat = SampleFormatFunc(func(s Sample) Sample { if _, ok := s.(Float32Sample); ok { return s } return Float32Sample(float32(s.Int()) / 0x100000000) }) )
SampleFormats for the standard formats.
Functions ¶
func RegisterDecoder ¶
func RegisterDecoder(builder DecoderBuilder) error
Types ¶
type Audio ¶
type Audio interface { SampleFormat() SampleFormat ChunkInfo() ChunkInfo At(i, ch int) Sample }
Audio is a finite series of audio Sample values.
type Decoder ¶
type Decoder interface { // Decode decodes raw chunk in endian byte order Decode(endian binary.ByteOrder, chunk []byte, channels int) (Audio, error) }
Decoder decodes raw chunk to Audio
func NewDecoder ¶
NewDecoder creates a decoder to decode raw audio data in the given format
type DecoderBuilder ¶
type DecoderBuilder interface { // NewDecoder creates a new decoder for specified format NewDecoder() (Decoder, Format) }
DecoderBuilder builds raw audio decoder
type DecoderBuilderFunc ¶
DecoderBuilderFunc is a proxy type for DecoderBuilder
func (DecoderBuilderFunc) NewDecoder ¶
func (builderFunc DecoderBuilderFunc) NewDecoder() (Decoder, Format)
type DecoderFunc ¶
DecoderFunc is a proxy type for Decoder
type EditableAudio ¶
EditableAudio is an editable finite series of audio Sample values.
type Float32Interleaved ¶
Float32Interleaved multi-channel interlaced Audio.
func NewFloat32Interleaved ¶
func NewFloat32Interleaved(size ChunkInfo) *Float32Interleaved
func (*Float32Interleaved) At ¶
func (a *Float32Interleaved) At(i, ch int) Sample
func (*Float32Interleaved) ChunkInfo ¶
func (a *Float32Interleaved) ChunkInfo() ChunkInfo
ChunkInfo returns audio chunk size.
func (*Float32Interleaved) SampleFormat ¶
func (a *Float32Interleaved) SampleFormat() SampleFormat
func (*Float32Interleaved) Set ¶
func (a *Float32Interleaved) Set(i, ch int, s Sample)
func (*Float32Interleaved) SetFloat32 ¶
func (a *Float32Interleaved) SetFloat32(i, ch int, s Float32Sample)
func (*Float32Interleaved) SubAudio ¶
func (a *Float32Interleaved) SubAudio(offsetSamples, nSamples int) *Float32Interleaved
SubAudio returns part of the original audio sharing the buffer.
type Float32NonInterleaved ¶
Float32NonInterleaved multi-channel interlaced Audio.
func NewFloat32NonInterleaved ¶
func NewFloat32NonInterleaved(size ChunkInfo) *Float32NonInterleaved
func (*Float32NonInterleaved) At ¶
func (a *Float32NonInterleaved) At(i, ch int) Sample
func (*Float32NonInterleaved) ChunkInfo ¶
func (a *Float32NonInterleaved) ChunkInfo() ChunkInfo
ChunkInfo returns audio chunk size.
func (*Float32NonInterleaved) SampleFormat ¶
func (a *Float32NonInterleaved) SampleFormat() SampleFormat
func (*Float32NonInterleaved) Set ¶
func (a *Float32NonInterleaved) Set(i, ch int, s Sample)
func (*Float32NonInterleaved) SetFloat32 ¶
func (a *Float32NonInterleaved) SetFloat32(i, ch int, s Float32Sample)
func (*Float32NonInterleaved) SubAudio ¶
func (a *Float32NonInterleaved) SubAudio(offsetSamples, nSamples int) *Float32NonInterleaved
SubAudio returns part of the original audio sharing the buffer.
type Float32Sample ¶
type Float32Sample float32
Float32Sample is a 32-bits float audio sample.
func (Float32Sample) Int ¶
func (s Float32Sample) Int() int64
type Int16Interleaved ¶
Int16Interleaved multi-channel interlaced Audio.
func NewInt16Interleaved ¶
func NewInt16Interleaved(size ChunkInfo) *Int16Interleaved
func (*Int16Interleaved) At ¶
func (a *Int16Interleaved) At(i, ch int) Sample
func (*Int16Interleaved) ChunkInfo ¶
func (a *Int16Interleaved) ChunkInfo() ChunkInfo
ChunkInfo returns audio chunk size.
func (*Int16Interleaved) SampleFormat ¶
func (a *Int16Interleaved) SampleFormat() SampleFormat
func (*Int16Interleaved) Set ¶
func (a *Int16Interleaved) Set(i, ch int, s Sample)
func (*Int16Interleaved) SetInt16 ¶
func (a *Int16Interleaved) SetInt16(i, ch int, s Int16Sample)
func (*Int16Interleaved) SubAudio ¶
func (a *Int16Interleaved) SubAudio(offsetSamples, nSamples int) *Int16Interleaved
SubAudio returns part of the original audio sharing the buffer.
type Int16NonInterleaved ¶
Int16NonInterleaved multi-channel interlaced Audio.
func NewInt16NonInterleaved ¶
func NewInt16NonInterleaved(size ChunkInfo) *Int16NonInterleaved
func (*Int16NonInterleaved) At ¶
func (a *Int16NonInterleaved) At(i, ch int) Sample
func (*Int16NonInterleaved) ChunkInfo ¶
func (a *Int16NonInterleaved) ChunkInfo() ChunkInfo
ChunkInfo returns audio chunk size.
func (*Int16NonInterleaved) SampleFormat ¶
func (a *Int16NonInterleaved) SampleFormat() SampleFormat
func (*Int16NonInterleaved) Set ¶
func (a *Int16NonInterleaved) Set(i, ch int, s Sample)
func (*Int16NonInterleaved) SetInt16 ¶
func (a *Int16NonInterleaved) SetInt16(i, ch int, s Int16Sample)
func (*Int16NonInterleaved) SubAudio ¶
func (a *Int16NonInterleaved) SubAudio(offsetSamples, nSamples int) *Int16NonInterleaved
SubAudio returns part of the original audio sharing the buffer.
type Int16Sample ¶
type Int16Sample int16
Int16Sample is a 16-bits signed integer audio sample.
func (Int16Sample) Int ¶
func (s Int16Sample) Int() int64
type Int64Sample ¶
type Int64Sample int64
Int64Sample is a 64-bits signed integer audio sample.
func (Int64Sample) Int ¶
func (s Int64Sample) Int() int64
type Sample ¶
type Sample interface { // Int returns the audio level value for the sample. // A value ranges within [0, 0xffffffff], but is represented by a int64. Int() int64 }
Sample can convert itself to 64-bits signed value.
type SampleFormat ¶
SampleFormat can convert any Sample to one from its own sample format.
func SampleFormatFunc ¶
func SampleFormatFunc(f func(Sample) Sample) SampleFormat
SampleFormatFunc returns a SampleFormat that invokes f to implement the conversion.