Documentation
¶
Overview ¶
Package speaker implements playback of beep.Streamer values through physical speakers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(sampleRate beep.SampleRate, bufferSize int) error
Init initializes audio playback through speaker. Must be called before using this package.
The bufferSize argument specifies the number of samples of the speaker's buffer. Bigger bufferSize means lower CPU usage and more reliable playback. Lower bufferSize means better responsiveness and less delay.
func Lock ¶
func Lock()
Lock locks the speaker. While locked, speaker won't pull new data from the playing Stramers. Lock if you want to modify any currently playing Streamers to avoid race conditions.
Always lock speaker for as little time as possible, to avoid playback glitches.
func UnderrunCallback ¶
func UnderrunCallback(f func())
UnderrunCallback sets a function which will be called when an underrun occurs. This is useful for debugging and optimization purposes.
Underrun happens when program doesn't keep up with the audio playback and doesn't supply audio data quickly enough. To fix an underrun, you either need to optimize your audio processing code, or increase the buffer size.
Underrun detection currently works on Linux.
Types ¶
This section is empty.