wave

package module
v0.0.0-...-495de20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 6 Imported by: 0

README

Golang wave file reader/writer

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataReader

type DataReader interface {
	io.Reader
	io.ReaderAt
}

data 読み込み

type DataReaderChunk

type DataReaderChunk struct {
	ID   []byte     // 'data'
	Size uint32     // 音データの長さ * channel
	Data DataReader // 実際のデータ
}

type DataWriterChunk

type DataWriterChunk struct {
	ID   []byte
	Size uint32
	Data *bytes.Buffer
}

type FmtChunk

type FmtChunk struct {
	ID   []byte // 'fmt '
	Size uint32 // 16
	Data *WavFmtChunkData
}

8 + 16 = 24byte

type Reader

type Reader struct {
	RiffChunk *RiffChunk
	FmtChunk  *FmtChunk
	DataChunk *DataReaderChunk

	NumSamples    uint32
	ReadSampleNum uint32
	SampleTime    int
	// contains filtered or unexported fields
}

func ByteReader

func ByteReader(data []byte) (*Reader, error)

func NewReader

func NewReader(fileName string) (*Reader, error)

func (*Reader) Read

func (rd *Reader) Read(p []byte) (int, error)

音声データのみ読み込む

func (*Reader) ReadRawSample

func (rd *Reader) ReadRawSample() ([]byte, error)

func (*Reader) ReadSample

func (rd *Reader) ReadSample() ([]float64, error)

func (*Reader) ReadSampleInt

func (rd *Reader) ReadSampleInt() ([]int, error)

type RiffChunk

type RiffChunk struct {
	ID         []byte // 'RIFF'
	Size       uint32 // 36bytes + data_chunk_size or whole_file_size - 'RIFF'+ChunkSize (8byte)
	FormatType []byte // 'WAVE'
}

12byte

type WavFmtChunkData

type WavFmtChunkData struct {
	WaveFormatType uint16 // PCM は 1
	Channel        uint16 // monoral or streo
	SamplesPerSec  uint32 // サンプリング周波数 44100
	BytesPerSec    uint32 // 1秒間に必要なbyte数
	BlockSize      uint16 // 量子化精度 * チャンネル数
	BitsPerSamples uint16 // 量子化精度
}

16byte

type WaveReader

type WaveReader interface {
	io.Reader
	io.Seeker
	io.ReaderAt
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(param WriterParam) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

func (*Writer) WriteSample16

func (w *Writer) WriteSample16(samples []int16) (int, error)

func (*Writer) WriteSample24

func (w *Writer) WriteSample24(samples []byte) (int, error)

func (*Writer) WriteSample8

func (w *Writer) WriteSample8(samples []uint8) (int, error)

type WriterParam

type WriterParam struct {
	Out           io.WriteCloser
	Channel       int
	SampleRate    int
	BitsPerSample int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL