module

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package module provides built-in modules

Index

Constants

View Source
const (
	// SampleRate is the numebr of samples computed every second
	SampleRate = 44100.0
)

Variables

View Source
var FrameSize = 256

FrameSize is the number of samples computed during every callback

View Source
var Registry = map[string]InitFunc{}

Registry contains initializers for all known synthesizer modules

Functions

func Register

func Register(name string, fn func(Config) (Patcher, error))

Register registers an input under a specified name

func RegisteredTypes

func RegisteredTypes() []string

RegisteredTypes returns a list of all registered module types

Types

type BeatsPerMin added in v0.0.11

type BeatsPerMin struct {
	Valuer
	Raw float64
}

BeatsPerMin represents beats-per-minute

func BPM added in v0.0.11

func BPM(v float64) BeatsPerMin

BPM returns a scalar value in beats-per-minute

func (BeatsPerMin) Read added in v0.0.11

func (bpm BeatsPerMin) Read(out Frame)

Read reads the BPM real value to a Frame

func (BeatsPerMin) String added in v0.0.11

func (bpm BeatsPerMin) String() string

type Buffer

type Buffer struct {
	Reader
	Frame
}

Buffer is a buffered source. Every read Frame is stored

func NewBuffer

func NewBuffer(r Reader) *Buffer

NewBuffer returns a new Buffer

func (*Buffer) Close

func (b *Buffer) Close() error

Close closes the underlying Reader if necessary

func (*Buffer) ReadFrame

func (b *Buffer) ReadFrame() Frame

ReadFrame reads a frame of data from the source

func (*Buffer) SetSource

func (b *Buffer) SetSource(r Reader)

SetSource establishes the Reader that is called when the Buffer is read

func (*Buffer) String

func (b *Buffer) String() string

type Config

type Config map[string]interface{}

Config is the conduit for providing initialization information to a module

type Frame

type Frame []Value

Frame is a block of Values to be sinked to the soundcard

type Hz

type Hz struct {
	Valuer
	Raw float64
}

Hz represents cycles-per-second

func Frequency

func Frequency(v float64) Hz

Frequency returns a scalar value in Hz

func (Hz) Read

func (hz Hz) Read(out Frame)

Read reads the Hz real value to a Frame

func (Hz) String

func (hz Hz) String() string

type IO

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

IO is the input/output registry of a module. It manages the lifecycles of the ports; fascilitating connects and disconnects between them. This struct lazy initializes so it is useful by default. It is intended to just be embedded inside other structs that represent a module.

func (*IO) AddInput added in v0.0.12

func (io *IO) AddInput(in *In) error

AddInput registers a new input with the module. This is primarily used to allow for lazy-creation of inputs when patched instead of at the module's create-time.

func (*IO) AddOutput added in v0.0.12

func (io *IO) AddOutput(out *Out) error

AddOutput registers a new output with the module. Like AddInput, it is used for lazy-creation of outputs.

func (*IO) Close added in v0.0.10

func (io *IO) Close() error

Close makes IO a noop io.Closer

func (*IO) Expose

func (io *IO) Expose(name string, ins []*In, outs []*Out) error

Expose registers inputs and outputs of the module so that they can be used in patching

func (*IO) ID added in v0.0.3

func (io *IO) ID() string

ID returns the module's unique identifier

func (*IO) Inputs

func (io *IO) Inputs() map[string]*In

Inputs lists all registered inputs

func (*IO) Output

func (io *IO) Output(name string) (*Out, error)

Output realizes a registered output and returns it for patching

func (*IO) Outputs

func (io *IO) Outputs() map[string]*Out

Outputs lists all registered outputs

func (*IO) OutputsActive

func (io *IO) OutputsActive(sinking bool) int

OutputsActive returns the total count of actively patched outputs

func (*IO) Patch

func (io *IO) Patch(name string, t interface{}) error

Patch assigns an input's reader to some source (Reader, Value, etc)

func (*IO) Reset

func (io *IO) Reset() error

Reset disconnects all inputs from their sources (closing them in the process) and re-assigns the input to its original default value

func (*IO) ResetOnly added in v0.0.10

func (io *IO) ResetOnly(names []string) error

ResetOnly disconnects specific inputs from their sources

func (*IO) String added in v0.0.3

func (io *IO) String() string

type In

type In struct {
	Source       Reader
	Name         string
	ForceSinking bool
	// contains filtered or unexported fields
}

In is a module input

func (*In) Close

func (i *In) Close() error

Close closes the input

func (*In) IsSinking added in v0.0.11

func (i *In) IsSinking() bool

IsSinking returns whether the input is sinking to audio output

func (*In) LastFrame

func (i *In) LastFrame() Frame

LastFrame returns the last frame read with ReadFrame

func (*In) Read

func (i *In) Read(f Frame)

Read reads the output of the source into a Frame

func (*In) ReadFrame

func (i *In) ReadFrame() Frame

ReadFrame reads an entire frame into the buffered input

func (*In) SetSource

func (i *In) SetSource(r Reader)

SetSource sets the internal source to some Reader

func (*In) SourceName added in v0.0.8

func (i *In) SourceName() string

SourceName returns the name of the connected output

func (*In) String

func (i *In) String() string

type InitFunc

type InitFunc func(Config) (Patcher, error)

InitFunc is a factory function that returns a module

func Lookup

func Lookup(name string) (InitFunc, error)

Lookup retrieves a module's initialization function from the Registry

type LuaMethod added in v0.0.15

type LuaMethod struct {
	Lock bool
	Func interface{}
}

type MS

type MS struct {
	Valuer
	Raw float64
}

MS is a value representation of milliseconds

func Duration

func Duration(v float64) MS

Duration returns a scalar value (float64) in MS

func DurationInt added in v0.0.3

func DurationInt(v int) MS

DurationInt returns a scalar value (int) in MS

func (MS) Read

func (ms MS) Read(out Frame)

Read reads the real value to a Frame

func (MS) String

func (ms MS) String() string

type Out

type Out struct {
	Name     string
	Provider ReaderProvider
	// contains filtered or unexported fields
}

Out is a module output

func (*Out) Close

func (o *Out) Close() error

Close closes the output

func (*Out) DestinationName added in v0.0.8

func (o *Out) DestinationName() string

DestinationName returns the name of the destination input

func (*Out) IsActive

func (o *Out) IsActive() bool

IsActive returns whether or not there is a realized Reader assigned

func (*Out) IsSinking added in v0.0.11

func (o *Out) IsSinking() bool

IsSinking returns whether the output is sinking to audio output

func (*Out) Read

func (o *Out) Read(out Frame)

func (*Out) String added in v0.0.3

func (o *Out) String() string

type Patcher

type Patcher interface {
	ID() string
	Patch(string, interface{}) error
	Output(string) (*Out, error)
	Reset() error
	ResetOnly([]string) error
	Close() error
}

Patcher is the patching behavior of a module

type Pitch

type Pitch struct {
	Valuer
	Raw string
}

Pitch is a pitch that has been expressed in scientific notation

func ParsePitch

func ParsePitch(v string) (Pitch, error)

ParsePitch parses the scientific notation of a pitch

func (Pitch) Read

func (p Pitch) Read(out Frame)

Read reads the Pitch real value to a Frame

func (Pitch) String

func (p Pitch) String() string

type Port

type Port struct {
	Patcher
	Port string
}

Port represents the address of a specific port on a Patcher

type Reader

type Reader interface {
	Read(Frame)
}

Reader is the interface that wraps reading to Frames.

type ReaderProvider

type ReaderProvider interface {
	Reader() Reader
}

ReaderProvider allows for delayed retrieval of Readers. This is typically used in outputs where the output should only be created when requested in a patch.

func Provide

func Provide(r Reader) ReaderProvider

Provide is a helper function that creates a ReaderProvider with a directly given Reader

type ReaderProviderFunc

type ReaderProviderFunc func() Reader

ReaderProviderFunc is a function that acts as as ReaderProvider

func (ReaderProviderFunc) Reader

func (fn ReaderProviderFunc) Reader() Reader

Reader yields the new Reader

type SourceSetter

type SourceSetter interface {
	SetSource(Reader)
}

SourceSetter is something that can set its source

type Value

type Value float64

Value is a real value sinked to the sound card

func (Value) Read

func (v Value) Read(out Frame)

Read reads a constant value into a Frame

func (Value) String added in v0.0.9

func (v Value) String() string

func (Value) Value

func (v Value) Value() Value

Value returns the constant value

type Valuer

type Valuer interface {
	Value() Value
}

Valuer is the wrapper interface around the Value method; which is used in obtaining the constant value

func ParseValueString

func ParseValueString(value string) (Valuer, error)

ParseValueString parses string representations of integers, floats and Pitches

Directories

Path Synopsis
Package midi provides MIDI input handling
Package midi provides MIDI input handling
Package osc provides Open Sound Control (OSC) input handling
Package osc provides Open Sound Control (OSC) input handling

Jump to

Keyboard shortcuts

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