Documentation ¶
Index ¶
- type AnalysisResult
- type AudioBuffer
- type AudioProperties
- type AudioProperty
- type DSPChannel
- type IEffect
- type Player
- func (p *Player) AddEffect(id any, effect IEffect) *Player
- func (p *Player) CopyProperties(other *Player) *Player
- func (p *Player) Effect(id any) IEffect
- func (p *Player) Read(bytes []byte) (n int, err error)
- func (p *Player) Seek(offset int64, whence int) (int64, error)
- func (p *Player) SetDSPChannel(c *DSPChannel) *Player
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisResult ¶
type AnalysisResult struct {
Normalization float64
}
AnalysisResult is an object that contains the results of an analysis performed on a stream.
type AudioBuffer ¶
type AudioBuffer []byte
AudioBuffer wraps a []byte of audio data and provides handy functions to get and set values for a specific position in the buffer.
func (AudioBuffer) Get ¶
func (ab AudioBuffer) Get(i int) (l, r float64)
Get returns the values for the left and right audio channels at the specified stream sample index. The values returned for the left and right audio channels range from 0 to 1.
func (AudioBuffer) Len ¶
func (ab AudioBuffer) Len() int
func (AudioBuffer) Set ¶
func (ab AudioBuffer) Set(i int, l, r float64)
Set sets the left and right audio channel values at the specified stream sample index. The values should range from 0 to 1.
func (AudioBuffer) String ¶
func (ab AudioBuffer) String() string
type AudioProperties ¶
type AudioProperties map[any]*AudioProperty
func NewAudioProperties ¶
func NewAudioProperties() AudioProperties
func (AudioProperties) Get ¶
func (ap AudioProperties) Get(id any) *AudioProperty
Get gets the audio property associated with some identifier. This could be, for example, the original filepath of the audio stream.
type AudioProperty ¶
type AudioProperty struct {
// contains filtered or unexported fields
}
AudioProperty is an object that allows associating an AnalysisResult for a specific stream with a name for that stream.
func (*AudioProperty) Analyze ¶
func (ap *AudioProperty) Analyze(stream io.ReadSeeker, scanCount int64) (AnalysisResult, error)
Analyze analyzes the provided audio stream, returning an AnalysisResult object. The stream is the audio stream to be used for scanning, and the scanCount is the number of times the function should scan various parts of the audio stream. The higher the scan count, the more accurate the results should be, but the longer the scan would take. A scanCount of 16 means it samples the stream 16 times evenly throughout the file. If a scanCount of 0 or less is provided, it will default to 64.
func (*AudioProperty) ResetAnalyzation ¶
func (ap *AudioProperty) ResetAnalyzation()
type DSPChannel ¶
type DSPChannel struct { Active bool Effects map[any]IEffect EffectOrder []IEffect // contains filtered or unexported fields }
DSPChannel represents an audio channel that can have various effects applied to it. Any Players that have a DSPChannel set will take on the effects applied to the channel as well.
func (*DSPChannel) AddEffect ¶ added in v0.3.0
func (d *DSPChannel) AddEffect(id any, effect IEffect) *DSPChannel
AddEffect adds the specified Effect to the DSPChannel under the given identification. Note that effects added to DSPChannels don't need to specify source streams, as the DSPChannel automatically handles this.
func (*DSPChannel) Close ¶ added in v0.3.0
func (d *DSPChannel) Close()
Close closes the DSP channel. When closed, any players that play on the channel do not play and automatically close their sources. Closing the channel can be used to stop any sounds that might be playing back on the DSPChannel.
type IEffect ¶
type IEffect interface { io.ReadSeeker ApplyEffect(data []byte, bytesRead int) // This function is called when sound data goes through an effect. The effect should modify the data byte buffer. }
IEffect indicates an effect that implements io.ReadSeeker and generally takes effect on an existing audio stream. It represents the result of applying an effect to an audio stream, and is playable in its own right.
type Player ¶ added in v0.3.0
type Player struct { *audio.Player DSPChannel *DSPChannel Source io.ReadSeeker EffectOrder []IEffect Effects map[any]IEffect }
Player handles playback of audio and effects. Player embeds audio.Player and so has all of the functions and abilities of the default audio.Player while also applying effects either played from its source, through the Player's Effects, or through the Player's DSPChannel.
func NewPlayer ¶ added in v0.3.0
func NewPlayer(sourceStream io.ReadSeeker) (*Player, error)
NewPlayer creates a new Player to playback an io.ReadSeeker-fulfilling audio stream.
func NewPlayerFromPlayer ¶ added in v0.3.0
NewPlayerFromPlayer creates a new resound.Player from an existing *audio.Player.
func (*Player) AddEffect ¶ added in v0.3.0
AddEffect adds the specified Effect to the Player, with the given ID.
func (*Player) CopyProperties ¶ added in v0.3.0
CopyProperties copies the properties (effects, current DSP Channel, etc) from one resound.Player to the other. Note that this won't duplicate the current state of playback of the internal audio stream.
func (*Player) Effect ¶ added in v0.3.0
Effect returns the effect associated with the given id. If an effect with the provided ID doesn't exist, this function will return nil.
func (*Player) SetDSPChannel ¶ added in v0.3.0
func (p *Player) SetDSPChannel(c *DSPChannel) *Player
SetDSPChannel sets the DSPChannel to be used for playing audio back through the Player.