device

package
v0.0.0-...-12eefb5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package device is used to interact with audio input/output devices on the host machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

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

The Input type represents the host's audio input device.

func DefaultInput

func DefaultInput() (*Input, error)

DefaultInput creates a new Input instance that will read audio from the host's default audio input device.

func (*Input) Close

func (m *Input) Close() error

Close the input stream

func (*Input) Listen

func (m *Input) Listen(ctx context.Context, w io.Writer) error

Listen to audio from the input device and write the audio data to the provided io.Writer implementation. If the provided context is cancelled, or an error is returned when writing, streaming from the device is stopped. This function blocks until cancelled/errored. If this function returns an error, Close must still be called to stop all usage of the input device.

type Output

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

The Output type represents the host's audio output device.

func DefaultOutput

func DefaultOutput() (*Output, error)

DefaultOutput creates a new Output instance that will write audio to the host's default audio output device.

func (*Output) Close

func (m *Output) Close() error

Close the output stream

func (*Output) Play

func (m *Output) Play(ctx context.Context, r io.Reader) error

Play audio from the output device using audio data read from the provided io.Reader implementation. If the provided context is cancelled, or an error is returned when reading, streaming to the device is stopped. This function blocks until cancelled/errored. If this function returns an error, Close must still be called to stop all usage of the output device.

type Stream

type Stream interface {
	io.Closer

	Start() error
	Stop() error
	Read() error
	Write() error
}

The Stream interface describes types that managing audio streaming on host machines.

Jump to

Keyboard shortcuts

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