Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrChannelMismatch = errors.New("audio data does not match the stream's channel count")
Error for audio data that does not match the channel count of its stream
var ErrClosed = errors.New("portaudio stream is closed")
Error for any call on a stream once Close has begun, a second Close included
var ErrNoPlayback = errors.New("no portaudio playback started")
Error for Playback asked before any Play
var ErrUnsupported = fmt.Errorf("load portaudio: %w", dlutil.ErrUnsupported)
Error for a build that has no dynamic library loader for its platform and so cannot load PortAudio
Functions ¶
Types ¶
type Audio ¶
type Audio interface {
Devices() ([]Device, error)
Device(selector any, dir Direction) (Device, error)
HostAPI(index int) (HostAPI, error)
Play(data []int16, sampleRate float64, blockSize int) error
Stop()
Playback() (Stream, error)
OpenInput(p StreamParams, callback InputCallback) (InputStream, error)
OpenOutput(p StreamParams) (OutputStream, error)
}
PortAudio loaded and initialized: device and host API queries, streams, and one playback of a buffer at a time
type CallbackFlags ¶
type CallbackFlags uint32
Status bits PortAudio passes a stream callback
func (CallbackFlags) String ¶
func (f CallbackFlags) String() string
Names of the set flags joined by commas, empty when none is set
type CallbackResult ¶
type CallbackResult int32
What a stream callback asks of its stream
const ( // Keep the stream running Continue CallbackResult = 0 // Finish once the blocks already handed over have played Complete CallbackResult = 1 // Stop at once, dropping what is still queued Abort CallbackResult = 2 )
type Device ¶
type Device struct {
Name string
Index int
HostAPI int
MaxInputChannels int
MaxOutputChannels int
DefaultLowInputLatency time.Duration
DefaultLowOutputLatency time.Duration
DefaultHighInputLatency time.Duration
DefaultHighOutputLatency time.Duration
DefaultSampleRate float64
}
One audio device as PortAudio reports it, the latencies being the defaults PortAudio suggests for it
type DeviceError ¶
Device selector that names no device with channels in a direction, or a name query that matches several
func (*DeviceError) Error ¶
func (e *DeviceError) Error() string
Which selector failed and, for an ambiguous query, the "[index] name, host API" line of each match
type Error ¶
Failed PortAudio call: the operation, PortAudio's error code and text, and the host API's own error when PortAudio reports one
type HostAPI ¶
One host API such as ALSA, Core Audio or WASAPI, with the indexes of its devices and of its default devices, -1 for none
type InputCallback ¶
type InputCallback func(indata []int16, frames int, status CallbackFlags) CallbackResult
Callback that receives each captured block of interleaved int16 samples with its frame count and the status flags, the slice being the callback's own to keep
type InputStream ¶
type InputStream interface {
Stream
Read(frames int) ([]int16, bool, error)
ReadAvailable() (int, error)
}
Stream that captures interleaved int16 frames through its callback or through blocking reads
type LibraryError ¶
type LibraryError struct{ Err error }
PortAudio library that could not be found, opened or bound
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
What kept the library from loading
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() error
The loader's or binder's own error
type OutputStream ¶
Stream that plays interleaved int16 frames through blocking writes