pipe

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: MIT Imports: 8 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

Overview

Package pipe provides functionality to build and execute DSP pipelines. Examples could be found in [examples repository](https://github.com/pipelined/example).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindHooks added in v0.5.1

func BindHooks(v interface{}) runner.Hooks

BindHooks of component.

func Wait

func Wait(d <-chan error) error

Wait for state transition or first error to occur.

Types

type Flusher

type Flusher interface {
	Flush(string) error
}

Flusher is a component that must be flushed in the end of execution. Flush hook is executed in the end of the run. It will be skipped if Reset hook has failed.

type Interrupter

type Interrupter interface {
	Interrupt(string) error
}

Interrupter is a component that has custom interruption logic. Interrupt hook is executed when Cancel happens.

type Line added in v0.5.0

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

Line is a sound processing sequence of components. It has a single pump, zero or many processors executed sequentially and one or many sinks executed in parallel.

type Pipe

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

Pipe controls the execution of multiple chained lines. Lines might be chained through components, mixer for example. If lines are not chained, they must be controlled by separate Pipes. Use New constructor to instantiate new Pipes.

func New

func New(ls ...*Line) (*Pipe, error)

New creates a new pipeline. Returned pipeline is in Ready state.

func (*Pipe) Close

func (p *Pipe) Close() chan error

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

func (*Pipe) ComponentID

func (p *Pipe) ComponentID(component interface{}) (id string, ok bool)

ComponentID finds id of the component within network.

func (*Pipe) Pause

func (p *Pipe) 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 (*Pipe) Push

func (p *Pipe) Push(id string, paramFuncs ...func())

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

func (*Pipe) Resume

func (p *Pipe) 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 (*Pipe) Run

func (p *Pipe) 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 Processor

type Processor interface {
	Process(pipeID string, sampleRate signal.SampleRate, numChannels int) (func(signal.Float64) error, error)
}

Processor defines interface for pipe processors. Processor should return output in the same signal buffer as input. It is encouraged to implement in-place processing algorithms. Buffer size could be changed during execution, but only decrease allowed. Number of channels cannot be changed.

func Processors added in v0.5.0

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

Processors is a helper function to use in line constructors.

type Pump

type Pump interface {
	Pump(pipeID string) (func(signal.Float64) error, signal.SampleRate, int, error)
}

Pump is a source of samples. Pump method returns a new buffer with signal data. If no data is available, io.EOF should be returned. If pump cannot provide data to fulfill buffer, it can trim the size of the buffer to align it with actual data. Buffer size can only be decreased.

type Resetter

type Resetter interface {
	Reset(string) error
}

Resetter is a component that must be resetted before new run. Reset hook is executed when Run happens.

type Sink

type Sink interface {
	Sink(pipeID string, sampleRate signal.SampleRate, numChannels int) (func(signal.Float64) error, error)
}

Sink is an interface for final stage in audio pipeline. This components must not change buffer content. Line can have multiple sinks and this will cause race condition.

func Sinks added in v0.5.0

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

Sinks is a helper function to use in line constructors.

Directories

Path Synopsis
internal
mock
Package mock provides mocks for pipeline components and allows to execute integration tests.
Package mock provides mocks for pipeline components and allows to execute integration tests.

Jump to

Keyboard shortcuts

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