tinyalsa

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: BSD-3-Clause Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const ErrorTolerance = 10 // defines how many error frames are allowed to be read without stopping reading the next ones
View Source
const PCM_FORMAT_S16_BE = tinyapi.PCM_FORMAT_S16_BE
View Source
const PCM_FORMAT_S16_LE = tinyapi.PCM_FORMAT_S16_LE
View Source
const PCM_FORMAT_S24_3BE = tinyapi.PCM_FORMAT_S24_3BE
View Source
const PCM_FORMAT_S24_3LE = tinyapi.PCM_FORMAT_S24_3LE
View Source
const PCM_FORMAT_S24_BE = tinyapi.PCM_FORMAT_S24_BE
View Source
const PCM_FORMAT_S24_LE = tinyapi.PCM_FORMAT_S24_LE
View Source
const PCM_FORMAT_S32_BE = tinyapi.PCM_FORMAT_S32_BE
View Source
const PCM_FORMAT_S32_LE = tinyapi.PCM_FORMAT_S32_LE
View Source
const PCM_IN = tinyapi.PCM_IN
View Source
const PCM_OUT = tinyapi.PCM_OUT

Variables

This section is empty.

Functions

func BestDeviceConfig

func BestDeviceConfig(cardNr int, deviceNr int, format int) pcm.Config

BestDeviceConfig return you the best device config to use

Types

type AlsaDevice

type AlsaDevice struct {
	Card         int
	Device       int
	DeviceConfig pcm.Config
}

func NewDevice

func NewDevice(cardNr int, deviceNr int, deviceConfig pcm.Config) AlsaDevice

NewDevice defines a new device you want to interact with

func (*AlsaDevice) GetAudioStream

func (d *AlsaDevice) GetAudioStream(config pcm.Config, audioData chan []byte) error

GetAudioStream Listens to the input of the defined device

func (*AlsaDevice) GetInfo

func (d *AlsaDevice) GetInfo() DeviceInfo

GetInfo returns information data about the given device's input & output

func (*AlsaDevice) IsReady added in v1.0.2

func (d *AlsaDevice) IsReady(format int) (bool, error)

IsReady returns if the device is ready

func (*AlsaDevice) NewAudioSession added in v1.0.3

func (d *AlsaDevice) NewAudioSession() (AudioSession, error)

NewAudioSession creates a new Audio session to stream audio data. Do not forget to call `Close()`

func (*AlsaDevice) SendAudioStream

func (d *AlsaDevice) SendAudioStream(audioData []byte) error

SendAudioStream plays the given audio data (usually wav) to the device

func (*AlsaDevice) WaitUntilReady added in v1.0.1

func (d *AlsaDevice) WaitUntilReady(format int, timeout time.Duration) error

WaitUntilReady waits until the device is ready or the timeout expired If successful, nil will be returned. Otherwise, an error

type AudioSession added in v1.0.3

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

func (*AudioSession) BufferSize added in v1.0.3

func (a *AudioSession) BufferSize() int

BufferSize returns the buffer size expected by the device

func (*AudioSession) Close added in v1.0.3

func (a *AudioSession) Close()

Close the open pcm device and free it for other use

func (*AudioSession) Pump added in v1.0.3

func (a *AudioSession) Pump(data []byte) error

Pump the audio data into the device.

type DeviceInfo

type DeviceInfo struct {
	// Output info (e.g. speaker)
	Out pcm.Info
	// Input info (e.g. microphone)
	In pcm.Info
}

func (*DeviceInfo) HasInput

func (i *DeviceInfo) HasInput() bool

HasInput returns true, if the given device has an input (e.g. microphone)

func (*DeviceInfo) HasOutput

func (i *DeviceInfo) HasOutput() bool

HasOutput returns true, if the given device has an output (e.g. speaker)

Jump to

Keyboard shortcuts

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