alsa

package module
v0.0.0-...-353bb99 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Go ALSA bindings

These bindings allow capture and playback of audio via ALSA using the alsa-lib library.

Build Status

Coverage Status

Installation
go get github.com/cocoonlife/goalsa
Status

The code has support for capture and playback with various parameters however it is only quite lightly tested so it is likely that bugs remain. Playback in particular has not been very well tested.

Documentation

Overview

Package alsa provides Go bindings to the ALSA library.

Index

Constants

View Source
const (
	FormatS8        = C.SND_PCM_FORMAT_S8
	FormatU8        = C.SND_PCM_FORMAT_U8
	FormatS16LE     = C.SND_PCM_FORMAT_S16_LE
	FormatS16BE     = C.SND_PCM_FORMAT_S16_BE
	FormatU16LE     = C.SND_PCM_FORMAT_U16_LE
	FormatU16BE     = C.SND_PCM_FORMAT_U16_BE
	FormatS24LE     = C.SND_PCM_FORMAT_S24_LE
	FormatS24BE     = C.SND_PCM_FORMAT_S24_BE
	FormatU24LE     = C.SND_PCM_FORMAT_U24_LE
	FormatU24BE     = C.SND_PCM_FORMAT_U24_BE
	FormatS32LE     = C.SND_PCM_FORMAT_S32_LE
	FormatS32BE     = C.SND_PCM_FORMAT_S32_BE
	FormatU32LE     = C.SND_PCM_FORMAT_U32_LE
	FormatU32BE     = C.SND_PCM_FORMAT_U32_BE
	FormatFloatLE   = C.SND_PCM_FORMAT_FLOAT_LE
	FormatFloatBE   = C.SND_PCM_FORMAT_FLOAT_BE
	FormatFloat64LE = C.SND_PCM_FORMAT_FLOAT64_LE
	FormatFloat64BE = C.SND_PCM_FORMAT_FLOAT64_BE
)

The range of sample formats supported by ALSA.

Variables

View Source
var (
	// ErrOverrun signals an overrun error
	ErrOverrun = errors.New("overrun")
	// ErrUnderrun signals an underrun error
	ErrUnderrun = errors.New("underrun")
)

Functions

This section is empty.

Types

type BufferParams

type BufferParams struct {
	BufferFrames int
	PeriodFrames int
	Periods      int
}

BufferParams specifies the buffer parameters of a device.

type CaptureDevice

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

CaptureDevice is an ALSA device configured to record audio.

func NewCaptureDevice

func NewCaptureDevice(deviceName string, channels int, format Format, rate int, bufferParams BufferParams) (c *CaptureDevice, err error)

NewCaptureDevice creates a new CaptureDevice object.

func (*CaptureDevice) Close

func (d *CaptureDevice) Close()

Close closes a device and frees the resources associated with it.

func (*CaptureDevice) Read

func (c *CaptureDevice) Read(buffer interface{}) (samples int, err error)

Read reads samples into a buffer and returns the amount read.

type Format

type Format C.snd_pcm_format_t

Format is the type used for specifying sample formats.

type PlaybackDevice

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

PlaybackDevice is an ALSA device configured to playback audio.

func NewPlaybackDevice

func NewPlaybackDevice(deviceName string, channels int, format Format, rate int, bufferParams BufferParams) (p *PlaybackDevice, err error)

NewPlaybackDevice creates a new PlaybackDevice object.

func (*PlaybackDevice) Close

func (d *PlaybackDevice) Close()

Close closes a device and frees the resources associated with it.

func (*PlaybackDevice) Write

func (p *PlaybackDevice) Write(buffer interface{}) (samples int, err error)

Write writes a buffer of data to a playback device.

Jump to

Keyboard shortcuts

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