audio

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSoundNotFound = errors.New("sound not found")

Functions

func ValidEventType

func ValidEventType(eventType EventType) bool

Types

type Config

type Config struct {
	Hooks map[EventType]string `json:"hooks"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) OK

func (c *Config) OK() error

type Event

type Event struct {
	Type EventType
	Time time.Time
}

type EventType

type EventType string
const (
	EventInit            EventType = "init"
	EventGitCommitCreate EventType = "git_commit_create"
	EventGitCommitPush   EventType = "git_push"
	EventFileCreate      EventType = "file_create"
	EventFileWrite       EventType = "file_write"
	EventFileRemove      EventType = "file_remove"
	EventPackageCreate   EventType = "package_create"
	EventPackageUpgrade  EventType = "package_upgrade"
	EventPackageRemove   EventType = "package_remove"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(cfg *Config) (*Manager, error)

func (*Manager) AddEventHook

func (m *Manager) AddEventHook(name string, eventType EventType) error

AddEventHook takes the 'name' of a sound (the filename, not the full path), and configures Manager to play it whenever an event of 'eventType' is received.

func (*Manager) AddSound

func (m *Manager) AddSound(path string) error

AddSound takes the path to a sound and stores it for use by the Manager based on event hooks.

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) GetSound

func (m *Manager) GetSound(name string) (*Sound, error)

func (*Manager) PlaySound

func (m *Manager) PlaySound(ctx context.Context, name string) error

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

func (*Manager) SendEvent

func (m *Manager) SendEvent(ctx context.Context, event Event)

type Sound

type Sound struct {
	Name   string
	Format beep.Format
	Buffer *beep.Buffer
}

Jump to

Keyboard shortcuts

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