input

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Backends []NamedBackend

Functions

func CopyBuffers

func CopyBuffers(dst, src [][]Sample)

CopyBuffers deep copies src to dst. It does NOT do length check.

func EnsureBufferLen added in v1.5.0

func EnsureBufferLen(cfg SessionConfig, buf [][]Sample) bool

EnsureBufferLen ensures that the given buffer has matching sizes with the needed parameters from SessionConfig. It is effectively a bound check.

func MakeBuffers

func MakeBuffers(channels, samples int) [][]Sample

MakeBuffer allocates a slice of sample buffers.

func RegisterBackend

func RegisterBackend(name string, b Backend)

RegisterBackend registers a backend globally. This function is not thread-safe, and most packages should call it on init().

Types

type Backend

type Backend interface {
	// Init should do nothing if called more than once.
	Init() error
	Close() error

	Devices() ([]Device, error)
	DefaultDevice() (Device, error)
	Start(SessionConfig) (Session, error)
}

func FindBackend

func FindBackend(name string) Backend

FindBackend is a helper function that finds a backend. It returns nil if the backend is not found.

func InitBackend added in v1.5.0

func InitBackend(bknd string) (Backend, error)

type Device

type Device interface {
	// String returns the device name.
	String() string
}

func GetDevice added in v1.5.0

func GetDevice(backend Backend, device string) (Device, error)

type NamedBackend

type NamedBackend struct {
	Name string
	Backend
}

type Processor added in v1.5.0

type Processor interface {
	Process()
}

Processor is called by Session everytime the buffer is full. Session may call this on another goroutine; the implementation must handle synchronization. It must also handle buffer swapping or copying if it wants to synchronize it away.

type Sample

type Sample = float64

type Session

type Session interface {
	// Start blocks until either the context is canceled or an error is
	// encountered.
	Start(context.Context, [][]Sample, chan bool, *sync.Mutex) error
}

Session is the interface for an input session. Its task is to call the processor everytime the buffer is full using the parameters given in SessionConfig.

type SessionConfig

type SessionConfig struct {
	Device     Device
	FrameSize  int     // number of channels per frame
	SampleSize int     // number of frames per buffer write
	SampleRate float64 // sample rate
}

Directories

Path Synopsis
common
execread
Package execread provides a shared struct that wraps around cmd.
Package execread provides a shared struct that wraps around cmd.
Package portaudio contains modifications of CGO bindings for portaudio obtained from https://github.com/gordonklaus/portaudio see ./LICENSE
Package portaudio contains modifications of CGO bindings for portaudio obtained from https://github.com/gordonklaus/portaudio see ./LICENSE

Jump to

Keyboard shortcuts

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