Documentation
¶
Overview ¶
Package audio provides sound playback using the oto audio library.
Index ¶
Constants ¶
View Source
const SampleRate = 44100
SampleRate is the playback rate in Hz. Must match the oto context sample rate.
Variables ¶
View Source
var Sounds = map[string]SoundDefinition{ "warning": { Name: "warning", Description: "Two-tone alternating warning signal", Segments: []ToneSegment{ {Frequency: 800, Duration: 150 * time.Millisecond, Volume: 0.7}, {Frequency: 600, Duration: 150 * time.Millisecond, Volume: 0.7}, {Frequency: 800, Duration: 150 * time.Millisecond, Volume: 0.7}, {Frequency: 600, Duration: 150 * time.Millisecond, Volume: 0.7}, }, }, "success": { Name: "success", Description: "Ascending major chord chime", Segments: []ToneSegment{ {Frequency: 523.25, Duration: 120 * time.Millisecond, Volume: 0.6}, {Frequency: 659.25, Duration: 120 * time.Millisecond, Volume: 0.6}, {Frequency: 783.99, Duration: 250 * time.Millisecond, Volume: 0.7}, }, }, "error": { Name: "error", Description: "Low descending buzz indicating failure", Segments: []ToneSegment{ {Frequency: 400, Duration: 200 * time.Millisecond, Volume: 0.8}, {Frequency: 300, Duration: 200 * time.Millisecond, Volume: 0.8}, {Frequency: 200, Duration: 300 * time.Millisecond, Volume: 0.9}, }, }, "info": { Name: "info", Description: "Single clean informational beep", Segments: []ToneSegment{ {Frequency: 880, Duration: 200 * time.Millisecond, Volume: 0.5}, }, }, "alert": { Name: "alert", Description: "Rapid high-pitched attention signal", Segments: []ToneSegment{ {Frequency: 1200, Duration: 80 * time.Millisecond, Volume: 0.7}, {Frequency: 0, Duration: 40 * time.Millisecond, Volume: 0}, {Frequency: 1200, Duration: 80 * time.Millisecond, Volume: 0.7}, {Frequency: 0, Duration: 40 * time.Millisecond, Volume: 0}, {Frequency: 1200, Duration: 80 * time.Millisecond, Volume: 0.7}, }, }, "notification": { Name: "notification", Description: "Gentle two-note doorbell chime", Segments: []ToneSegment{ {Frequency: 659.25, Duration: 200 * time.Millisecond, Volume: 0.5}, {Frequency: 523.25, Duration: 300 * time.Millisecond, Volume: 0.4}, }, }, "blip": { Name: "blip", Description: "Ultra-short confirmation blip", Segments: []ToneSegment{ {Frequency: 1000, Duration: 80 * time.Millisecond, Volume: 0.7}, }, }, }
Sounds is the registry of all available sound effects.
Functions ¶
func GeneratePCM ¶
func GeneratePCM(def SoundDefinition) []byte
GeneratePCM produces stereo 16-bit signed little-endian PCM data for the given sound.
Types ¶
type SoundDefinition ¶
type SoundDefinition struct {
Name string
Description string
Segments []ToneSegment
}
SoundDefinition describes a named sound composed of one or more tone segments.
Click to show internal directories.
Click to hide internal directories.