pipe

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 7 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 giude

License

FOSSA Status

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidState = errors.New("invalid state")

ErrInvalidState is returned if pipe method cannot be executed at this moment.

Functions

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 defines component that must flushed in the end of execution.

type Interrupter

type Interrupter interface {
	Interrupt(string) error
}

Interrupter defines component that has custom interruption logic.

type Logger

type Logger interface {
	Debug(...interface{})
	Info(...interface{})
}

Logger is a global interface for pipe loggers

type Option

type Option func(p *Pipe) error

Option provides a way to set functional parameters to pipe.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger sets logger to Pipe. If this option is not provided, silent logger is used.

func WithMetric

func WithMetric(m *metric.Metric) Option

WithMetric adds meterics for this pipe and all components.

func WithName

func WithName(n string) Option

WithName sets name to Pipe.

func WithProcessors

func WithProcessors(processors ...Processor) Option

WithProcessors sets processors to Pipe

func WithPump

func WithPump(pump Pump) Option

WithPump sets pump to Pipe.

func WithSinks

func WithSinks(sinks ...Sink) Option

WithSinks sets sinks to Pipe.

type Pipe

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

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

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

func New

func New(bufferSize int, options ...Option) (*Pipe, error)

New creates a new pipe and applies provided options. Returned pipe is in Ready state.

func (*Pipe) Close

func (p *Pipe) Close() chan error

Close must be called to clean up pipe's resources.

func (*Pipe) ComponentID

func (p *Pipe) ComponentID(component interface{}) string

ComponentID returns component id.

func (*Pipe) Pause

func (p *Pipe) Pause() chan error

Pause sends a pause event into pipe. Calling this method after pipe is closed causes a panic.

func (*Pipe) Push

func (p *Pipe) Push(component interface{}, 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 pipe. Calling this method after pipe is closed causes a panic.

func (*Pipe) Run

func (p *Pipe) Run() chan error

Run sends a run event into pipe. Calling this method after pipe is closed causes a panic.

func (*Pipe) String

func (p *Pipe) String() string

Convert pipe to string. If name is included if has value.

type Processor

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

Processor defines interface for pipe-processors

type Pump

type Pump interface {
	Pump(pipeID string, bufferSize int) (func() ([][]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.

type Resetter

type Resetter interface {
	Reset(string) error
}

Resetter defines component that must be resetted before consequent use.

type Sink

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

Sink is an interface for final stage in audio pipeline

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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