audioout

package
v0.0.0-...-11816a6 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package audioout enumerates and opens native audio endpoints and pulls interleaved float32 stereo frames from a callback on the device's own thread. It also opens the default input, pushing interleaved float32 samples to a callback the same way. Each operating system has its own implementation; the callback contracts are the same everywhere.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("audioout: device unavailable")
View Source
var ErrUnsupported = errors.New("audioout: backend unavailable")

Functions

This section is empty.

Types

type Callback

type Callback func(out []float32)

Callback fills out with len(out)/2 stereo frames.

type CaptureCallback

type CaptureCallback func(in []float32)

CaptureCallback receives interleaved float32 samples the input device has recorded, at the rate and channel count the stream was opened with. The slice belongs to the device and is only valid for the call, so a callback that keeps the samples copies them.

type CaptureDevice

type CaptureDevice struct {
	Rate     int
	Channels int
	// contains filtered or unexported fields
}

CaptureDevice is an open ALSA capture stream.

func OpenCapture

func OpenCapture(rate, channels int, cb CaptureCallback) (*CaptureDevice, error)

OpenCapture starts the system-default input.

func OpenCaptureDevice

func OpenCaptureDevice(id string, rate, channels int, cb CaptureCallback) (*CaptureDevice, error)

OpenCaptureDevice starts a named input; empty selects the system default.

func (*CaptureDevice) Close

func (d *CaptureDevice) Close()

Close stops native recording and joins the capture callback worker.

type Device

type Device struct {
	Rate int
	// contains filtered or unexported fields
}

Device is an open ALSA playback stream.

func Open

func Open(rate int, cb Callback) (*Device, error)

Open starts the system-default output.

func OpenDevice

func OpenDevice(id string, rate int, cb Callback) (*Device, error)

OpenDevice starts a named output; empty selects system-default routing.

func (*Device) Close

func (d *Device) Close()

Close stops the stream.

type DeviceInfo

type DeviceInfo struct {
	ID      string
	Name    string
	Default bool
}

DeviceInfo identifies a native endpoint; its ID can be passed back to open.

func InputDevices

func InputDevices() ([]DeviceInfo, error)

InputDevices enumerates configured ALSA capture PCMs.

func OutputDevices

func OutputDevices() ([]DeviceInfo, error)

OutputDevices enumerates configured ALSA playback PCMs, including virtual routing endpoints.

Jump to

Keyboard shortcuts

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