wavWriter

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 (
	// DefaultChannels recorded into a wav file
	DefaultChannels int = 1
	// DefaultSamplerate for writing wav files to disk
	DefaultSamplerate float64 = 48000
	// DefaultBitDepth for writing audio samples to disk
	DefaultBitDepth int = 16
)

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 BitDepth

func BitDepth(b int) Option

BitDepth is a functional option to set the bit depth with which the audio will be written to file. The Bitdepth (12/16 bit) defines the dynamic range of the audio. For most usecases 16 bit (default) is the way to go. The higher the bitDepth, the larger the recordings are.

func Channels

func Channels(chs int) Option

Channels is a functional option to set the amount of channels to be used with the audio device. Typically this is either Mono (1) or Stereo (2).

func Samplerate

func Samplerate(s float64) Option

Samplerate is a functional option to set the sampling rate with which the audio will be recorded. The higher the samplerate, the higher larger the recordings are.

type Options

type Options struct {
	Channels   int
	Samplerate float64
	BitDepth   int
}

Options contains the parameters for initializing a wav writer.

type WavWriter

type WavWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

WavWriter implements the audio.Sink interface and is used to write (record) audio frames in the wav format.

func NewWavWriter

func NewWavWriter(path string, opts ...Option) (*WavWriter, error)

NewWavWriter returns a wavWriter to which audio frames can be written to. The audio data will be saved in the wav format.

func (*WavWriter) Close

func (w *WavWriter) Close() error

Close shuts down properly the wavWriter.

func (*WavWriter) Flush

func (w *WavWriter) Flush()

Flush is not implemented

func (*WavWriter) SetVolume

func (w *WavWriter) SetVolume(v float32)

SetVolume sets the volume for all incoming audio frames.

func (*WavWriter) Start

func (w *WavWriter) Start() error

Start writing audio to the wav file.

func (*WavWriter) Stop

func (w *WavWriter) Stop() error

Stop writing audio frames to the wav file.

func (*WavWriter) Volume

func (w *WavWriter) Volume() float32

Volume returns the current volume.

func (*WavWriter) Write

func (w *WavWriter) Write(msg audio.Msg) error

Write enqueues audio buffers to be written into the wav file. Channels and Samplerate will be adjusted, if necessary.

Jump to

Keyboard shortcuts

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