wav

package
v2.9.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 112

Documentation

Overview

Package wav provides WAV (RIFF) decoder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stream

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

Stream is a decoded audio stream.

The format is signed 16bit integer little endian PCM (DecodeWithoutResampling, etc.), or 32bit float little endian PCM (DeocdeF32). The channel count is 2.

func Decode deprecated

func Decode(context *audio.Context, src io.Reader) (*Stream, error)

Decode decodes WAV (RIFF) data to playable stream in signed 16bit integer, little endian, 2 channels (stereo) format.

The format must be 1 or 2 channels, 8bit or 16bit little endian PCM. The format is converted into 2 channels and 16bit.

Decode returns error when decoding fails or IO error happens.

Decode automatically resamples the stream to fit with the audio context if necessary.

The returned Stream's Seek is available only when src is an io.Seeker.

A Stream doesn't close src even if src implements io.Closer. Closing the source is src owner's responsibility.

Deprecated: as of v2.1. Use DecodeWithSampleRate instead.

func DecodeF32 added in v2.8.0

func DecodeF32(src io.Reader) (*Stream, error)

DecodeF32 decodes WAV (RIFF) data to playable stream in 32bit float, little endian, 2 channels (stereo) format.

The src format must be 1 or 2 channels, 8bit or 16bit little endian PCM. The src format is converted into 2 channels and 16bit.

DecodeF32 returns error when decoding fails or IO error happens.

The returned Stream's Seek is available only when src is an io.Seeker.

A Stream doesn't close src even if src implements io.Closer. Closing the source is src owner's responsibility.

func DecodeWithSampleRate added in v2.1.0

func DecodeWithSampleRate(sampleRate int, src io.Reader) (*Stream, error)

DecodeWithSampleRate decodes WAV (RIFF) data to playable stream in signed 16bit integer, little endian, 2 channels (stereo) format.

The format must be 1 or 2 channels, 8bit or 16bit little endian PCM. The format is converted into 2 channels and 16bit.

DecodeWithSampleRate returns error when decoding fails or IO error happens.

DecodeWithSampleRate automatically resamples the stream to fit with sampleRate if necessary.

The returned Stream's Seek is available only when src is an io.Seeker.

A Stream doesn't close src even if src implements io.Closer. Closing the source is src owner's responsibility.

Resampling can be a very heavy task. Stream has a cache for resampling, but the size is limited. Do not expect that Stream has a resampling cache even after whole data is played.

func DecodeWithoutResampling added in v2.4.0

func DecodeWithoutResampling(src io.Reader) (*Stream, error)

DecodeWithoutResampling decodes WAV (RIFF) data to playable stream in signed 16bit integer, little endian, 2 channels (stereo) format.

The src format must be 1 or 2 channels, 8bit or 16bit little endian PCM. The src format is converted into 2 channels and 16bit.

DecodeWithoutSampleRate returns error when decoding fails or IO error happens.

The returned Stream's Seek is available only when src is an io.Seeker.

A Stream doesn't close src even if src implements io.Closer. Closing the source is src owner's responsibility.

func (*Stream) Length

func (s *Stream) Length() int64

Length returns the size of decoded stream in bytes.

func (*Stream) Read

func (s *Stream) Read(p []byte) (int, error)

Read is implementation of io.Reader's Read.

func (*Stream) SampleRate added in v2.8.0

func (s *Stream) SampleRate() int

SampleRate returns the sample rate of the decoded stream.

func (*Stream) Seek

func (s *Stream) Seek(offset int64, whence int) (int64, error)

Seek is implementation of io.Seeker's Seek.

Note that Seek can take long since decoding is a relatively heavy task.

If the underlying source is not an io.Seeker, Seek panics.

Jump to

Keyboard shortcuts

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