portaudio

package
v0.2.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package portaudio provides an implementation of streamio.Player and streamio.Recorder using PortAudio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListDevices

func ListDevices() ([]string, error)

ListDevices returns a slice of string containing device info on each line.

func OpenStream

func OpenStream(inputDeviceID, outputDeviceID int, numInputChannels, numOutputChannels int, sampleRate float64, framesPerBuffer int, args ...interface{}) (*portaudio.Stream, error)

OpenStream opens a stream with device IDs that portaudio.OpenDefaultStream does not support.

If the device ID is -1, the function uses the default input/output device.

Types

type Player

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

Player is a writable PortAudio output device.

func NewPlayer

func NewPlayer(outputDeviceID int, bufferSize int, channels int, bitDepth int, sampleRate int, byteOrder binary.ByteOrder) (p *Player, err error)

NewPlayer initialize a Player object.

func (*Player) Close

func (p *Player) Close() (err error)

Close closes PortAudio.

func (*Player) Write

func (p *Player) Write(b []byte) (n int, err error)

Write writes len(b) bytes from b to the playback buffer.

The first call to this function invokes a goroutine that sequentially reads data from the playback buffer and writes the data to the audio output device.

type Recorder

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

Recorder is a readable PortAudio input device.

func NewRecorder

func NewRecorder(inputDeviceID int, bufferSize int, channels int, bitDepth int, sampleRate int, byteOrder binary.ByteOrder) (r *Recorder, err error)

NewRecorder initialize a Player object.

func (*Recorder) Close

func (r *Recorder) Close() (err error)

Close closes PortAudio.

func (*Recorder) Read

func (r *Recorder) Read(b []byte) (n int, err error)

Read reads len(b) bytes from the record buffer into b.

The function blocks until it reads len(b) bytes or more. The function does not support ioutil.ReadAll (blocks permanently).

The first call to this function invokes a goroutine that sequentially reads data from the audio input device and writes the data into the record buffer.

Jump to

Keyboard shortcuts

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