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 Clear ¶
func Clear()
Clear removes all currently playing Streamers from the speaker. Previously buffered samples may still be played.
func Close ¶
func Close()
Close closes audio playback. However, the underlying driver context keeps existing, because closing it isn't supported (https://github.com/hajimehoshi/oto/issues/149). In most cases, there is certainly no need to call Close even when the program doesn't play anymore, because in properly set systems, the default mixer handles multiple concurrent processes.
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 Streamers. 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 PlayAndWait ¶ added in v1.4.0
PlayAndWait plays all provided Streamers through the speaker and waits until they have all finished playing.
func Resume ¶ added in v1.4.0
func Resume() error
Resume resumes the entire audio play, which was suspended by Suspend.
Types ¶
This section is empty.