dac

package module
v0.0.0-...-e41b870 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: MIT Imports: 5 Imported by: 0

README

dac

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FreeBuffer

func FreeBuffer(b *Buffer)

FreeBuffer will pull a new buffer from the cache

func SetBufferSize

func SetBufferSize(s int)

SetBufferSize initializes the buffer cache with sample size

func SetSampleRate

func SetSampleRate(r int)

SetSampleRate sets the sample rate of buffers and re initilizes the cache

Types

type AudioCallback

type AudioCallback func(in, out *Buffer) error

AudioCallback will be executed at every sample buffer

type AudioInterface

type AudioInterface func(sampleRate, bufferSize, inChannels, outChannels int) (AudioInterfaceCallback, error)

AudioInterface constructs a new input callback

type AudioInterfaceCallback

type AudioInterfaceCallback func(AudioCallback) error

AudioInterfaceCallback Will run on the audio interface

type Buffer

type Buffer struct {
	SampleRate int         // Samples per second
	Samples    [][]float64 // PCM data
}

Buffer holds audio samples

func GetBuffer

func GetBuffer(channels int) *Buffer

GetBuffer will pull a new buffer from the cache

func (*Buffer) Add

func (b *Buffer) Add(n *Buffer)

Add two buffers

func (*Buffer) Channels

func (b *Buffer) Channels() int

Channels returns the number of channels

func (*Buffer) Clear

func (b *Buffer) Clear()

Clear the buffer to all 0s

func (*Buffer) Copy

func (b *Buffer) Copy() *Buffer

Copy the buffer

func (*Buffer) GetSample

func (b *Buffer) GetSample(channel, index int) float64

GetSample returns the sample at the given index

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of samples in the bufffer, per channel

func (*Buffer) Multiply

func (b *Buffer) Multiply(n *Buffer)

Multiply two buffers

func (*Buffer) SetSample

func (b *Buffer) SetSample(channel, index int, sample float64)

SetSample returns the sample at the given index

type DAC

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

DAC is a digital audio converter. It provides an interface for reading and writing audio samples

func NewDAC

func NewDAC(sampleRate, bufferSize, inputChannels, outputChannels int) (d *DAC, err error)

NewDAC connects to the given dac and opens given chennels

func (*DAC) MainLoop

func (d *DAC) MainLoop()

func (*DAC) OnAudio

func (d *DAC) OnAudio(a AudioCallback)

OnAudio adds a new input callback

type Output

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

Output is an analog to digital converter

func (*Output) Read

func (o *Output) Read(channel int) *Buffer

Read audio from a given channel

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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