speaker

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 4 Imported by: 443

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.

func Close added in v1.0.2

func Close()

Close closes the playback and the driver. 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. It's only when the default device is not a virtual but hardware device, that you'll probably want to manually manage the device from your application.

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 Play

func Play(s ...beep.Streamer)

Play starts playing all provided Streamers through the speaker.

func Unlock

func Unlock()

Unlock unlocks the speaker. Call after modifying any currently playing Streamer.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL