Documentation
¶
Index ¶
- Constants
- type PlayerDataReader
- type SoundOutput
- func (so *SoundOutput) Close()
- func (so *SoundOutput) IsPlaying() bool
- func (so *SoundOutput) Pause() error
- func (so *SoundOutput) Play() error
- func (so *SoundOutput) SeekTo(timestampMS float64) (float64, error)
- func (so *SoundOutput) SetSamples(samples []float64)
- func (so *SoundOutput) Stop() error
- func (so *SoundOutput) WaitUntilReady()
- func (so *SoundOutput) WaitUntilStops()
Constants ¶
const SamplesPerMS = float64(SoundOutputSampleRate) * 1 / 1000.0
const SoundOutputSampleRate = 44100
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PlayerDataReader ¶
type PlayerDataReader struct {
// contains filtered or unexported fields
}
func NewPlayerDataReader ¶
func NewPlayerDataReader() *PlayerDataReader
NewPlayerDataReader creates a reader object that is used by the player to play the samples. You don't need to do anything with this construct, it is for the player.
func (*PlayerDataReader) Seek ¶
func (p *PlayerDataReader) Seek(offset int64, whence int) (int64, error)
func (*PlayerDataReader) SetSamples ¶
func (p *PlayerDataReader) SetSamples(samples []float64)
SetSamples switches out the samples to play. It is a thread-safe operation. It won't change the current player's position, there is the Seek function for that.
type SoundOutput ¶
type SoundOutput struct {
IsReady bool
// contains filtered or unexported fields
}
func NewSoundOutput ¶
func NewSoundOutput() (*SoundOutput, error)
NewSoundOutput creates and initialize a sound player that can output a 1 channel 44.1kHz sample composed of float64 values. There can only be one SoundOutput at any times!
func (*SoundOutput) Close ¶
func (so *SoundOutput) Close()
Close closes the player. Call this with defer.
func (*SoundOutput) IsPlaying ¶
func (so *SoundOutput) IsPlaying() bool
IsPlaying returns if the player is playing audio.
func (*SoundOutput) Pause ¶
func (so *SoundOutput) Pause() error
Pause pauses the playback. Can be continued with Play.
func (*SoundOutput) SeekTo ¶
func (so *SoundOutput) SeekTo(timestampMS float64) (float64, error)
SeekTo sets to playback position to corresponding sample position. It will return the timestamp for the actual position which can differ from the requested. This doesn't necessary mean an error.
func (*SoundOutput) SetSamples ¶
func (so *SoundOutput) SetSamples(samples []float64)
SetSamples will set the new samples to play. Currently it resets the sound playback to do so. It will resume playing if it was before.
func (*SoundOutput) Stop ¶
func (so *SoundOutput) Stop() error
Stop stops the playback. Only needed if you want to stop playback early.
func (*SoundOutput) WaitUntilReady ¶
func (so *SoundOutput) WaitUntilReady()
WaitUntilReady waits until the player is usable. Convenience for commandline usage.
func (*SoundOutput) WaitUntilStops ¶
func (so *SoundOutput) WaitUntilStops()
WaitUntilStops waits until the player is usable. Convenience for commandline usage.