pipe

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 5 Imported by: 0

README

GoDoc Build Status Go Report Card codecov FOSSA Status

pipe is a framework for floating point signal processing. It utilizes pipeline pattern to build fast, asynchronomous and easy-to-extend pipes for sound processing. Each pipe consists of one Pump, zero or multiple Processors and one or more Sinks. Phono also offers a friendly API for new pipe components implementations.

diagram

Getting started

Find examples in example repository.

Testing

mock package can be used to implement integration tests for custom Pumps, Processors and Sinks. It allows to mock up pipe components and then assert the data metrics.

Contributing

For a complete guide to contributing to pipe, see the Contribution guide

License

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wait

func Wait(d <-chan error) error

Wait for state transition or first error to occur.

Types

type L added in v0.5.0

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

L is a pipe(L)ine. It controls the execution of multiple chained pipes. If pipes are not chained, they must be controlled by separate (L)ines. Use Line constructor to instantiate new pipelines.

func Line added in v0.5.0

func Line(ps ...*Pipe) (*L, error)

Line creates a new pipeline. Returned net is in Ready state.

func (*L) Close added in v0.5.0

func (l *L) Close() chan error

Close must be called to clean up handle's resources. Feedback is closed when line is done.

func (*L) ComponentID added in v0.5.0

func (l *L) ComponentID(component interface{}) (id string, ok bool)

ComponentID finds id of the component within network.

func (*L) Pause added in v0.5.0

func (l *L) Pause() chan error

Pause sends a pause event into handle. Calling this method after handle is closed causes a panic. Feedback is closed when Paused state is reached.

func (*L) Push added in v0.5.0

func (l *L) Push(id string, paramFuncs ...func())

Push new params into pipe. Calling this method after pipe is closed causes a panic.

func (*L) Resume added in v0.5.0

func (l *L) Resume() chan error

Resume sends a resume event into handle. Calling this method after handle is closed causes a panic. Feedback is closed when Ready state is reached.

func (*L) Run added in v0.5.0

func (l *L) Run(ctx context.Context, bufferSize int) chan error

Run sends a run event into handle. Calling this method after handle is closed causes a panic. Feedback channel is closed when Ready state is reached or context is cancelled.

type Pipe

type Pipe struct {
	Pump
	Processors []Processor
	Sinks      []Sink
}

Pipe is a pipeline with fully defined sound processing sequence it has:

1 		pump
0..n 	processors
1..n	sinks

type Processor

type Processor interface {
	Process(pipeID string, sampleRate, numChannels int) (func([][]float64) ([][]float64, error), error)
}

Processor defines interface for pipe-processors

func Processors added in v0.5.0

func Processors(processors ...Processor) []Processor

Processors is a helper function to use in pipe constructors.

type Pump

type Pump interface {
	Pump(pipeID string) (func(bufferSize int) ([][]float64, error), int, int, error)
}

Pump is a source of samples. Pump method returns a new buffer with signal data. Implentetions should use next error conventions:

  • nil if a full buffer was read;
  • io.EOF if no data was read;
  • io.ErrUnexpectedEOF if not a full buffer was read.

The latest case means that pump executed as expected, but not enough data was available. This incomplete buffer still will be sent further and pump will be finished gracefully. If no data was read or any other error was met, buffer should be nil.

type Sink

type Sink interface {
	Sink(pipeID string, sampleRate, numChannels int) (func([][]float64) error, error)
}

Sink is an interface for final stage in audio pipeline

func Sinks added in v0.5.0

func Sinks(sinks ...Sink) []Sink

Sinks is a helper function to use in pipe constructors.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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