wavReader

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFramesPerBuffer default amount of audio frames read per buffer
	DefaultFramesPerBuffer int = 4096
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option is the type for a function option

func FramesPerBuffer

func FramesPerBuffer(s int) Option

FramesPerBuffer is a functional option which sets the amount of audio frames the wavReader will provide when executing the callback. Example: A buffer with 960 frames at 48000kHz / stereo contains 1920 samples and results in 20ms Audio.

type Options

type Options struct {
	FramesPerBuffer int
}

Options contains the parameters for initializing a wav Reader.

type WavReader

type WavReader struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

WavReader implements the audio.Source interface and is used to read (play) audio frames from a wav source (e.g. file).

func NewWavReader

func NewWavReader(file string, opts ...Option) (*WavReader, error)

NewWavReader reads a wav file from disk into memory and returns a WavReader object which implements the audio.Source interface.

func (*WavReader) Close

func (w *WavReader) Close() error

Close shutsdown the wav player

func (*WavReader) SetCb

func (w *WavReader) SetCb(cb audio.OnDataCb)

SetCb sets the callback which will be executed to provide audio buffers.

func (*WavReader) Start

func (w *WavReader) Start() error

Start will "play" the audio by providing audio buffers through the set callback function.

func (*WavReader) Stop

func (w *WavReader) Stop() error

Stop cancels sending audio through the callback.

Jump to

Keyboard shortcuts

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