Documentation ¶
Index ¶
- Constants
- type AudioSource
- func (a *AudioSource) Active() bool
- func (a *AudioSource) Duration() time.Duration
- func (a *AudioSource) Looping() bool
- func (a *AudioSource) Mute()
- func (a *AudioSource) Muted() bool
- func (a *AudioSource) Pan() float64
- func (a *AudioSource) Pause()
- func (a *AudioSource) Paused() bool
- func (a *AudioSource) Play()
- func (a *AudioSource) Position() time.Duration
- func (a *AudioSource) Progress() float64
- func (a *AudioSource) Rewind()
- func (a *AudioSource) SetFinishedCallback(callbackFn func(*AudioSource))
- func (a *AudioSource) SetLooping(loop bool)
- func (a *AudioSource) SetPan(pan float64)
- func (a *AudioSource) SetSpeedMultiplier(multiplier float64)
- func (a *AudioSource) SetStream(stream beep.StreamSeekCloser, format beep.Format)
- func (a *AudioSource) SetVolume(volume float64)
- func (a *AudioSource) SpeedMultiplier() float64
- func (a *AudioSource) Unmute()
- func (a *AudioSource) Unpause()
- func (a *AudioSource) Volume() float64
Constants ¶
const ( SampleRate = 48000 BufferSizeSamples = 2400 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudioSource ¶
type AudioSource struct {
// contains filtered or unexported fields
}
AudioSource expresses the state of audio playback for a single source of audio data.
func New ¶
func New() *AudioSource
func (*AudioSource) Active ¶
func (a *AudioSource) Active() bool
Active returns true if the Audio is currently Active, meaning that the Audio's Play method has been called, and it has not yet finished playing. If the Audio is not Active, then pausing/unpausing, panning, looping, etc., will appear to have no effect until the Audio's Play method is called. When an Audio is Played, it is marked Active, and then it is automatically marked inactive when it has finished playing.
func (*AudioSource) Duration ¶
func (a *AudioSource) Duration() time.Duration
Duration returns the length of the Audio's raw audio data as a time.Duration
func (*AudioSource) Looping ¶
func (a *AudioSource) Looping() bool
Looping returns true if the Audio is set to loop endlessly.
func (*AudioSource) Mute ¶
func (a *AudioSource) Mute()
Mute mutes the Audio, making it completely silent.
func (*AudioSource) Muted ¶
func (a *AudioSource) Muted() bool
Muted returns true if the Audio is muted.
func (*AudioSource) Pan ¶
func (a *AudioSource) Pan() float64
Pan returns a float between -1 and 1 representing the current pan of the audio. -1 = 100% left channel 0 = 50% left/50% right 1 = 100% right channel
func (*AudioSource) Paused ¶
func (a *AudioSource) Paused() bool
Paused returns true if the Audio is paused.
func (*AudioSource) Play ¶
func (a *AudioSource) Play()
Play unpauses the Audio if it is paused, and re-activates it if it is inactive. The Audio is automatically marked inactive and rewinded when it finishes playing. If Play is called again before the Audio has finished playing, this Audio will appear to stop and restart back at the beginning of the stream.
func (*AudioSource) Position ¶
func (a *AudioSource) Position() time.Duration
Position returns Audio's current position in its raw audio data stream as a time.Duration
func (*AudioSource) Progress ¶
func (a *AudioSource) Progress() float64
Progress returns a float between 0 and 100 representing the percentage of the Audio that has finished playing.
func (*AudioSource) Rewind ¶
func (a *AudioSource) Rewind()
Rewind rewinds the Audio's data stream back to the beginning.
func (*AudioSource) SetFinishedCallback ¶
func (a *AudioSource) SetFinishedCallback(callbackFn func(*AudioSource))
SetFinishedCallback sets the callback function that is called when the Audio has finished playing. This callback function is never called if the Audio is looping.
func (*AudioSource) SetLooping ¶
func (a *AudioSource) SetLooping(loop bool)
SetLooping takes a boolean argument, and sets the Audio to loop endlessly if true.
func (*AudioSource) SetPan ¶
func (a *AudioSource) SetPan(pan float64)
SetPan takes a float between -1 and 1 to control the left-right pan of the audio. -1 = 100% left channel 0 = 50% left/50% right 1 = 100% right channel
func (*AudioSource) SetSpeedMultiplier ¶
func (a *AudioSource) SetSpeedMultiplier(multiplier float64)
SetSpeedMultiplier sets the Audio's speed multiplier. Examples: 1 = normal speed 2 = 2x normal speed 0.5 = 0.5x normal speed
func (*AudioSource) SetStream ¶
func (a *AudioSource) SetStream(stream beep.StreamSeekCloser, format beep.Format)
func (*AudioSource) SetVolume ¶
func (a *AudioSource) SetVolume(volume float64)
SetVolume sets the Audio's volume. It is recommended that you start at 0 and go up or down in increments of 0.5.
func (*AudioSource) SpeedMultiplier ¶
func (a *AudioSource) SpeedMultiplier() float64
SpeedMultiplier returns the Audio's current speed multiplier.
func (*AudioSource) Volume ¶
func (a *AudioSource) Volume() float64
Volume returns the Audio's current volume. This will return the same value regardless of whether the Audio is muted.