mixing

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Unlicense Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultMixerVolume

func GetDefaultMixerVolume(numMixedChannels int) volume.Volume

GetDefaultMixerVolume returns the default mixer volume value based on the number of mixed channels not to be confused with the number of output channels

Types

type ChannelData

type ChannelData []Data

ChannelData is a single channel's data

type Data

type Data struct {
	Data       MixBuffer
	Pan        panning.Position
	Volume     volume.Volume
	Pos        int
	SamplesLen int
	Flush      func()
}

Data is a single buffer of data at a specific panning position

type MixBuffer

type MixBuffer []volume.Matrix

MixBuffer is a buffer of premixed volume data intended to be eventually sent out to the sound output device after conversion to the output format

func (*MixBuffer) Add

func (m *MixBuffer) Add(pos int, rhs *MixBuffer, volMtx volume.Matrix)

Add will mix in another MixBuffer's data

func (*MixBuffer) C

func (m *MixBuffer) C() (chan<- SampleMixIn, func())

C returns a channel and a function that flushes any outstanding mix-ins and closes the channel

func (*MixBuffer) MixInSample

func (m *MixBuffer) MixInSample(d SampleMixIn)

MixInSample mixes in a single sample entry into the mix buffer

func (*MixBuffer) ToIntStream

func (m *MixBuffer) ToIntStream(outputChannels int, samples int, bitsPerSample int, mixerVolume volume.Volume) [][]int32

ToIntStream converts a mixbuffer into an int stream intended to be output to the output sound device

func (*MixBuffer) ToRenderData

func (m *MixBuffer) ToRenderData(samples int, channels int, mixerVolume volume.Volume, formatter sampling.Formatter) []byte

ToRenderData converts a mixbuffer into a byte stream intended to be output to the output sound device

func (*MixBuffer) ToRenderDataWithBufs

func (m *MixBuffer) ToRenderDataWithBufs(outBuffers [][]byte, samples int, mixerVolume volume.Volume, formatter sampling.Formatter)

ToRenderDataWithBufs converts a mixbuffer into a byte stream intended to be output to the output sound device

type Mixer

type Mixer struct {
	Channels int
}

Mixer is a manager for mixing multiple single- and multi-channel samples into a single multi-channel output stream

func (Mixer) Flatten

func (m Mixer) Flatten(panmixer PanMixer, samplesLen int, row []ChannelData, mixerVolume volume.Volume, sampleFormat sampling.Format) []byte

Flatten will to a final saturation mix of all the row's channel data into a single output buffer

func (Mixer) FlattenTo

func (m Mixer) FlattenTo(resultBuffers [][]byte, panmixer PanMixer, samplesLen int, row []ChannelData, mixerVolume volume.Volume, sampleFormat sampling.Format)

FlattenTo will to a final saturation mix of all the row's channel data into a single output buffer

func (Mixer) FlattenToInts

func (m Mixer) FlattenToInts(panmixer PanMixer, samplesLen, bitsPerSample int, row []ChannelData, mixerVolume volume.Volume) [][]int32

FlattenToInts runs a flatten on the channel data into separate channel data of int32 variety these int32s still respect the bitsPerSample size

func (Mixer) NewMixBuffer

func (m Mixer) NewMixBuffer(samples int) MixBuffer

NewMixBuffer returns a mixer buffer with a number of channels of preallocated sample data

type PanMixer

type PanMixer interface {
	GetMixingMatrix(panning.Position) volume.Matrix
	NumChannels() int
}

PanMixer is a mixer that's specialized for mixing multichannel audio content

var PanMixerMono PanMixer = &panMixerMono{}

PanMixerMono is a mixer that's specialized for mixing monaural audio content

var PanMixerQuad PanMixer = &panMixerQuad{}

PanMixerQuad is a mixer that's specialized for mixing quadraphonic audio content

var PanMixerStereo PanMixer = &panMixerStereo{}

PanMixerStereo is a mixer that's specialized for mixing stereo audio content

func GetPanMixer

func GetPanMixer(channels int) PanMixer

GetPanMixer returns the panning mixer that can generate a matrix based on input pan value

type SampleMixIn

type SampleMixIn struct {
	Sample    sampling.Sampler
	StaticVol volume.Volume
	VolMatrix volume.Matrix
	MixPos    int
	MixLen    int
}

SampleMixIn is the parameters for mixing in a sample into a MixBuffer

Jump to

Keyboard shortcuts

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