portaudio

package
v2.16.7 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package portaudio provides Go bindings for PortAudio.

By default the C sources are compiled directly from the vendored pa_src submodule (see portaudio_vendored*.go). Build with -tags portaudio_system to link against a system libportaudio via pkg-config instead (portaudio_system.go); the Homebrew formula uses this so it depends on the brew `portaudio` formula rather than the vendored copy. The Go API below is identical either way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize() error

Initialize must be called before any other portaudio function.

func Terminate

func Terminate() error

Types

type DeviceInfo

type DeviceInfo struct {
	Index             int
	Name              string
	MaxInputChannels  int
	MaxOutputChannels int
	DefaultSampleRate float64
	IsDefaultInput    bool
	IsDefaultOutput   bool
	InputLatency      time.Duration
	OutputLatency     time.Duration
}

func DefaultInputDevice

func DefaultInputDevice() (*DeviceInfo, error)

func DefaultOutputDevice

func DefaultOutputDevice() (*DeviceInfo, error)

func FindDevice

func FindDevice(query string, input bool) (*DeviceInfo, error)

FindDevice finds a device by index (numeric string) or name substring (case-insensitive).

func ListDevices

func ListDevices() ([]DeviceInfo, error)

type Stream

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

func OpenInputStream

func OpenInputStream(device *DeviceInfo, sampleRate, channels, framesPerBuffer int) (*Stream, error)

func OpenOutputStream

func OpenOutputStream(device *DeviceInfo, sampleRate, channels, framesPerBuffer int) (*Stream, error)

func (*Stream) Abort

func (s *Stream) Abort() error

Abort stops the stream immediately without waiting for buffers to drain.

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Info

func (s *Stream) Info() StreamInfo

func (*Stream) Read

func (s *Stream) Read(buf []int16) error

func (*Stream) Start

func (s *Stream) Start() error

func (*Stream) Stop

func (s *Stream) Stop() error

Stop waits for buffered output to drain, then stops the stream.

func (*Stream) Write

func (s *Stream) Write(buf []int16) error

type StreamInfo

type StreamInfo struct {
	InputLatency  time.Duration
	OutputLatency time.Duration
	SampleRate    float64
}

Jump to

Keyboard shortcuts

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