wave

package module
v0.0.0-...-20cf3f5 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 6 Imported by: 25 modules, 25 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 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) WriteSample8

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

func (*Writer) WriteSample16

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

func (*Writer) WriteSample24

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

type WriterParam

type WriterParam struct {
	Out            io.WriteCloser
	WaveFormatType int
	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
⌂ 换网址