Documentation ¶
Index ¶
- Constants
- func BestDeviceConfig(cardNr int, deviceNr int, format int) pcm.Config
- type AlsaDevice
- func (d *AlsaDevice) GetAudioStream(config pcm.Config, audioData chan []byte) error
- func (d *AlsaDevice) GetInfo() DeviceInfo
- func (d *AlsaDevice) IsReady(format int) (bool, error)
- func (d *AlsaDevice) NewAudioSession() (AudioSession, error)
- func (d *AlsaDevice) SendAudioStream(audioData []byte) error
- func (d *AlsaDevice) WaitUntilReady(format int, timeout time.Duration) error
- type AudioSession
- type DeviceInfo
Constants ¶
const ErrorTolerance = 10 // defines how many error frames are allowed to be read without stopping reading the next ones
const PCM_FORMAT_S16_BE = tinyapi.PCM_FORMAT_S16_BE
const PCM_FORMAT_S16_LE = tinyapi.PCM_FORMAT_S16_LE
const PCM_FORMAT_S24_3BE = tinyapi.PCM_FORMAT_S24_3BE
const PCM_FORMAT_S24_3LE = tinyapi.PCM_FORMAT_S24_3LE
const PCM_FORMAT_S24_BE = tinyapi.PCM_FORMAT_S24_BE
const PCM_FORMAT_S24_LE = tinyapi.PCM_FORMAT_S24_LE
const PCM_FORMAT_S32_BE = tinyapi.PCM_FORMAT_S32_BE
const PCM_FORMAT_S32_LE = tinyapi.PCM_FORMAT_S32_LE
const PCM_IN = tinyapi.PCM_IN
const PCM_OUT = tinyapi.PCM_OUT
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlsaDevice ¶
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)