Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataReader ¶
DataReader defines interface for DataReader
type DataReaderChunk ¶
type DataReaderChunk struct { ID []byte // 'data' Size uint32 // sound data length * channels Data DataReader // Actual data }
DataReaderChunk defines a data chunk with reader
type DataWriterChunk ¶
DataWriterChunk defines a data chunk with a writer
type FmtChunk ¶
type FmtChunk struct { ID []byte // 'fmt ' Size uint32 // 16 Data *FmtChunkData }
FmtChunk is with 8 + 16 = 24 bytes
type FmtChunkData ¶
type FmtChunkData struct { WaveFormatType uint16 // PCM は 1 Channel uint16 // monoral or stereo SamplesPerSec uint32 // Sampling frequency: 8000, 16000 or 44100 BytesPerSec uint32 // the number of bytes required per second BlockSize uint16 // Quantization accuracy * Number of channels BitsPerSamples uint16 }
FmtChunkData is with 16 bytes
type Reader ¶
type Reader struct { RiffChunk *RiffChunk FmtChunk *FmtChunk DataChunk *DataReaderChunk NumSamples uint32 ReadSampleNum uint32 SampleTime int // contains filtered or unexported fields }
Reader defines a struct implements WaveHeader interface
func NewReaderFromBytes ¶
NewReaderFromBytes creates a Reader from a byte slice
func NewReaderFromFile ¶
NewReaderFromFile opens a file and creates a new reader of it.
func (*Reader) ReadRawSample ¶
ReadRawSample reads raw sample
func (*Reader) ReadSample ¶
ReadSample reads sample as float64 slice
func (*Reader) ReadSampleInt ¶
ReadSampleInt reads sample as int slice
type RiffChunk ¶
type RiffChunk struct { ID []byte // 'RIFF' Size uint32 // 36bytes + data_chunk_size or whole_file_size - 'RIFF'+ChunkSize (8byte) FormatType []byte // 'WAVE' }
RiffChunk has 12 bytes
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer defines a writer to write data to a wave file
func NewWriter ¶
func NewWriter(param WriterParam) (*Writer, error)
NewWriter creates and writes wave data to a wave file.
func (*Writer) WriteSample16 ¶
WriteSample16 writes int16 slice samples to the writer
type WriterParam ¶
type WriterParam struct { Out io.WriteCloser Channel int SampleRate int BitsPerSample int }
WriterParam defines the parameters for creating a new writer