audio

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster added in v0.1.2

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

Broadcaster is a specialized video broadcaster.

func NewBroadcaster added in v0.1.2

func NewBroadcaster(source Reader, config *BroadcasterConfig) *Broadcaster

NewBroadcaster creates a new broadcaster. Source is expected to drop chunks when any of the readers is slower than the source.

func (*Broadcaster) NewReader added in v0.1.2

func (broadcaster *Broadcaster) NewReader(copyChunk bool) Reader

NewReader creates a new reader. Each reader will retrieve the same data from the source. copyFn is used to copy the data from the source to individual readers. Broadcaster uses a small ring buffer, this means that slow readers might miss some data if they're really late and the data is no longer in the ring buffer.

func (*Broadcaster) ReplaceSource added in v0.1.2

func (broadcaster *Broadcaster) ReplaceSource(source Reader) error

ReplaceSource replaces the underlying source. This operation is thread safe.

func (*Broadcaster) Source added in v0.1.2

func (broadcaster *Broadcaster) Source() Reader

Source retrieves the underlying source. This operation is thread safe.

type BroadcasterConfig added in v0.1.2

type BroadcasterConfig struct {
	Core *io.BroadcasterConfig
}

type Reader

type Reader interface {
	// Read reads data from the source. The caller is responsible to release the memory that's associated
	// with data by calling the given release function. When err is not nil, the caller MUST NOT call release
	// as data is going to be nil (no memory was given). Otherwise, the caller SHOULD call release after
	// using the data. The caller is NOT REQUIRED to call release, as this is only a part of memory management
	// optimization. If release is not called, the source is forced to allocate a new memory, which also means
	// there will be new allocations during streaming, and old unused memory will become garbage. As a consequence,
	// these garbage will put a lot of pressure to the garbage collector and makes it to run more often and finish
	// slower as the heap memory usage increases and more garbage to collect.
	Read() (chunk wave.Audio, release func(), err error)
}

type ReaderFunc

type ReaderFunc func() (chunk wave.Audio, release func(), err error)

func (ReaderFunc) Read

func (rf ReaderFunc) Read() (chunk wave.Audio, release func(), err error)

type TransformFunc

type TransformFunc func(r Reader) Reader

TransformFunc produces a new Reader that will produces a transformed audio

func DetectChanges added in v0.1.2

func DetectChanges(interval time.Duration, onChange func(prop.Media)) TransformFunc

DetectChanges will detect chunk and audio property changes. For audio property detection, since it's time related, interval will be used to determine the sample rate.

func Merge

func Merge(transforms ...TransformFunc) TransformFunc

Merge merges transforms and produces a new TransformFunc that will execute transforms in order

func NewBuffer

func NewBuffer(nSamples int) TransformFunc

NewBuffer creates audio transform to buffer signal to have exact nSample samples.

func NewChannelMixer

func NewChannelMixer(channels int, mixer mixer.ChannelMixer) TransformFunc

NewChannelMixer creates audio transform to mix audio channels.

Jump to

Keyboard shortcuts

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