sc

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: GPL-2.0 Imports: 22 Imported by: 8

README

sc

Package sc provides a way to interface directly with the SuperCollider server from Go programs.

Go Report Card

Why

SuperCollider has a well-deserved reputation for being difficult to learn. I believe that sclang is a big reason for this. I also believe that Go is quite easy to learn, hence replacing sclang with Go makes a lot of sense to me.

Who

See AUTHORS.

Install

Install SuperCollider.

Install Go.

go get github.com/scgolang/sc

Usage

Find godocs at http://godoc.org/github.com/scgolang/sc. Also, look at the example programs.

The list of supported ugens is here: https://github.com/scgolang/sc/blob/master/UGENS.md

Develop

See https://github.com/scgolang/sc/blob/master/CONTRIBUTING and https://github.com/scgolang/sc/blob/master/HACKING.md.

Roadmap

See https://github.com/scgolang/sc/milestones

Thanks

This project is hugely indebted to

Documentation

Overview

Package sc is a SuperCollider client for Go.

Index

Examples

Constants

View Source
const (

	// BufferFlagNormalize causes the peak amplitude of the buffer
	// to be normalized to 1.0 when using the Gen method.
	BufferFlagNormalize = 0x01
	// BufferFlagWavetable causes the buffer to be written in wavetable
	// format when using the Gen method, so that it can be used by
	// interpolating oscillators
	BufferFlagWavetable = 0x02
	// BufferFlagClear causes the buffer to be cleared before new
	// partials are written using the Gen method. Otherwise new partials
	// are summed with the existing contents of the buffer.
	BufferFlagClear = 0x04
	// BufferRoutineSine1 generates a buffer with a series of sine partials.
	// The args of this routine are the amplitudes of the partials.
	BufferRoutineSine1 = "sine1"
	// BufferRoutineSine2 is similar to BufferRoutineSine1 except that the
	// args are pairs of frequency and amplitude (i.e. you can specify the
	// frequency of each partial).
	BufferRoutineSine2 = "sine2"
	// BufferRoutineSine3 is similar to BufferRoutineSine1 except that the
	// args are triplets of frequency, amplitude, and phase (i.e. you can
	// specify the frequency and phase of each partial).
	BufferRoutineSine3 = "sine3"
	// BufferRoutineCheby generates a buffer that contains a series of
	// chebyshev polynomials which can be defined as
	//     cheby(n) = amplitude * cos(n * acos(x))
	// The first arg specifies the amplitude for n = 1, the second arg
	// specifies the amplitude for n = 2, and so on.
	// To eliminate DC offset when used as a waveshaper, the wavetable is
	// offset so that the center value is zero.
	BufferRoutineCheby = "cheby"
)
View Source
const (
	DumpOff      = 0
	DumpParsed   = 1
	DumpContents = 2
	DumpAll      = 3
)

Arguments to dumpOSC command. See http://doc.sccode.org/Reference/Server-Command-Reference.html#/dumpOSC

View Source
const (
	AddToHead  = int32(0)
	AddToTail  = int32(1)
	AddBefore  = int32(2)
	AddAfter   = int32(3)
	AddReplace = int32(4)
)

Arguments to s_new command. See http://doc.sccode.org/Reference/Server-Command-Reference.html#/s_new

View Source
const (
	// RootNodeID is what sclang uses as the root node ID. See http://doc.sccode.org/Classes/RootNode.html.
	RootNodeID = int32(0)

	// DefaultGroupID is what sclang uses for the default group ID. See http://doc.sccode.org/Reference/default_group.html.
	DefaultGroupID = int32(1)

	// DefaultLocalAddr is the listening address for DefaultClient.
	DefaultLocalAddr = "0.0.0.0:57110"

	// DefaultScsynthAddr is the remote address for DefaultClient.
	DefaultScsynthAddr = "0.0.0.0:57120"

	// DefaultConnectTimeout is the default timeout for connecting to scsynth.
	DefaultConnectTimeout = time.Second
)
View Source
const (
	// CurveStep is a flat envelope segment.
	CurveStep = C(0)
	// CurveLinear is a linear envelope segment.
	CurveLinear = C(1)
	// CurveExp is an exponential envelope segment.
	CurveExp = C(2)
	// CurveSine is a sinusoidal shaped envelope segment.
	CurveSine = C(3)
	// CurveWelch is a sinusoidal segment shaped like the sides of a welch window.
	CurveWelch = C(4)
	// CurveCustom is an undocumented (on doc.sccode.org) envelope segment shape.
	CurveCustom = C(5)
	// CurveSquared is a squared envelope segment.
	CurveSquared = C(6)
	// CurveCubed is a cubed envelope segment.
	CurveCubed = C(7)
)
View Source
const (
	GrainBufHanningEnv   = -1
	GrainBufNoInterp     = 1
	GrainBufLinearInterp = 2
	GrainBufCubicInterp  = 4
)

Envelope shapes for grain amp envelope.

View Source
const (
	BinOpAbsdif       = 38
	BinOpAdd          = 0
	BinOpAmclip       = 40
	BinOpAtan2        = 22
	BinOpClip2        = 42
	BinOpDifsqr       = 34
	BinOpDiv          = 4
	BinOpExcess       = 43
	BinOpExpon        = 25
	BinOpFold2        = 44
	BinOpGCD          = 18
	BinOpGT           = 9
	BinOpGTE          = 11
	BinOpHypot        = 23
	BinOpHypotApx     = 24
	BinOpLCM          = 17
	BinOpLT           = 8
	BinOpLTE          = 10
	BinOpMax          = 13
	BinOpModulo       = 5
	BinOpMin          = 12
	BinOpMul          = 2
	BinOpPow          = 25
	BinOpRing1        = 30
	BinOpRing2        = 31
	BinOpRing3        = 32
	BinOpRing4        = 33
	BinOpRound        = 19
	BinOpScaleneg     = 41
	BinOpSqrdif       = 37
	BinOpSqrsum       = 36
	BinOpSumsqr       = 35
	BinOpThresh       = 39
	BinOpTrunc        = 21
	BinOpWrap2        = 45
	UnaryOpAbs        = 5
	UnaryOpAcos       = 32
	UnaryOpAmpDb      = 22
	UnaryOpAsin       = 31
	UnaryOpAtan       = 33
	UnaryOpBilinrand  = 40
	UnaryOpCeil       = 8
	UnaryOpCoin       = 44
	UnaryOpCos        = 29
	UnaryOpCosh       = 35
	UnaryOpCpsmidi    = 18
	UnaryOpCpsoct     = 24
	UnaryOpCubed      = 13
	UnaryOpDbAmp      = 21
	UnaryOpDistort    = 42
	UnaryOpExp        = 15
	UnaryOpFloor      = 9
	UnaryOpFrac       = 10
	UnaryOpLinrand    = 39
	UnaryOpLog        = 25
	UnaryOpLog10      = 27
	UnaryOpLog2       = 26
	UnaryOpMidicps    = 17
	UnaryOpMidiratio  = 19
	UnaryOpNeg        = 0
	UnaryOpOctcps     = 23
	UnaryOpRatiomidi  = 20
	UnaryOpRand       = 37
	UnaryOpRand2      = 38
	UnaryOpReciprocal = 16
	UnaryOpSoftClip   = 43
	UnaryOpSign       = 11
	UnaryOpSin        = 28
	UnaryOpSinh       = 34
	UnaryOpSquared    = 12
	UnaryOpSqrt       = 14
	UnaryOpSum3rand   = 41
	UnaryOpTan        = 30
	UnaryOpTanh       = 36
)

Operator constants. These are used as the "special index" for BinaryOpUGen and UnaryOpUGen in synthdef files.

View Source
const (
	BinOpUgenName   = "BinaryOpUGen"
	UnaryOpUgenName = "UnaryOpUGen"
)

Ugen names.

View Source
const (
	IR = 0
	KR = 1
	AR = 2
)

Ugen rates.

  • IR is initialization rate.
  • KR is control rate.
  • AR is audio rate.

See http://doc.sccode.org/Tutorials/Mark_Polishook_tutorial/08_Rates.html.

View Source
const (
	DoNothing = iota
	Pause
	FreeEnclosing
	FreePreceding
	FreeFollowing
	FreePrecedingGroup
	FreeFollowingGroup
	FreeAllPreceding
	FreeAllFollowing
	FreeAndPausePreceding
	FreeAndPauseFollowing
	DeepFreePreceding
	DeepFreeFollowing
	FreeAllInGroup
)

UGen done actions, see http://doc.sccode.org/Reference/UGen-doneActions.html

View Source
const DefaultServerPort = 57120

DefaultServerPort is the default listening port for scsynth.

View Source
const GrainBufDefaultMaxGrains = 512

GrainBufDefaultMaxGrains is the default value of MaxGrains.

View Source
const Pi = C(float32(math.Pi))

Pi is a wrapper around math.Pi

View Source
const ServerPath = "/usr/bin/scsynth:/usr/local/bin/scsynth"

ServerPath is the path the scsynth executable on linux systems.

Variables

View Source
var (
	DistLinear    = C(0)
	DistCauchy    = C(1)
	DistLogist    = C(2)
	DistHyperbCos = C(3)
	DistArcSine   = C(4)
	DistExpon     = C(5)
	DistSinus     = C(6)
)

Probability distributions for Gendy1.

View Source
var (
	WarpExp = C(1)
	WarpLin = C(0)
)

Warp constants.

View Source
var ErrNoScsynth = errors.New("please install scsynth somewhere in your PATH")

ErrNoScsynth happens when you try to start a SuperCollider server but do not have an scsynth executable in your PATH.

View Source
var (
	ErrTimeout = errors.New("timeout error")
)

Common errors.

View Source
var Synthdefs = map[string]*Synthdef{}

Synthdefs is a map of synthdefs.

Functions

func CheckRate

func CheckRate(rate int8)

CheckRate causes a panic if rate is not IR, KR, or AR.

func Cpsmidi added in v0.1.4

func Cpsmidi(cps float32) float32

Cpsmidi converts frequency in Hz to midi note values.

func Cpsoct added in v0.1.4

func Cpsoct(cps float32) float32

Cpsoct converts cycles per second to decimal octaves.

func Midicps

func Midicps(note float32) float32

Midicps converts midi note values to frequency in Hz

func Octcps added in v0.1.4

func Octcps(oct float32) float32

Octcps converts decimal octaves to cycles per second.

func Play

func Play(c *Client, f UgenFunc) error

Play corresponds to http://doc.sccode.org/Classes/Function.html#-play. It wraps the provided UgenFunc in a synthdef, sends this synthdef to a server instance with DefaultClient, then creates a new synth from the synthdef.

func RegisterSynthdef added in v0.1.4

func RegisterSynthdef(name string, f UgenFunc) error

RegisterSynthdef registers a synthdef with this package. It returns an error if a synthdef is already registered with the provided name.

func Roundf added in v0.1.4

func Roundf(a, b float32) float32

Roundf rounds a to the nearest multiple of b.

func Truncf added in v0.1.4

func Truncf(a, b float32) float32

Truncf returns the next highest multiple of b that is < a.

Types

type Allpass added in v0.1.4

type Allpass struct {
	// Interpolation determines the type of interpolation (e.g. none, linear, cubic).
	Interpolation Interpolation

	// In is the input signal
	In Input

	// MaxDelayTime is maximum delay time in seconds.
	// This is used to initialize the delay buffer.
	MaxDelayTime Input

	// DelayTime time in seconds
	DelayTime Input

	// DecayTime time for the echoes to decay by 60dB.
	// If this is negative then the feedback coefficient will
	// be negative, thus emphasizing only odd harmonics
	// at a lower octave.
	DecayTime Input
}

Allpass is an allpass delay.

func (Allpass) Rate added in v0.1.4

func (apc Allpass) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If an In signal is not provided this method will panic. If Interpolation is set to an unsupported value this method will panic.

type AnalogIn added in v0.1.6

type AnalogIn struct {
	// Analog pin number to read.
	// Pin numbers begin at 0.
	// This value can be modulated at audiorate.
	AnalogPin Input
}

Read data from an analog input. Note: This UGen only works on Bela: https://bela.io/

func (AnalogIn) Rate added in v0.1.6

func (a AnalogIn) Rate(rate int8) Input

Rate returns an Input at the specified rate. This method panics if rate is not a supported value.

type AnalogOut added in v0.1.7

type AnalogOut struct {
	// Analog pin number to read.
	// Pin numbers begin at 0.
	// This value can be modulated at audiorate.
	AnalogPin Input
	// Value to write out to the pin.
	Output Input
}

Write data to an analog output. Note: This UGen only works on Bela: https://bela.io/

func (AnalogOut) Rate added in v0.1.7

func (a AnalogOut) Rate(rate int8) Input

Rate returns an Input at the specified rate. This method panics if rate is not a supported value.

type ArraySpec added in v0.1.4

type ArraySpec [3][]Input

ArraySpec is a convenience type for Klang and Klank.

func (ArraySpec) Abs added in v0.1.4

func (as ArraySpec) Abs() Input

Abs computes the absolute value of a signal.

func (ArraySpec) Absdif added in v0.1.4

func (as ArraySpec) Absdif(val Input) Input

Absdif returns the absolute value of the difference of two inputs.

func (ArraySpec) Acos added in v0.1.4

func (as ArraySpec) Acos() Input

Acos computes the arccosine of a signal.

func (ArraySpec) Add added in v0.1.4

func (as ArraySpec) Add(val Input) Input

Add adds one input to another.

func (ArraySpec) Amclip added in v0.1.4

func (as ArraySpec) Amclip(val Input) Input

Amclip returns 0 when b <= 0, a*b when b > 0.

func (ArraySpec) AmpDb added in v0.1.4

func (as ArraySpec) AmpDb() Input

AmpDb converts linear amplitude to decibels.

func (ArraySpec) Asin added in v0.1.4

func (as ArraySpec) Asin() Input

Asin computes the arcsine of a signal.

func (ArraySpec) Atan added in v0.1.4

func (as ArraySpec) Atan() Input

Atan computes the arctangent of a signal.

func (ArraySpec) Atan2 added in v0.1.4

func (as ArraySpec) Atan2(val Input) Input

Atan2 returns the arctangent of y/x.

func (ArraySpec) Bilinrand added in v0.1.4

func (as ArraySpec) Bilinrand() Input

Bilinrand returns a linearly distributed random value between [+in ... -in].

func (ArraySpec) Ceil added in v0.1.4

func (as ArraySpec) Ceil() Input

Ceil computes the ceiling of a signal.

func (ArraySpec) Clip2 added in v0.1.4

func (as ArraySpec) Clip2(val Input) Input

Clip2 clips input wave a to +/- b

func (ArraySpec) Coin added in v0.1.4

func (as ArraySpec) Coin() Input

Coin returns one or zero with the probability given by the input.

func (ArraySpec) Cos added in v0.1.4

func (as ArraySpec) Cos() Input

Cos computes the cosine of a signal.

func (ArraySpec) Cosh added in v0.1.4

func (as ArraySpec) Cosh() Input

Cosh computes the hyperbolic cosine of a signal.

func (ArraySpec) Cpsmidi added in v0.1.4

func (as ArraySpec) Cpsmidi() Input

Cpsmidi converts frequency in Hz to midi note values.

func (ArraySpec) Cpsoct added in v0.1.4

func (as ArraySpec) Cpsoct() Input

Cpsoct converts cycles per second to decimal octaves.

func (ArraySpec) Cubed added in v0.1.4

func (as ArraySpec) Cubed() Input

Cubed computes the cube of a signal.

func (ArraySpec) DbAmp added in v0.1.4

func (as ArraySpec) DbAmp() Input

DbAmp converts decibels tolinear amplitude.

func (ArraySpec) Difsqr added in v0.1.4

func (as ArraySpec) Difsqr(val Input) Input

Difsqr returns the value of (a*a) - (b*b).

func (ArraySpec) Distort added in v0.1.4

func (as ArraySpec) Distort() Input

Distort performs non-linear distortion on a signal.

func (ArraySpec) Div added in v0.1.4

func (as ArraySpec) Div(val Input) Input

Div divides one input by another.

func (ArraySpec) Excess added in v0.1.4

func (as ArraySpec) Excess(val Input) Input

Excess returns the difference of the original signal and its clipped form: (a - clip2(a,b)).

func (ArraySpec) Exp added in v0.1.4

func (as ArraySpec) Exp() Input

Exp computes the exponential of a signal.

func (ArraySpec) Expon added in v0.1.4

func (as ArraySpec) Expon(val Input) Input

Expon raises an Input to the power of another.

func (ArraySpec) Floor added in v0.1.4

func (as ArraySpec) Floor() Input

Floor computes the floor of a signal.

func (ArraySpec) Fold2 added in v0.1.4

func (as ArraySpec) Fold2(val Input) Input

Fold2 folds input wave a to +/- b

func (ArraySpec) Frac added in v0.1.4

func (as ArraySpec) Frac() Input

Frac returns the fractional part of a signal.

func (ArraySpec) GCD added in v0.1.4

func (as ArraySpec) GCD(val Input) Input

GCD computes the gcd of one Input and another.

func (ArraySpec) GT added in v0.1.4

func (as ArraySpec) GT(val Input) Input

GT computes x > y.

func (ArraySpec) GTE added in v0.1.4

func (as ArraySpec) GTE(val Input) Input

GTE computes x >= y.

func (ArraySpec) Hypot added in v0.1.4

func (as ArraySpec) Hypot(val Input) Input

Hypot returns the square root of the sum of the squares of a and b. Or equivalently, the distance from the origin to the point (x, y).

func (ArraySpec) HypotApx added in v0.1.4

func (as ArraySpec) HypotApx(val Input) Input

HypotApx returns an approximation of the square root of the sum of the squares of x and y.

func (ArraySpec) LCM added in v0.1.4

func (as ArraySpec) LCM(val Input) Input

LCM computes the least common multiple of one Input and another.

func (ArraySpec) LT added in v0.1.4

func (as ArraySpec) LT(val Input) Input

LT computes x < y.

func (ArraySpec) LTE added in v0.1.4

func (as ArraySpec) LTE(val Input) Input

LTE computes x <= y.

func (ArraySpec) Linrand added in v0.1.4

func (as ArraySpec) Linrand() Input

Linrand returns a linearly distributed random value between in and zero.

func (ArraySpec) Log added in v0.1.4

func (as ArraySpec) Log() Input

Log computes a natural logarithm.

func (ArraySpec) Log10 added in v0.1.4

func (as ArraySpec) Log10() Input

Log10 computes a base 10 logarithm.

func (ArraySpec) Log2 added in v0.1.4

func (as ArraySpec) Log2() Input

Log2 computes a base 2 logarithm.

func (ArraySpec) Max added in v0.1.4

func (as ArraySpec) Max(val Input) Input

Max returns the maximum of one input and another.

func (ArraySpec) Midicps added in v0.1.4

func (as ArraySpec) Midicps() Input

Midicps converts from MIDI note values to cycles per second.

func (ArraySpec) Midiratio added in v0.1.4

func (as ArraySpec) Midiratio() Input

Midiratio converts an interval in MIDI notes into a frequency ratio.

func (ArraySpec) Min added in v0.1.4

func (as ArraySpec) Min(val Input) Input

Min returns the minimum of one signal and another.

func (ArraySpec) Moddif added in v0.1.4

func (as ArraySpec) Moddif(y, mod Input) Input

Moddif returns the smaller of the great circle distances between the two points.

func (ArraySpec) Modulo added in v0.1.4

func (as ArraySpec) Modulo(val Input) Input

Modulo computes the modulo of one signal and another.

func (ArraySpec) Mul added in v0.1.4

func (as ArraySpec) Mul(val Input) Input

Mul multiplies one input and another.

func (ArraySpec) MulAdd added in v0.1.4

func (as ArraySpec) MulAdd(m, a Input) Input

MulAdd computes (as * m) + a.

func (ArraySpec) Neg added in v0.1.4

func (as ArraySpec) Neg() Input

Neg negates an input.

func (ArraySpec) Octcps added in v0.1.4

func (as ArraySpec) Octcps() Input

Octcps converts decimal octaves to cycles per second.

func (ArraySpec) Pow added in v0.1.4

func (as ArraySpec) Pow(val Input) Input

Pow raises an Input to the power of another.

func (ArraySpec) Rand added in v0.1.4

func (as ArraySpec) Rand() Input

Rand returns an evenly distributed random value between this and zero.

func (ArraySpec) Rand2 added in v0.1.4

func (as ArraySpec) Rand2() Input

Rand2 returns an evenly distributed random value between [+this ... - this].

func (ArraySpec) Ratiomidi added in v0.1.4

func (as ArraySpec) Ratiomidi() Input

Ratiomidi converts a frequency ratio to an interval in MIDI notes.

func (ArraySpec) Reciprocal added in v0.1.4

func (as ArraySpec) Reciprocal() Input

Reciprocal computes the reciprocal of a signal.

func (ArraySpec) Ring1 added in v0.1.4

func (as ArraySpec) Ring1(val Input) Input

Ring1 is ring modulation plus first source.

func (ArraySpec) Ring2 added in v0.1.4

func (as ArraySpec) Ring2(val Input) Input

Ring2 is ring modulation plus both sources.

func (ArraySpec) Ring3 added in v0.1.4

func (as ArraySpec) Ring3(val Input) Input

Ring3 returns the value of (a*a *b)

func (ArraySpec) Ring4 added in v0.1.4

func (as ArraySpec) Ring4(val Input) Input

Ring4 returns the value of ((a*a *b) - (a*b*b)).

func (ArraySpec) Round added in v0.1.4

func (as ArraySpec) Round(val Input) Input

Round performs quantization by rounding. Rounds a to the nearest multiple of b.

func (ArraySpec) Scaleneg added in v0.1.4

func (as ArraySpec) Scaleneg(val Input) Input

Scaleneg returns a*b when a < 0, otherwise a.

func (ArraySpec) Sign added in v0.1.4

func (as ArraySpec) Sign() Input

Sign returns the sign of a signal.

func (ArraySpec) Sin added in v0.1.4

func (as ArraySpec) Sin() Input

Sin computes the sine of a signal.

func (ArraySpec) Sinh added in v0.1.4

func (as ArraySpec) Sinh() Input

Sinh computes the hyperbolic sine of a signal.

func (ArraySpec) SoftClip added in v0.1.4

func (as ArraySpec) SoftClip() Input

SoftClip computes nonlinear distortion of an input.

func (ArraySpec) Sqrdif added in v0.1.4

func (as ArraySpec) Sqrdif(val Input) Input

Sqrdif computes the square of the difference between the two inputs.

func (ArraySpec) Sqrsum added in v0.1.4

func (as ArraySpec) Sqrsum(val Input) Input

Sqrsum computes the square of the sum of the two inputs.

func (ArraySpec) Sqrt added in v0.1.4

func (as ArraySpec) Sqrt() Input

Sqrt returns the square root of a signal.

func (ArraySpec) Squared added in v0.1.4

func (as ArraySpec) Squared() Input

Squared computes the square of a signal.

func (ArraySpec) Sum3rand added in v0.1.4

func (as ArraySpec) Sum3rand() Input

Sum3rand returns a value from a gaussian-like random distribution between in and zero.

func (ArraySpec) Sumsqr added in v0.1.4

func (as ArraySpec) Sumsqr(val Input) Input

Sumsqr returns the value of (a*a) + (b*b).

func (ArraySpec) Tan added in v0.1.4

func (as ArraySpec) Tan() Input

Tan computes the tangent of a signal.

func (ArraySpec) Tanh added in v0.1.4

func (as ArraySpec) Tanh() Input

Tanh computes the hyperbolic tangent of a signal.

func (ArraySpec) Thresh added in v0.1.4

func (as ArraySpec) Thresh(val Input) Input

Thresh returns 0 when a < b, otherwise a.

func (ArraySpec) Trunc added in v0.1.4

func (as ArraySpec) Trunc(val Input) Input

Trunc performs quantization by truncation. Truncate a to a multiple of b.

func (ArraySpec) Wrap2 added in v0.1.4

func (as ArraySpec) Wrap2(val Input) Input

Wrap2 wraps input wave to +/-b

type BAllPass added in v0.1.4

type BAllPass struct {
	// In is the input signal.
	In Input

	// Freq is the center frequency.
	// WARNING: due to the nature of its implementation frequency values close to 0
	// may cause glitches and/or extremely loud audio artifacts!
	Freq Input

	// RQ is the reciprocal of Q. bandwidth / cutoffFreq.
	RQ Input
}

BAllPass is an allpass filter based on the Second Order Section (SOS) biquad UGen. NOTE: Biquad coefficient calculations imply certain amount of CPU overhead. These plugin UGens contain optimizations such that the coefficients get updated only when there has been a change to one of the filter's parameters. This can cause spikes in CPU performance and should be considered when using several of these units.

func (BAllPass) Rate added in v0.1.4

func (b BAllPass) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. This method will also panic if In is nil.

type BLowPass

type BLowPass struct {
	// In is the input signal.
	In Input
	// Freq is frequency in Hz.
	Freq Input
	// RQ is the reciprocal of Q, bandwidth / cutoff.
	RQ Input
}

BLowPass is a lowpass filter based on the Second Order Section biquad UGen.

func (BLowPass) Rate

func (blp BLowPass) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type BPF

type BPF struct {
	// In is the input signal
	In Input
	// Freq cutoff in Hz
	Freq Input
	// RQ Reciprocal of Q
	RQ Input
}

BPF a resonant low pass filter

func (BPF) Rate

func (bpf BPF) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type BRF

type BRF struct {
	// In is the input signal
	In Input
	// Freq cutoff in Hz
	Freq Input
	// RQ Reciprocal of Q
	RQ Input
}

BRF a second order band reject filter

func (BRF) Rate

func (brf BRF) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Balance2

type Balance2 struct {
	// L is the left input signal
	L Input
	// R is the right input signal
	R Input
	// Pos stereo position where -1 is hard left and +1 is hard right
	Pos Input
	// Level gain [0, 1]
	Level Input
}

Balance2 equal power panner

func (Balance2) Rate

func (bal Balance2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Ball added in v0.1.4

type Ball struct {
	In       Input
	Gravity  Input
	Damp     Input
	Friction Input
}

Ball models the path of a bouncing object that is reflected by a vibrating surface.

func (Ball) Rate added in v0.1.4

func (b Ball) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Blip

type Blip struct {
	// Freq frequency in Hz
	Freq Input
	// Harm the number of harmonics
	Harm Input
}

Blip band-limited impulse generator

func (Blip) Rate

func (blip Blip) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type BrownNoise

type BrownNoise struct{}

BrownNoise generates noise whose spectrum falls off in power by 6 dB per octave

func (BrownNoise) Rate

func (brown BrownNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Buffer

type Buffer struct {
	Channels   int32
	Frames     int32
	Num        int32
	SampleRate float32
	// contains filtered or unexported fields
}

Buffer is a client-side representation of an scsynth audio buffer

func (*Buffer) Gen

func (buffer *Buffer) Gen(routine string, flags int, args ...float32) error

Gen generates a buffer using a routine. A runtime panic will occur if routine is not one of the BufferRoutine constants.

type C

type C float32

C wraps a float32 and implements the Input interface.

func (C) Abs added in v0.1.4

func (c C) Abs() Input

Abs computes the absolute value of a signal.

func (C) Absdif added in v0.1.4

func (c C) Absdif(val Input) Input

Absdif returns the absolute value of the difference of two inputs.

func (C) Acos added in v0.1.4

func (c C) Acos() Input

Acos computes the arccosine of a signal.

func (C) Add

func (c C) Add(val Input) Input

Add adds another input to the constant.

func (C) Amclip added in v0.1.4

func (c C) Amclip(val Input) Input

Amclip returns 0 when b <= 0, a*b when b > 0.

func (C) AmpDb added in v0.1.4

func (c C) AmpDb() Input

AmpDb converts linear amplitude to decibels.

func (C) Asin added in v0.1.4

func (c C) Asin() Input

Asin computes the arcsine of a signal.

func (C) Atan added in v0.1.4

func (c C) Atan() Input

Atan computes the arctangent of a signal.

func (C) Atan2 added in v0.1.4

func (c C) Atan2(val Input) Input

Atan2 returns the arctangent of y/x.

func (C) Bilinrand added in v0.1.4

func (c C) Bilinrand() Input

Bilinrand returns a linearly distributed random value between [+in ... -in].

func (C) Ceil added in v0.1.4

func (c C) Ceil() Input

Ceil computes the ceiling (next highest integer) of a signal.

func (C) Clip2 added in v0.1.4

func (c C) Clip2(val Input) Input

Clip2 clips input wave a to +/- b

func (C) Coin added in v0.1.4

func (c C) Coin() Input

Coin returns one or zero with the probability given by the input.

func (C) Cos added in v0.1.4

func (c C) Cos() Input

Cos computes the cosine of an Input.

func (C) Cosh added in v0.1.4

func (c C) Cosh() Input

Cosh computes the hyperboliccosine of an Input.

func (C) Cpsmidi added in v0.1.4

func (c C) Cpsmidi() Input

Cpsmidi converts frequency in Hz to midi note values.

func (C) Cpsoct added in v0.1.4

func (c C) Cpsoct() Input

Cpsoct converts cycles per second to decimal octaves.

func (C) Cubed added in v0.1.4

func (c C) Cubed() Input

Cubed computes the cube of a signal.

func (C) DbAmp added in v0.1.4

func (c C) DbAmp() Input

DbAmp converts decibels to linear amplitude.

func (C) Difsqr added in v0.1.4

func (c C) Difsqr(val Input) Input

Difsqr returns the value of (a*a) - (b*b).

func (C) Distort added in v0.1.4

func (c C) Distort() Input

Distort performs non-linear distortion on a signal.

func (C) Div added in v0.1.4

func (c C) Div(val Input) Input

Div divides one input by another. This will panic if val is C(0)

func (C) Excess added in v0.1.4

func (c C) Excess(val Input) Input

Excess returns the difference of the original signal and its clipped form: (a - clip2(a,b)).

func (C) Exp added in v0.1.4

func (c C) Exp() Input

Exp computes the exponential of a signal.

func (C) Expon added in v0.1.4

func (c C) Expon(val Input) Input

Expon raises a constant to the power of another input. If val is not a C the this method just returns c. TODO: fix this

func (C) Floor added in v0.1.4

func (c C) Floor() Input

Floor computes the floor of a constant.

func (C) Fold2 added in v0.1.4

func (c C) Fold2(val Input) Input

Fold2 folds input wave a to +/- b

func (C) Frac added in v0.1.4

func (c C) Frac() Input

Frac returns the fractional part of a constant.

func (C) GCD added in v0.1.4

func (c C) GCD(val Input) Input

GCD computes the gcd of one Input and another.

func (C) GT added in v0.1.4

func (c C) GT(val Input) Input

GT computes x > y.

func (C) GTE added in v0.1.4

func (c C) GTE(val Input) Input

GTE computes x >= y.

func (C) Hypot added in v0.1.4

func (c C) Hypot(val Input) Input

Hypot returns the square root of the sum of the squares of a and b. Or equivalently, the distance from the origin to the point (x, y).

func (C) HypotApx added in v0.1.4

func (c C) HypotApx(val Input) Input

HypotApx returns an approximation of the square root of the sum of the squares of x and y. This uses the formula:

abs(x) + abs(y) - ((sqrt(2) - 1) * min(abs(x), abs(y)))

func (C) LCM added in v0.1.4

func (c C) LCM(val Input) Input

LCM computes the least common multiple of one Input and another.

func (C) LT added in v0.1.4

func (c C) LT(val Input) Input

LT computes x < y.

func (C) LTE added in v0.1.4

func (c C) LTE(val Input) Input

LTE computes x <= y.

func (C) Linrand added in v0.1.4

func (c C) Linrand() Input

Linrand returns a linearly distributed random value between in and zero.

func (C) Log added in v0.1.4

func (c C) Log() Input

Log computes a natural logarithm.

func (C) Log10 added in v0.1.4

func (c C) Log10() Input

Log10 computes a natural logarithm.

func (C) Log2 added in v0.1.4

func (c C) Log2() Input

Log2 computes a natural logarithm.

func (C) Max added in v0.1.3

func (c C) Max(other Input) Input

Max returns the maximum of one input and another.

func (C) Midicps added in v0.1.4

func (c C) Midicps() Input

Midicps converts MIDI note number to cycles per second.

func (C) Midiratio added in v0.1.4

func (c C) Midiratio() Input

Midiratio converts an interval in MIDI notes into a frequency ratio.

func (C) Min added in v0.1.4

func (c C) Min(other Input) Input

Min returns the minimum of one signal and another.

func (C) Moddif added in v0.1.4

func (c C) Moddif(y, mod Input) Input

Moddif returns the smaller of the great circle distances between the two points.

func (C) Modulo added in v0.1.4

func (c C) Modulo(val Input) Input

Modulo computes the modulo of one signal and another. If val is not a C, then this method just returns the receiver. I'm not sure what a constant modulo a ugen should be. Note that Go only supports integers for the modulo operator.

func (C) Mul

func (c C) Mul(val Input) Input

Mul multiplies the constant by another input.

func (C) MulAdd

func (c C) MulAdd(mul, add Input) Input

MulAdd multiplies and adds at the same time.

func (C) Neg added in v0.1.4

func (c C) Neg() Input

Neg is a convenience operator that multiplies a signal by -1.

func (C) Octcps added in v0.1.4

func (c C) Octcps() Input

Octcps converts decimal octaves to cycles per second.

func (C) Pow added in v0.1.4

func (c C) Pow(val Input) Input

Pow raises a constant to the power of another input. If val is not a C the this method just returns c. TODO: fix this

func (C) Rand added in v0.1.4

func (c C) Rand() Input

Rand returns an evenly distributed random value between this and zero.

func (C) Rand2 added in v0.1.4

func (c C) Rand2() Input

Rand2 returns an evenly distributed random value between [+this ... - this].

func (C) Ratiomidi added in v0.1.4

func (c C) Ratiomidi() Input

Ratiomidi converts a frequency ratio to an interval in MIDI notes.

func (C) Reciprocal added in v0.1.4

func (c C) Reciprocal() Input

Reciprocal computes the reciprocal of a signal.

func (C) Ring1 added in v0.1.4

func (c C) Ring1(val Input) Input

Ring1 returns the value of ((a*b) + a).

func (C) Ring2 added in v0.1.4

func (c C) Ring2(val Input) Input

Ring2 returns the value of ((a*b) + a + b).

func (C) Ring3 added in v0.1.4

func (c C) Ring3(val Input) Input

Ring3 returns the value of (a*a*b).

func (C) Ring4 added in v0.1.4

func (c C) Ring4(val Input) Input

Ring4 returns the value of ((a*a *b) - (a*b*b)).

func (C) Round added in v0.1.4

func (c C) Round(val Input) Input

Round performs quantization by rounding. Rounds a to the nearest multiple of b.

func (C) Scaleneg added in v0.1.4

func (c C) Scaleneg(val Input) Input

Scaleneg returns a*b when a < 0, otherwise a.

func (C) Sign added in v0.1.4

func (c C) Sign() Input

Sign computes the sign of the constant.

func (C) Sin added in v0.1.4

func (c C) Sin() Input

Sin computes the sine of an Input.

func (C) Sinh added in v0.1.4

func (c C) Sinh() Input

Sinh computes the hyperbolic sine of an Input.

func (C) SoftClip added in v0.1.3

func (c C) SoftClip() Input

SoftClip clips the constant to the range [-0.5, 0.5]

func (C) Sqrdif added in v0.1.4

func (c C) Sqrdif(val Input) Input

Sqrdif computes the square of the difference between the two inputs.

func (C) Sqrsum added in v0.1.4

func (c C) Sqrsum(val Input) Input

Sqrsum computes the square of the sum of the two inputs.

func (C) Sqrt added in v0.1.4

func (c C) Sqrt() Input

Sqrt computes the square root of a constant.

func (C) Squared added in v0.1.4

func (c C) Squared() Input

Squared computes the square of a signal.

func (C) Sum3rand added in v0.1.4

func (c C) Sum3rand() Input

Sum3rand returns a value from a gaussian-like random distribution between in and zero.

func (C) Sumsqr added in v0.1.4

func (c C) Sumsqr(val Input) Input

Sumsqr returns the value of (a*a) + (b*b).

func (C) Tan added in v0.1.4

func (c C) Tan() Input

Tan computes the tangent of an Input.

func (C) Tanh added in v0.1.4

func (c C) Tanh() Input

Tanh computes the hyperbolic tangent of an Input.

func (C) Thresh added in v0.1.4

func (c C) Thresh(val Input) Input

Thresh returns 0 when c < val, otherwise c.

func (C) Trunc added in v0.1.4

func (c C) Trunc(val Input) Input

Trunc performs quantization by truncation. Truncate c to a multiple of val. If val is not a constant, c is returned.

func (C) Wrap2 added in v0.1.4

func (c C) Wrap2(val Input) Input

Wrap2 wraps input wave to +/-b

type COsc

type COsc struct {
	// BufNum the number of a buffer filled in wavetable format
	BufNum Input
	// Freq frequency in Hz
	Freq Input
	// Beats beat frequency in Hz
	Beats Input
}

COsc is a chorusing wavetable lookup oscillator. Produces sum of 2 signals at

freq +- (beats / 2)

Due to summing, the peak amplitude is twice that of the wavetable.

func (COsc) Rate

func (cosc COsc) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. There will also be a runtime panic if BufNum is nil.

type Client

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

Client manages all communication with scsynth

func DefaultClient

func DefaultClient() (*Client, error)

DefaultClient returns the default sc client.

func NewClient

func NewClient(network, local, scsynth string, timeout time.Duration) (*Client, error)

NewClient creates a new SuperCollider client. The client will bind to the provided address and port to receive messages from scsynth.

func (*Client) AddDefaultGroup

func (c *Client) AddDefaultGroup() (*GroupNode, error)

AddDefaultGroup adds the default group.

func (*Client) AllocBuffer

func (c *Client) AllocBuffer(frames, channels int) (*Buffer, error)

AllocBuffer allocates a buffer on the server

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Connect

func (c *Client) Connect(addr string, timeout time.Duration) error

Connect connects to an scsynth instance via UDP.

func (*Client) DumpOSC

func (c *Client) DumpOSC(level int32) error

DumpOSC sends a /dumpOSC message to scsynth level should be DumpOff, DumpParsed, DumpContents, DumpAll

func (*Client) FreeAll

func (c *Client) FreeAll(gids ...int32) error

FreeAll frees all nodes in a group

func (*Client) Group

func (c *Client) Group(id, action, target int32) (*GroupNode, error)

Group creates a group.

func (*Client) NextSynthID

func (c *Client) NextSynthID() int32

NextSynthID gets the next available ID for creating a synth

func (*Client) NodeFree added in v0.1.4

func (c *Client) NodeFree(id int32) error

NodeFree stops a node abruptly, removes it from its group, and frees its memory. Using this method can cause a click if the node is not silent at the time it is freed.

func (*Client) NodeMap added in v0.1.4

func (c *Client) NodeMap(id int32, m map[string]int32) error

NodeMap causes controls of a node to be read from a control bus. The first argument is the node ID. The second argument is a map from control names to control bus indices.

func (*Client) NodeMapa added in v0.1.4

func (c *Client) NodeMapa(id int32, m map[string]int32) error

NodeMapa causes controls of a node to be read from an audio bus. The first argument is the node ID. The second argument is a map from control names to audio bus indices.

func (*Client) NodeSet added in v0.1.4

func (c *Client) NodeSet(id int32, ctls map[string]float32) error

NodeSet sets a control value on a node.

func (*Client) QueryBuffer added in v0.1.4

func (c *Client) QueryBuffer(num int32) (*Buffer, error)

QueryBuffer gets information about a buffer from scsynth.

func (*Client) QueryGroup

func (c *Client) QueryGroup(id int32) (*GroupNode, error)

QueryGroup g_queryTree for a particular group.

func (*Client) ReadBuffer

func (c *Client) ReadBuffer(path string, num int32, channels ...int) (*Buffer, error)

ReadBuffer tells the server to read an audio file and load it into a buffer.

func (*Client) SendAllDefs added in v0.1.4

func (c *Client) SendAllDefs() error

SendAllDefs sends all the synthdefs that have been registered with RegisterSynthdef.

func (*Client) SendDef

func (c *Client) SendDef(def *Synthdef) error

SendDef sends a synthdef to scsynth. This method blocks until a /done message is received indicating that the synthdef was loaded

func (*Client) Status

func (c *Client) Status(timeout time.Duration) (*ServerStatus, error)

Status gets the status of scsynth with a timeout. If the status request times out it returns ErrTimeout.

func (*Client) Synth

func (c *Client) Synth(defName string, id, action, target int32, ctls map[string]float32) (*Synth, error)

Synth creates a synth node.

func (*Client) Synths added in v0.1.3

func (c *Client) Synths(args []SynthArgs) error

Synths creates multiple synth nodes at once with an OSC bundle.

type ClipNoise

type ClipNoise struct{}

ClipNoise generates noise whose values are either -1 or 1. This produces the maximum energy for the least peak to peak amplitude.

func (ClipNoise) Rate

func (cn ClipNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type CoinGate added in v0.1.4

type CoinGate struct {
	// Value between 0.0 and 1.0 determines probability of either possibilities.
	Prob Input

	// Trigger signal.
	In Input
}

CoinGate tosses a coin every time it receives a trigger and either passes the trigger or doesn't.

func (CoinGate) Rate added in v0.1.4

func (c CoinGate) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Comb

type Comb struct {
	// Interpolation determines the type of interpolation.
	Interpolation Interpolation
	// In the input signal
	In Input
	// MaxDelayTime maximum delay time in seconds, which is used
	// to initialize the delay buffer size.
	MaxDelayTime Input
	// DelayTime delay time in seconds
	DelayTime Input
	// DecayTime time for the echoes to decay by 60dB.
	// If this time is negative then the feedback coefficient will be
	// negative, thus emphasizing only odd harmonics an octave lower.
	DecayTime Input
}

Comb is a delay line with cubic interpolation.

func (Comb) Rate

func (comb Comb) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic. If Interpolation is an unsupported value, then this method will trigger a runtime panic.

type ControlRate added in v0.1.4

type ControlRate struct{}

ControlRate returns the current control rate of the server.

func (ControlRate) Rate added in v0.1.4

func (s ControlRate) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is not IR this method will cause a runtime panic.

type Crackle

type Crackle struct {
	Chaos Input
}

Crackle is a noise generator based on a chaotic function.

func (Crackle) Rate

func (crackle Crackle) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type DC added in v0.1.4

type DC struct {
	In Input
}

DC creates a constant amplitude signal.

func (DC) Rate added in v0.1.4

func (dc DC) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Decay

type Decay struct {
	// In is the input signal
	In Input
	// Decay 60dB decay time in seconds
	Decay Input
}

Decay is an exponential decay.

func (Decay) Rate

func (decay Decay) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type Decay2

type Decay2 struct {
	// In is the input signal
	In Input
	// Attack 60dB attack time in seconds
	Attack Input
	// Decay 60dB decay time in seconds
	Decay Input
}

Decay2 is just like Decay, except it rounds off the attack by subtracting one Decay from another. This fixes the sharp attacks and clicks that can sometimes occur with Decay.

func (Decay2) Rate

func (decay2 Decay2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type DecodeB2 added in v0.1.4

type DecodeB2 struct {
	// NumChans is the number of output speakers. Typically 4 to 8.
	NumChans int

	// The B-format signal.
	// This should be a ugen with 3 outputs: W, X, and Y.
	In Input

	// Orientation should be zero if the front is a vertex of the polygon.
	// The first speaker will be directly in front.
	// Should be 0.5 if the front bisects a side of the polygon.
	// Then the first speaker will be the one left of center.
	Orientation Input
}

DecodeB2 Decodes a two dimensional ambisonic B-format signal to a set of speakers in a regular polygon. The outputs will be in clockwise order. The position of the first speaker is either center or left of center.

func (DecodeB2) Rate added in v0.1.4

func (d DecodeB2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Delay

type Delay struct {
	// Interpolation determines the type of interpolation.
	Interpolation Interpolation
	// In the input signal
	In Input
	// MaxDelayTime maximum delay time in seconds, which is used
	// to initialize the delay buffer size.
	MaxDelayTime Input
	// DelayTime delay time in seconds
	DelayTime Input
}

Delay is a simple delay line.

func (Delay) Rate

func (delay Delay) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type DetectSilence added in v0.1.3

type DetectSilence struct {
	In   Input // The input signal.
	Amp  Input // Amplitude threshold.
	Time Input // The minimum duration for which amplitude must be below Amp before Done triggers.
	Done int   // UGen done-action.
}

DetectSilence evaluates Done when input falls below a certain threshold.

func (DetectSilence) Rate added in v0.1.3

func (ds DetectSilence) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type DigitalIn added in v0.1.7

type DigitalIn struct {
	// Digital pin number to read.
	// Pin numbers begin at 0.
	// This value cannot be modulated.
	DigitalPin Input
}

Read digital data from a digital sensor input. Note: This UGen only works on Bela: https://bela.io/

func (DigitalIn) Rate added in v0.1.7

func (d DigitalIn) Rate(rate int8) Input

Rate returns an Input at the specified rate. This method panics if rate is not a supported value.

type DigitalOut added in v0.1.7

type DigitalOut struct {
	// Digital pin number to write to.
	// Pin numbers begin at 0.
	// This value cannot be modulated.
	DigitalPin Input
	// Value to write out to the pin. The value will be 1 when the argument is larger
	// than 0, otherwise 0.
	Output Input
}

Write data to a digital output. Note: This UGen only works on Bela: https://bela.io/ Note: If you want to modulate the pin number, you should use the UGen DigitalIO

func (DigitalOut) Rate added in v0.1.7

func (d DigitalOut) Rate(rate int8) Input

Rate returns an Input at the specified rate. This method panics if rate is not a supported value.

type Dust

type Dust struct {
	// Density is the average number of impulses per second
	Density Input
}

Dust generates random impulses from 0 to +1

func (Dust) Rate

func (dust Dust) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Dust2

type Dust2 struct {
	// Density is the average number of impulses per second
	Density Input
}

Dust2 generates random impulses from -1 to +1

func (Dust2) Rate

func (dust2 Dust2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Env

type Env struct {
	// Levels is the array of levels
	Levels []Input
	// Times is the array of durations (in seconds).
	// The length of this array should be one less than the
	// Levels array.
	Times []Input
	// Curve determines the shape of each envelope segment.
	// This could be a string, a float, a slice of strings, or a slice of floats.
	Curve       interface{}
	ReleaseNode Input
	LoopNode    Input
}

Env is a specification for a breakpoint envelope

func (Env) Inputs

func (env Env) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvADSR

type EnvADSR struct {
	A, D, S, R, Peak, Curve, Bias Input
}

EnvADSR represents the ever-popular ADSR envelope

func (EnvADSR) Inputs

func (adsr EnvADSR) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvASR

type EnvASR struct {
	A, S, R, Curve Input
}

EnvASR is an attack-sustain-release envelope

func (EnvASR) Inputs

func (asr EnvASR) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvCutoff

type EnvCutoff struct {
	R, Level, CurveType Input
}

EnvCutoff creates an envelope with no attack segment. It simply sustains at the peak level until released.

func (EnvCutoff) Inputs

func (cutoff EnvCutoff) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvDADSR

type EnvDADSR struct {
	Delay, A, D, S, R, Peak, Curve, Bias Input
}

EnvDADSR is EnvADSR with its onset delayed by D seconds

func (EnvDADSR) Inputs

func (dadsr EnvDADSR) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvGen

type EnvGen struct {
	// Env determines the shape of the envelope
	Env Envelope
	// Gate triggers the envelope and holds it open while > 0
	Gate Input
	// LevelScale scales the levels of the breakpoints
	LevelScale Input
	// LevelBias offsets the levels of the breakpoints
	LevelBias Input
	// TimeScale scales the durations of the segments
	TimeScale Input
	// Done is the ugen done action
	Done int
}

EnvGen plays back breakpoint envelopes. The envelopes must implement the Envelope interface. The envelope and the arguments for LevelScale, LevelBias, and TimeScale are polled when the EnvGen is triggered and remain constant for the duration of the envelope.

func (EnvGen) Rate

func (envgen EnvGen) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type EnvLinen

type EnvLinen struct {
	Attack, Sustain, Release, Level Input
	Curve                           interface{}
}

EnvLinen creates a new envelope which has a trapezoidal shape

func (EnvLinen) Inputs

func (linen EnvLinen) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvPairs

type EnvPairs struct {
	Pairs Pairs
	Curve interface{}
}

EnvPairs creates a new envelope from coordinates/pairs

func (EnvPairs) Inputs

func (pairs EnvPairs) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvPerc

type EnvPerc struct {
	Attack, Release, Level, Curve Input
}

EnvPerc creates a new envelope that has a percussive shape

func (EnvPerc) Inputs

func (perc EnvPerc) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvSine

type EnvSine struct {
	Dur, Level Input
}

EnvSine creates a new envelope which has a hanning window shape

func (EnvSine) Inputs

func (sine EnvSine) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type EnvTLC

type EnvTLC []TLC

EnvTLC creates a new envelope from an array of (time, level, curve) triplets This is renamed from Env.xyc. The Curve value of the last triplet is ignored.

func (EnvTLC) Inputs

func (tlc EnvTLC) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

func (EnvTLC) Len

func (tlc EnvTLC) Len() int

func (EnvTLC) Less

func (tlc EnvTLC) Less(i, j int) bool

func (EnvTLC) Swap

func (tlc EnvTLC) Swap(i, j int)

type EnvTriangle

type EnvTriangle struct {
	Dur, Level Input
}

EnvTriangle creates a new envelope that has a triangle shape

func (EnvTriangle) Inputs

func (tri EnvTriangle) Inputs() []Input

Inputs returns the array of inputs that defines the Env.

type Envelope

type Envelope interface {
	// InputsArray provides EnvGen with the data it needs
	// to get a list of inputs.
	Inputs() []Input
}

Envelope is an interface that should be implemented by types that define envelopes for EnvGen.

type FFT added in v0.1.4

type FFT struct {
	// A buffer to store spectral data. The buffer's size must correspond to a power of 2.
	// LocalBuf is useful here, because processes should not share data between synths.
	// (Note: most PV UGens operate on this data in place. Use PV_Copy for parallel processing.)
	Buffer Input
	// The signal to be analyzed. The signal's rate determines the rate at which the input is read.
	In Input
	// The amount of offset from the beginning of one FFT analysis frame to the next, measured in multiples of the analysis frame size.
	// This can range between 1.0 and values close to (but larger than) 0.0,
	// and the default is 0.5 (meaning each frame has a 50% overlap with the preceding/following frames).
	Hop Input
	// Defines how the data is windowed:
	// -1 is rectangular windowing, simple but typically not recommended
	// 0 is (the default) Sine windowing, typically recommended for phase-vocoder work
	// 1 is Hann windowing, typically recommended for analysis work.
	WinType Input
	// A simple control allowing FFT analysis to be active (>0) or inactive (<=0).
	// This is mainly useful for signal analysis processes which are only intended to analyse at specific times rather than continuously
	Active Input
	// The windowed audio frames are usually the same size as the buffer.
	// If you wish the FFT to be zero-padded then you can specify a window size smaller than the actual buffer size
	// (e.g. window size 1024 with buffer size 2048).
	// Both values must still be a power of two. Leave this at its default of zero for no zero-padding.
	WinSize Input
}

FFT implements the Fast Fourier Transform. The fast fourier transform analyzes the frequency content of a signal, which can be useful for audio analysis or for frequency-domain sound processing (phase vocoder).

func (FFT) Rate added in v0.1.4

func (fft FFT) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal or Buffer is not provided this method will trigger a runtime panic.

type FSinOsc

type FSinOsc struct {
	// Freq is frequency in Hz
	Freq Input
	// Phase is the initial phase offset
	Phase Input
}

FSinOsc is a very fast sine wave generator implemented using a ringing filter. This generates a much cleaner sine wave than a table lookup oscillator and is a lot faster. However, the amplitude of the wave will vary with frequency. Generally the amplitude will go down as you raise the frequency and go up as you lower the frequency.

func (FSinOsc) Rate

func (fso FSinOsc) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Formant added in v0.1.4

type Formant struct {
	// FundFreq is the fundamental frequency in Hertz. (control rate)
	FundFreq Input

	// FormantFreq is the formant frequency in Hertz. (control rate)
	FormantFreq Input

	// BWFreq is the pulse width frequency in Hertz.
	// Controls the bandwidth of the formant. (control rate)
	// Must be greater than or equal to fundfreq.
	BWFreq Input
}

Formant generates a set of harmonics around a formant frequency at a given fundamental frequency. The frequency inputs are read at control rate only, so if you use an audio rate UGen as an input, it will only be sampled at the start of each audio synthesis block.

func (Formant) Rate added in v0.1.4

func (f Formant) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Formlet

type Formlet struct {
	// In the input signal
	In Input
	// Freq resonant frequency in Hz
	Freq Input
	// AttackTime 60 dB attack time in seconds
	AttackTime Input
	// DecayTime 60 dB decay time in seconds
	DecayTime Input
}

Formlet is a resonant filter whose impulse response is like that of a sine wave with a Decay2 envelope over it. The great advantage to this filter over FOF is that there is no limit to the number of overlapping grains since the grain is just the impulse response of the filter.

func (Formlet) Rate

func (formlet Formlet) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type FreeVerb

type FreeVerb struct {
	// In the input signal
	In Input
	// Mix dry/wet balance [0, 1]
	Mix Input
	// Room room size [0, 1]
	Room Input
	// Damp high frequency damping [0, 1]
	Damp Input
}

FreeVerb reverb implemented with faust

func (FreeVerb) Rate

func (fv FreeVerb) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type GVerb added in v0.1.4

type GVerb struct {
	// Mono Input
	In Input
	// In squared meters
	RoomSize Input
	// In seconds
	RevTime Input
	// 0 to 1, high frequency rolloff, 0 damps the reverb signal completely, 1 not at all
	Damping Input
	// 0 to 1, same as damping control, but on the input signal.
	InputBW Input
	// A control on the stereo spread and diffusion of the reverb signal.
	Spread Input
	// Amount of dry signal.
	DryLevel Input
	// Amount of early reflection level.
	EarlyRefLevel Input
	// Amount of tail level.
	TailLevel Input
	// To set the size of the delay lines. Defaults to roomsize + 1.
	MaxRoomSize Input
}

GVerb is a two-channel reverb UGen. Based on the "GVerb" LADSPA effect by Juhana Sadeharju (kouhia at nic.funet.fi).

func (GVerb) Rate added in v0.1.4

func (gv GVerb) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type Gate

type Gate struct {
	// In is the input signal.
	In Input
	// Trig is the rigger signal. The output is held fixed when this is non-positive.
	Trig Input
}

Gate allows an input signal value to pass when gate is positive, otherwise holds last value.

func (Gate) Rate

func (gate Gate) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type Gendy1 added in v0.1.4

type Gendy1 struct {
	// Choice of probability distribution for the next perturbation
	// of the amplitude of a control point.
	AmpDist Input

	// Choice of distribution for the perturbation of the current inter control point duration.
	DurDist Input

	// A parameter for the shape of the amplitude probability distribution,
	// requires values in the range 0.0001 to 1 (there are safety checks
	// in the code so don't worry too much if you want to modulate!).
	ADParam Input

	// A parameter for the shape of the duration probability distribution,
	// requires values in the range 0.0001 to 1.
	DDParam Input

	// Minimum allowed frequency of oscillation for the Gendy1 oscillator,
	// so gives the largest period the duration is allowed to take on.
	MinFreq Input

	// Maximum allowed frequency of oscillation for the Gendy1 oscillator,
	// so gives the smallest period the duration is allowed to take on.
	MaxFreq Input

	// Normally 0.0 to 1.0, multiplier for the distribution's delta value for amplitude.
	// An ampscale of 1.0 allows the full range of -1 to 1 for a change of amplitude.
	AmpScale Input

	// Normally 0.0 to 1.0, multiplier for the distribution's delta value for duration.
	// An ampscale of 1.0 allows the full range of -1 to 1 for a change of duration.
	DurScale Input

	// Initialise the number of control points in the memory.
	// Xenakis specifies 12.
	// There would be this number of control points per cycle of the oscillator,
	// though the oscillator's period will constantly change due to the duration distribution.
	InitCPs Input

	// Current number of utilised control points, allows modulation.
	KNum Input
	// contains filtered or unexported fields
}

Gendy1 is an implementation of the dynamic stochastic synthesis generator conceived by Iannis Xenakis and described in Formalized Music (1992, Stuyvesant, NY: Pendragon Press) chapter 9 (pp 246-254) and chapters 13 and 14 (pp 289-322). The BASIC program in the book was written by Marie-Helene Serra so I think it helpful to credit her too. The program code has been adapted to avoid infinities in the probability distribution functions. The distributions are hard-coded in C but there is an option to have new amplitude or time breakpoints sampled from a continuous controller input. All parameters can be modulated at control rate except for initCPs which is used only at initialisation.

func (Gendy1) Rate added in v0.1.4

func (g Gendy1) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Gendy2 added in v0.1.4

type Gendy2 struct {
	Gendy1

	// Parameter for Lehmer random number generator perturbed by Xenakis as in ((old*a)+c)%1.0
	A Input

	// Parameter for Lehmer random number generator perturbed by Xenakis.
	C Input
}

Gendy2 is a dynamic stochastic synthesis generator. See Gendy1 for background. This variant of GENDYN is closer to that presented in Hoffmann, Peter. (2000) The New GENDYN Program. Computer Music Journal 24:2, pp 31-38.

func (Gendy2) Rate added in v0.1.4

func (g Gendy2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Gendy3 added in v0.1.4

type Gendy3 struct {
	// Choice of probability distribution for the next perturbation
	// of the amplitude of a control point.
	AmpDist Input

	// Choice of distribution for the perturbation of the current inter control point duration.
	DurDist Input

	// A parameter for the shape of the amplitude probability distribution,
	// requires values in the range 0.0001 to 1 (there are safety checks
	// in the code so don't worry too much if you want to modulate!).
	ADParam Input

	// A parameter for the shape of the duration probability distribution,
	// requires values in the range 0.0001 to 1.
	DDParam Input

	// Oscillation frquency.
	Freq Input

	// Normally 0.0 to 1.0, multiplier for the distribution's delta value for amplitude.
	// An ampscale of 1.0 allows the full range of -1 to 1 for a change of amplitude.
	AmpScale Input

	// Normally 0.0 to 1.0, multiplier for the distribution's delta value for duration.
	// An ampscale of 1.0 allows the full range of -1 to 1 for a change of duration.
	DurScale Input

	// Initialise the number of control points in the memory.
	// Xenakis specifies 12.
	// There would be this number of control points per cycle of the oscillator,
	// though the oscillator's period will constantly change due to the duration distribution.
	InitCPs Input

	// Current number of utilised control points, allows modulation.
	KNum Input
}

Gendy3 is a dynamic stochastic synthesis generator. See Gendy1 for background. This variant of GENDYN normalises the durations in each period to force oscillation at the desired pitch. The breakpoints still get perturbed as in Gendy1. There is some glitching in the oscillator caused by the stochastic effects: control points as they vary cause big local jumps of amplitude. Put ampscale and durscalelow to minimise the rate of this.

func (Gendy3) Rate added in v0.1.4

func (g Gendy3) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type GrainBuf

type GrainBuf struct {
	// NumChannels is the number of channels to output.
	// If 1, mono is returned and pan is ignored.
	NumChannels int

	// Trigger is a KR or AR trigger to start a new grain.
	// If AR, grains after the start of the synth are
	// sample-accurate.
	Trigger Input

	// Dur is the size of the grain in seconds.
	Dur Input

	// BufNum is the buffer holding a mono audio signal.
	BufNum Input

	// Speed is the playback speed of the grain.
	Speed Input

	// Pos is the position in the audio buffer where
	// the grain will start. This is in the range [0, 1].
	Pos Input

	// Interp is the interpolation method used for
	// pitch-shifting grains.
	// GrainBufNoInterp is no interpolation,
	// GrainBufLinearInterp is linear,
	// and GrainBufCubicInterp is cubic.
	Interp Input

	// Pan determines where to position the output in a stereo
	// field. If NumChannels = 1, no panning is done. If
	// NumChannels = 2, behavior is similar to Pan2. If
	// NumChannels > 2, behavior is the same as PanAz.
	Pan Input

	// EnvBuf is the buffer number containing a signal to use
	// for each grain's amplitude envelope. If set to
	// GrainBufHanningEnv, a built-in Hanning envelope is used.
	EnvBuf Input

	// MaxGrains is the maximum number of overlapping grains
	// that can be used at a given time. This value is set
	// when you initialize GrainBuf and can't be modified.
	// Default is 512, but lower values may result in more
	// efficient use of memory.
	MaxGrains Input
}

GrainBuf is a table-lookup sinewave oscillator

func (GrainBuf) Rate

func (gb GrainBuf) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. There will also be a runtime panic if BufNum is nil.

type GrainFM

type GrainFM struct {
	// NumChannels is the number of channels to output.
	// If 1, mono is returned and pan is ignored.
	NumChannels int
	// Trigger is a KR or AR trigger to start a new grain.
	// If AR, grains after the start of the synth are
	// sample-accurate.
	Trigger Input
	// Dur is the size of the grain (in seconds)
	Dur Input
	// CarFreq the carrier frequency of the grain generator's internal oscillator
	CarFreq Input
	// ModFreq the modulator frequency of the grain generator's internal oscillator
	ModFreq Input
	// ModIndex the index of modulation
	ModIndex Input
	// Pan determines where to position the output in a stereo
	// field. If NumChannels = 1, no panning is done. If
	// NumChannels = 2, behavior is similar to Pan2. If
	// NumChannels > 2, behavior is the same as PanAz.
	Pan Input
	// EnvBuf is the buffer number containing a signal to use
	// for each grain's amplitude envelope. If set to
	// GrainBufHanningEnv, a built-in Hanning envelope is used.
	EnvBuf Input
	// MaxGrains is the maximum number of overlapping grains
	// that can be used at a given time. This value is set
	// when you initialize GrainFM and can't be modified.
	// Default is 512, but lower values may result in more
	// efficient use of memory.
	MaxGrains Input
}

GrainFM is a table-lookup sinewave oscillator

func (GrainFM) Rate

func (gfm GrainFM) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. There will also be a runtime panic if BufNum is nil.

type GrainIn added in v0.1.4

type GrainIn struct {
	// NumChannels is the number of channels to output.
	// If 1, mono is returned and pan is ignored.
	NumChannels int

	// Trigger is a KR or AR trigger to start a new grain.
	// If AR, grains after the start of the synth are
	// sample-accurate.
	Trigger Input

	// Dur is the size of the grain in seconds.
	Dur Input

	// In is the input signal.
	In Input

	// Pan determines where to position the output in a stereo
	// field. If NumChannels = 1, no panning is done. If
	// NumChannels = 2, behavior is similar to Pan2. If
	// NumChannels > 2, behavior is the same as PanAz.
	Pan Input

	// EnvBuf is the buffer holding a mono audio signal.
	EnvBuf Input

	// MaxGrains is the maximum number of overlapping grains
	// that can be used at a given time. This value is set
	// when you initialize GrainBuf and can't be modified.
	// Default is 512, but lower values may result in more
	// efficient use of memory.
	MaxGrains Input
}

GrainIn granulates an input signal.

func (GrainIn) Rate added in v0.1.4

func (g GrainIn) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic. If the trig signal is nil this method will panic.

type GrainSin added in v0.1.4

type GrainSin struct {
	// NumChannels is the number of channels to output.
	// If 1, mono is returned and pan is ignored.
	NumChannels int

	// Trigger is a KR or AR trigger to start a new grain.
	// If AR, grains after the start of the synth are
	// sample-accurate.
	Trigger Input

	// Dur is the size of the grain in seconds.
	Dur Input

	// Freq is the input to granulate.
	Freq Input

	// Pan determines where to position the output in a stereo
	// field. If NumChannels = 1, no panning is done. If
	// NumChannels = 2, behavior is similar to Pan2. If
	// NumChannels > 2, behavior is the same as PanAz.
	Pan Input

	// EnvBuf is the buffer holding a mono audio signal.
	EnvBuf Input

	// MaxGrains is the maximum number of overlapping grains
	// that can be used at a given time. This value is set
	// when you initialize GrainBuf and can't be modified.
	// Default is 512, but lower values may result in more
	// efficient use of memory.
	MaxGrains Input
}

GrainSin implements granular synthesis with sine tones. All args except numChannels and trigger are polled at grain creation time.

func (GrainSin) Rate added in v0.1.4

func (g GrainSin) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic. If the trig signal is nil this method will panic.

type GrayNoise

type GrayNoise struct {
}

GrayNoise generates noise which results from flipping random bits in a word. This type of noise has a high RMS level relative to its peak to peak level. The spectrum is emphasized towards lower frequencies.

func (GrayNoise) Rate

func (gn GrayNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type GroupNode added in v0.1.4

type GroupNode struct {
	Children []Node
	// contains filtered or unexported fields
}

GroupNode is a group of nodes.

func (*GroupNode) Free added in v0.1.4

func (g *GroupNode) Free() error

Free frees all the nodes in a group. TODO

func (*GroupNode) FreeAll added in v0.1.4

func (g *GroupNode) FreeAll() error

FreeAll frees all the nodes in a group recursively. TODO

func (*GroupNode) ID added in v0.1.4

func (g *GroupNode) ID() int32

ID returns the node ID.

func (*GroupNode) Synth added in v0.1.4

func (g *GroupNode) Synth(defName string, id, action int32, ctls map[string]float32) (*Synth, error)

Synth adds a synth to a group

func (*GroupNode) Synths added in v0.1.4

func (g *GroupNode) Synths(args []SynthArgs) error

Synths creates multiple synth nodes at once with an OSC bundle.

type HPF added in v0.1.4

type HPF struct {
	// In is the input signal
	In Input
	// Freq cutoff in Hz
	Freq Input
}

HPF is a 2nd order Butterworth highpass filter.

func (HPF) Rate added in v0.1.4

func (hpf HPF) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Hasher added in v0.1.4

type Hasher struct {
	In Input
}

Hasher returns a unique output value from -1 to +1 for each input value according to a hash function. The same input value will always produce the same output value. The input need not be in the range -1 to +1.

func (Hasher) Rate added in v0.1.4

func (hasher Hasher) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil then this method will cause a runtime panic.

type IFFT added in v0.1.4

type IFFT struct {
	// The FFT "chain" signal coming originally from an FFT UGen,
	// perhaps via other PV UGens.
	Buffer Input

	// WinType defines how the data is windowed:
	//   -1 is rectangular windowing, simple but typically not recommended;
	//    0 (the default) is sine windowing, typically recommended for phase-vocoder work;
	//    1 is Hann windowing, typically recommended for analysis work.
	WinType Input

	// WinSize can be used to account for zero-padding,
	// in the same way as the FFT UGen.
	WinSize Input
}

IFFT converts from frequency content to a signal. The fast fourier transform analyzes the frequency content of a signal. The IFFT UGen converts this frequency-domain information back into time-domain audio data. Most often this is used as the end of a process which begins with FFT, followed by frequency-domain processing using PV (phase-vocoder) UGens, followed by IFFT.

func (IFFT) Rate added in v0.1.4

func (ifft IFFT) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Impulse

type Impulse struct {
	// Freq frequency in Hz
	Freq Input
	// Phase offset in cycles [0, 1]
	Phase Input
}

Impulse non-band-limited single-sample impulses

func (Impulse) Rate

func (impulse Impulse) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type In added in v0.1.4

type In struct {
	NumChannels int
	Bus         Input
}

In reads signals from busses.

func (In) Rate added in v0.1.4

func (in In) Rate(rate int8) Input

Rate returns an Input at the specified rate. This method panics if rate is not a supported value.

type Input

type Input interface {
	// Abs computes the absolute value of a signal.
	Abs() Input

	// Absdif returns the absolute value of the difference of two inputs.
	Absdif(Input) Input

	// Acos computes the arccosine of a signal.
	Acos() Input

	// Amclip returns 0 when b <= 0, a*b when b > 0.
	Amclip(Input) Input

	// Asin computes the arcsine of a signal.
	Asin() Input

	// Atan computes the arctangent of a signal.
	Atan() Input

	// Atan2 returns the arctangent of y/x.
	Atan2(val Input) Input

	// Add adds one Input to another.
	Add(val Input) Input

	// AmpDb converts linear amplitude to decibels.
	AmpDb() Input

	// Bilinrand returns a linearly distributed random value between [+in ... -in].
	Bilinrand() Input

	// Ceil computes the ceiling (next lowest integer) of a signal.
	Ceil() Input

	// Clip2 clips input wave a to +/- b
	Clip2(Input) Input

	// Coin returns one or zero with the probability given by the input.
	Coin() Input

	// Cos computes the cosine of an Input.
	Cos() Input

	// Cosh computes the hyperbolic cosine of an Input.
	Cosh() Input

	// Cpsmidi converts frequency in Hz to midi note values.
	Cpsmidi() Input

	// Cpsoct converts cycles per second to decimal octaves.
	Cpsoct() Input

	// Cubed raises a signal to the power of 3.
	Cubed() Input

	// DbAmp converts decibels to linear amplitude.
	DbAmp() Input

	// Difsqr returns the value of (a*a) - (b*b).
	Difsqr(Input) Input

	// Distort performs non-linear distortion on a signal.
	Distort() Input

	// Div divides one input by another.
	Div(Input) Input

	// Exp computes the exponential of a signal.
	Exp() Input

	// Expon raises this input to the power of another.
	// When used with UGens which produce a negative signal this function extends
	// the usual definition of exponentiation and returns neg(neg(a) ** b).
	// This allows exponentiation of negative signal values by noninteger exponents.
	// For the normal behaviour use Pow (see below).
	Expon(Input) Input

	// Excess returns the difference of the original signal and its clipped form: (a - clip2(a,b)).
	Excess(Input) Input

	// Floor computes the floor (next lowest integer) of a signal.
	Floor() Input

	// Fold2 folds input wave a to +/- b
	Fold2(Input) Input

	// Frac returns the fractional part of a signal.
	Frac() Input

	// GCD computes the gcd of one Input and another.
	GCD(Input) Input

	// GT computes x > y.
	GT(Input) Input

	// GT computes x >= y.
	GTE(Input) Input

	// Hypot returns the square root of the sum of the squares of a and b.
	// Or equivalently, the distance from the origin to the point (x, y).
	Hypot(Input) Input

	// HypotApx returns an approximation of the square root of the sum of the squares of x and y.
	HypotApx(Input) Input

	// LCM computes the least common multiple of one Input and another.
	LCM(Input) Input

	// LT computes x < y.
	LT(Input) Input

	// LT computes x <= y.
	LTE(Input) Input

	// Linrand returns a linearly distributed random value between in and zero.
	Linrand() Input

	// Log computes a natural logarithm.
	Log() Input

	// Log10 computes a base 10 logarithm.
	Log10() Input

	// Log2 computes a base 2 logarithm.
	Log2() Input

	// Max returns the max of one signal and another.
	Max(other Input) Input

	// Midicps converts MIDI note number to cycles per second.
	Midicps() Input

	// Midiratio converts an interval in MIDI notes into a frequency ratio.
	Midiratio() Input

	// Min returns the minimum of one signal and another.
	Min(Input) Input

	// Moddif returns the smaller of the great circle distances between the two points.
	Moddif(Input, Input) Input

	// Modulo computes the modulo of one signal and another.
	Modulo(Input) Input

	// Mul multiplies one Input by another.
	Mul(val Input) Input

	// MulAdd multiplies and adds an Input using two others.
	MulAdd(mul, add Input) Input

	// Neg is a convenience operator that multiplies a signal by -1.
	Neg() Input

	// Octcps converts decimal octaves to cycles per second.
	Octcps() Input

	// Pow raises an Input to the power of another.
	Pow(Input) Input

	// Rand returns an evenly distributed random value between this and zero.
	Rand() Input

	// Rand2 returns an evenly distributed random value between [+this ... - this].
	Rand2() Input

	// Ratiomidi converts a frequency ratio to an interval in MIDI notes.
	Ratiomidi() Input

	// Reciprocal computes the reciprocal of a signal.
	Reciprocal() Input

	// Ring1 is ring modulation plus first source.
	Ring1(val Input) Input

	// Ring2 is ring modulation plus both sources.
	Ring2(val Input) Input

	// Ring3 returns the value of (a*a *b)
	Ring3(val Input) Input

	// Ring4 returns the value of ((a*a *b) - (a*b*b)).
	Ring4(val Input) Input

	// Round performs quantization by rounding. Rounds a to the nearest multiple of b.
	Round(Input) Input

	// Scaleneg returns a*b when a < 0, otherwise a.
	Scaleneg(Input) Input

	// Sign computes the sign of a signal.
	// This returns -1 when a < 0, +1 when a > 0, 0 when a is 0.
	Sign() Input

	// Sin computes the sine of an Input.
	Sin() Input

	// Sinh computes the hyperbolic sine of an Input.
	Sinh() Input

	// SoftClip distorts a signal with a perfectly linear range from -0.5 to 0.5
	SoftClip() Input

	// Sqrdif computes the square of the difference between the two inputs.
	Sqrdif(Input) Input

	// Sqrsum computes the square of the sum of the two inputs.
	Sqrsum(Input) Input

	// Sqrt computes the square root of a signal.
	// The definition of square root is extended for signals so that sqrt(a)
	// when a < 0 returns -sqrt(-a).
	Sqrt() Input

	// Squared raises a signal to the power of 2.
	Squared() Input

	// Sum3rand returns a value from a gaussian-like random distribution between in and zero.
	Sum3rand() Input

	// Sumsqr returns the value of (a*a) + (b*b).
	Sumsqr(Input) Input

	// Tan computes the tangent of an Input.
	Tan() Input

	// Tanh computes the hyperbolic tangent of an Input.
	Tanh() Input

	// Thresh returns 0 when a < b, otherwise a.
	Thresh(Input) Input

	// Trunc performs quantization by truncation. Truncate a to a multiple of b.
	Trunc(Input) Input

	// Wrap2 wraps input wave to +/- b
	Wrap2(Input) Input
}

Input is implemented by any value that can serve as a ugen input. This includes synthdef parameters, constants, and other ugens.

func A added in v0.1.4

func A(r Rater) Input

A returns a ugen input at audio rate.

func Fill added in v0.1.4

func Fill(n int, input Input) []Input

Fill returns a slice of inputs that has length n and every element is set to input.

func I added in v0.1.4

func I(r Rater) Input

I returns a ugen input at initialization rate.

func K added in v0.1.4

func K(r Rater) Input

K returns a ugen input at control rate.

func Mix

func Mix(rate int8, inputs []Input) Input

Mix will mix an array of channels down to a single channel.

func NewInput added in v0.1.4

func NewInput(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) Input

NewInput creates a ugen suitable for use as an input to other ugens. It will return either a single-channel ugen or a multi-channel ugen.

func RandArray added in v0.1.4

func RandArray(n int, min, max float64) []Input

RandArray returns a slice (of length n) of random constants between min and max.

func RandC added in v0.1.4

func RandC(min, max float64) Input

RandC returns a random constant between min and max.

func Sum3

func Sum3(rate int8, in1, in2, in3 Input) Input

Sum3 sums three signals. Should be used via Mix.

func Sum4

func Sum4(rate int8, in1, in2, in3, in4 Input) Input

Sum4 sums four signals. Should be used via Mix.

type Inputs

type Inputs []Input

Inputs is a slice of Input.

func Multi

func Multi(inputs ...Input) Inputs

Multi does multichannel expansion. See http://doc.sccode.org/Guides/Multichannel-Expansion.html.

func (Inputs) Abs added in v0.1.4

func (ins Inputs) Abs() Input

Abs computes the absolute value of a signal.

func (Inputs) Absdif added in v0.1.4

func (ins Inputs) Absdif(val Input) Input

Absdif returns the absolute value of the difference of two inputs.

func (Inputs) Acos added in v0.1.4

func (ins Inputs) Acos() Input

Acos computes the arccosine of a signal.

func (Inputs) Add

func (ins Inputs) Add(val Input) Input

Add adds an input to all the inputs.

func (Inputs) Amclip added in v0.1.4

func (ins Inputs) Amclip(val Input) Input

Amclip returns 0 when b <= 0, a*b when b > 0.

func (Inputs) AmpDb added in v0.1.4

func (ins Inputs) AmpDb() Input

AmpDb converts linear amplitude to decibels.

func (Inputs) Asin added in v0.1.4

func (ins Inputs) Asin() Input

Asin computes the arcsine of a signal.

func (Inputs) Atan added in v0.1.4

func (ins Inputs) Atan() Input

Atan computes the arctangent of a signal.

func (Inputs) Atan2 added in v0.1.4

func (ins Inputs) Atan2(val Input) Input

Atan2 returns the arctangent of y/x.

func (Inputs) Bilinrand added in v0.1.4

func (ins Inputs) Bilinrand() Input

Bilinrand returns a linearly distributed random value between [+in ... -in].

func (Inputs) Ceil added in v0.1.4

func (ins Inputs) Ceil() Input

Ceil computes the ceiling (next highest integer) of a signal.

func (Inputs) Clip2 added in v0.1.4

func (ins Inputs) Clip2(val Input) Input

Clip2 clips input wave a to +/- b

func (Inputs) Coin added in v0.1.4

func (ins Inputs) Coin() Input

Coin returns one or zero with the probability given by the input.

func (Inputs) Cos added in v0.1.4

func (ins Inputs) Cos() Input

Cos returns the cosine of an Inputs.

func (Inputs) Cosh added in v0.1.4

func (ins Inputs) Cosh() Input

Cosh returns the hyperbolic cosine of an Inputs.

func (Inputs) Cpsmidi added in v0.1.4

func (ins Inputs) Cpsmidi() Input

Cpsmidi converts frequency in Hz to midi note values.

func (Inputs) Cpsoct added in v0.1.4

func (ins Inputs) Cpsoct() Input

Cpsoct converts cycles per second to decimal octaves.

func (Inputs) Cubed added in v0.1.4

func (ins Inputs) Cubed() Input

Cubed computes the cube of a signal.

func (Inputs) DbAmp added in v0.1.4

func (ins Inputs) DbAmp() Input

DbAmp converts decibels to linear amplitude.

func (Inputs) Difsqr added in v0.1.4

func (ins Inputs) Difsqr(val Input) Input

Difsqr returns the value of (a*a) - (b*b).

func (Inputs) Distort added in v0.1.4

func (ins Inputs) Distort() Input

Distort performs non-linear distortion on a signal.

func (Inputs) Div added in v0.1.4

func (ins Inputs) Div(val Input) Input

Div divides one input by another.

func (Inputs) Excess added in v0.1.4

func (ins Inputs) Excess(val Input) Input

Excess returns the difference of the original signal and its clipped form: (a - clip2(a,b)).

func (Inputs) Exp added in v0.1.4

func (ins Inputs) Exp() Input

Exp computes the exponential of a signal.

func (Inputs) Expon added in v0.1.4

func (ins Inputs) Expon(val Input) Input

Expon raises this input to the power of another.

func (Inputs) Floor added in v0.1.4

func (ins Inputs) Floor() Input

Floor computes the floor (next lowest integer) of a signal.

func (Inputs) Fold2 added in v0.1.4

func (ins Inputs) Fold2(val Input) Input

Fold2 folds input wave a to +/- b

func (Inputs) Frac added in v0.1.4

func (ins Inputs) Frac() Input

Frac computes the fractional part of a signal.

func (Inputs) GCD added in v0.1.4

func (ins Inputs) GCD(val Input) Input

GCD computes the gcd of one Input and another.

func (Inputs) GT added in v0.1.4

func (ins Inputs) GT(val Input) Input

GT computes x > y.

func (Inputs) GTE added in v0.1.4

func (ins Inputs) GTE(val Input) Input

GTE computes x >= y.

func (Inputs) Hypot added in v0.1.4

func (ins Inputs) Hypot(val Input) Input

Hypot returns the square root of the sum of the squares of a and b. Or equivalently, the distance from the origin to the point (x, y).

func (Inputs) HypotApx added in v0.1.4

func (ins Inputs) HypotApx(val Input) Input

HypotApx returns an approximation of the square root of the sum of the squares of x and y.

func (Inputs) InputArray

func (ins Inputs) InputArray() []Input

InputArray provides access to the list of inputs.

func (Inputs) LCM added in v0.1.4

func (ins Inputs) LCM(val Input) Input

LCM computes the lcm of one Input and another.

func (Inputs) LT added in v0.1.4

func (ins Inputs) LT(val Input) Input

LT computes x < y.

func (Inputs) LTE added in v0.1.4

func (ins Inputs) LTE(val Input) Input

LTE computes x <= y.

func (Inputs) Linrand added in v0.1.4

func (ins Inputs) Linrand() Input

Linrand returns a linearly distributed random value between in and zero.

func (Inputs) Log added in v0.1.4

func (ins Inputs) Log() Input

Log computes a natural logarithm.

func (Inputs) Log10 added in v0.1.4

func (ins Inputs) Log10() Input

Log10 computes a base 10 logarithm.

func (Inputs) Log2 added in v0.1.4

func (ins Inputs) Log2() Input

Log2 computes a base 2 logarithm.

func (Inputs) Max added in v0.1.3

func (ins Inputs) Max(other Input) Input

Max returns Inputs that contain the max of all the inputs and the provided Input.

func (Inputs) Midicps added in v0.1.4

func (ins Inputs) Midicps() Input

Midicps converts MIDI note number to cycles per second.

func (Inputs) Midiratio added in v0.1.4

func (ins Inputs) Midiratio() Input

Midiratio converts an interval in MIDI notes into a frequency ratio.

func (Inputs) Min added in v0.1.4

func (ins Inputs) Min(other Input) Input

Min returns the minimum of one signal and another.

func (Inputs) Moddif added in v0.1.4

func (ins Inputs) Moddif(y, mod Input) Input

Moddif returns the smaller of the great circle distances between the two points.

func (Inputs) Modulo added in v0.1.4

func (ins Inputs) Modulo(val Input) Input

Modulo computes the modulo of one signal and another.

func (Inputs) Mul

func (ins Inputs) Mul(val Input) Input

Mul multiplies all the inputs by another input.

func (Inputs) MulAdd

func (ins Inputs) MulAdd(mul, add Input) Input

MulAdd performs a multiplication and addition on all the inputs.

func (Inputs) Neg added in v0.1.4

func (ins Inputs) Neg() Input

Neg is a convenience operator that multiplies a signal by -1.

func (Inputs) Octcps added in v0.1.4

func (ins Inputs) Octcps() Input

Octcps converts decimal octaves to cycles per second.

func (Inputs) Pow added in v0.1.4

func (ins Inputs) Pow(val Input) Input

Pow raises this input to the power of another.

func (Inputs) Rand added in v0.1.4

func (ins Inputs) Rand() Input

Rand returns an evenly distributed random value between this and zero.

func (Inputs) Rand2 added in v0.1.4

func (ins Inputs) Rand2() Input

Rand2 returns an evenly distributed random value between [+this ... - this].

func (Inputs) Ratiomidi added in v0.1.4

func (ins Inputs) Ratiomidi() Input

Ratiomidi converts a frequency ratio to an interval in MIDI notes.

func (Inputs) Reciprocal added in v0.1.4

func (ins Inputs) Reciprocal() Input

Reciprocal computes the reciprocal of a signal.

func (Inputs) Ring1 added in v0.1.4

func (ins Inputs) Ring1(val Input) Input

Ring1 is ring modulation plus first source.

func (Inputs) Ring2 added in v0.1.4

func (ins Inputs) Ring2(val Input) Input

Ring2 is ring modulation plus both sources.

func (Inputs) Ring3 added in v0.1.4

func (ins Inputs) Ring3(val Input) Input

Ring3 returns the value of (a*a *b)

func (Inputs) Ring4 added in v0.1.4

func (ins Inputs) Ring4(val Input) Input

Ring4 returns the value of ((a*a *b) - (a*b*b)).

func (Inputs) Round added in v0.1.4

func (ins Inputs) Round(val Input) Input

Round performs quantization by rounding. Rounds a to the nearest multiple of b.

func (Inputs) Scaleneg added in v0.1.4

func (ins Inputs) Scaleneg(val Input) Input

Scaleneg returns a*b when a < 0, otherwise a.

func (Inputs) Sign added in v0.1.4

func (ins Inputs) Sign() Input

Sign computes the sign of a signal.

func (Inputs) Sin added in v0.1.4

func (ins Inputs) Sin() Input

Sin returns the sine of an Inputs.

func (Inputs) Sinh added in v0.1.4

func (ins Inputs) Sinh() Input

Sinh returns the hyperbolic sine of an Inputs.

func (Inputs) SoftClip added in v0.1.3

func (ins Inputs) SoftClip() Input

SoftClip adds distortion to the inputs.

func (Inputs) Sqrdif added in v0.1.4

func (ins Inputs) Sqrdif(val Input) Input

Sqrdif computes the square of the difference between the two inputs.

func (Inputs) Sqrsum added in v0.1.4

func (ins Inputs) Sqrsum(val Input) Input

Sqrsum computes the square of the sum of the two inputs.

func (Inputs) Sqrt added in v0.1.4

func (ins Inputs) Sqrt() Input

Sqrt computes the square root of a signal.

func (Inputs) Squared added in v0.1.4

func (ins Inputs) Squared() Input

Squared computes the square of a signal.

func (Inputs) Sum3rand added in v0.1.4

func (ins Inputs) Sum3rand() Input

Sum3rand returns a value from a gaussian-like random distribution between in and zero.

func (Inputs) Sumsqr added in v0.1.4

func (ins Inputs) Sumsqr(val Input) Input

Sumsqr returns the value of (a*a) + (b*b).

func (Inputs) Tan added in v0.1.4

func (ins Inputs) Tan() Input

Tan returns the tangent of an Inputs.

func (Inputs) Tanh added in v0.1.4

func (ins Inputs) Tanh() Input

Tanh returns the hyperbolic tangent of an Inputs.

func (Inputs) Thresh added in v0.1.4

func (ins Inputs) Thresh(val Input) Input

Thresh returns 0 when a < b, otherwise a.

func (Inputs) Trunc added in v0.1.4

func (ins Inputs) Trunc(val Input) Input

Trunc performs quantization by truncation. Truncate a to a multiple of b.

func (Inputs) Wrap2 added in v0.1.4

func (ins Inputs) Wrap2(val Input) Input

Wrap2 wraps input wave to +/-b

type Integrator

type Integrator struct {
	// In is the input signal
	In Input
	// Coef is the leak coefficient
	Coef Input
}

Integrator integrates an input signal with a leak. The formula used is

out(0) = in(0) + (coef * out(-1))

func (Integrator) Rate

func (integrator Integrator) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If an In signal is not provided this method will trigger a runtime panic.

type Interpolation

type Interpolation int

Interpolation is a smoothing strategy for delay lines. Possible values are

  • InterpolationNone
  • InterpolationLinear
  • InterpolationCubic
const (
	InterpolationNone Interpolation = iota
	InterpolationLinear
	InterpolationCubic
)

Interpolation types.

type JPverb added in v0.1.4

type JPverb struct {
	// In is the input signal.
	In Input

	// T60 is time for the reverb to decay 60db.
	// Does not effect early reflections. (0.1..60)
	T60 Input

	// Damp controls damping of high-frequencies as the reverb decays.
	// 0 is no damping, 1 is very strong damping (0..1)
	Damp Input

	// Size scales size of delay-lines within the reverberator,
	// producing the impression of a larger or smaller space.
	// Values below 1 can sound metallic. (0.5..5)
	Size Input

	// EarlyDiff controls shape of early reflections.
	// Values of 0.707 or more produce smooth exponential decay.
	// Lower values produce a slower build-up of echoes. (0..1)
	EarlyDiff Input

	// ModDepth is the depth of delay-line modulation.
	// Use in combination with ModFreq to set amount of chorusing
	// within the structure. (0..1)
	ModDepth Input

	// ModFreq is the frequency of delay-line modulation.
	// Use in combination with modDepth to set amount of chorusing
	// within the structure. (0..10)
	ModFreq Input

	// Low is the multiplier for the reverberation time within the low band. (0..1)
	Low Input

	// Mid is the multiplier for the reverberation time within the mid band. (0..1)
	Mid Input

	// High is the multiplier for the reverberation time within the high band. (0..1)
	High Input

	// LowCut is the frequency at which the crossover between
	// the low and mid bands of the reverb occurs. (100..6000)
	LowCut Input

	HighCut Input
}

JPverb is a reverb effect from sc3-plugins. See https://github.com/supercollider/sc3-plugins and http://doc.sccode.org/Classes/JPverb.html

func (JPverb) Rate added in v0.1.4

func (jpv JPverb) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type Klang added in v0.1.4

type Klang struct {
	// Spec consists of 3 Input slices.
	//   1. frequencies: An Array of oscillator frequencies.
	//   2. amplitudes: A slice of oscillator amplitudes, or nil. If nil, then amplitudes default to 1.0.
	//   3. phases: A slice of initial phases, or nil. If nil, then phases default to 0.0.
	// The parameters in specificationsArrayRef can't be changed after it has been started.
	// For a modulatable but less efficient version, see DynKlang.
	Spec Input

	// A scale factor multiplied by all frequencies at initialization time.
	FreqScale Input

	// An offset added to all frequencies at initialization time.
	FreqOffset Input
}

Klang is a bank of fixed frequency sine oscillators. Klang is more efficient than creating individual oscillators but offers less flexibility.

func (Klang) Rate added in v0.1.4

func (k Klang) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Klank added in v0.1.3

type Klank struct {
	// In is the excitation input to the resonant filter bank.
	In Input

	// Spec is three Input slices (which should all have the same length).
	// The first slice is the filter frequencies.
	// The second slice is the filter amplitudes.
	// The third slice is the 60dB decay times in seconds for the filters.
	Spec Input

	// FreqScale is a scale factor multiplied by all frequencies at initialization time.
	FreqScale Input

	// FreqOffset is an offset added to all frequencies at initialization time.
	FreqOffset Input

	// DecayScale is a scale factor multiplied by all ring times at initialization time.
	DecayScale Input
}

Klank is a bank of fixed frequency resonators which can be used to simulate the resonant modes of an object. Each mode is given a ring time, which is the time for the mode to decay by 60 dB.

func (Klank) Rate added in v0.1.3

func (k Klank) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If k.In is nil this method will cause a runtime panic. If k.Spec is not ArraySpec or Multi(ArraySpec...) then this method will panic.

type LFClipNoise added in v0.1.4

type LFClipNoise struct {
	Freq Input
}

LFClipNoise randomly generates the values -1 or +1 at a rate given by the nearest integer division of the sample rate by the freqargument. It is probably pretty hard on your speakers!

func (LFClipNoise) Rate added in v0.1.4

func (l LFClipNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFCub

type LFCub struct {
	// Freq frequency in Hz
	Freq Input
	// Iphase initial phase offset
	Iphase Input
}

LFCub is a sine-like shape made of two cubic pieces. It is smoother than LFPar.

func (LFCub) Rate

func (lfcub LFCub) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFDClipNoise added in v0.1.4

type LFDClipNoise struct {
	Freq Input
}

LFDClipNoise is like LFClipNoise, except it generates the values -1 or +1 at a rate given by the freq argument, with two differences:

no time quantization
fast recovery from low freq values1

If you don't need very high or very low freqs, or use fixed freqs, LFDClipNoise is more efficient.

func (LFDClipNoise) Rate added in v0.1.4

func (l LFDClipNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFDNoise added in v0.1.3

type LFDNoise struct {
	Interpolation Interpolation
	Freq          Input
}

LFDNoise generates random values at a rate given by the freq argument, with two differences: no time quantization, and fast recovery from low freq values.

func (LFDNoise) Rate added in v0.1.3

func (lfdn LFDNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFGauss added in v0.1.4

type LFGauss struct {
	Duration Input
	Width    Input
	IPhase   Input
	Loop     Input
	Done     int
}

LFGauss is a non-band-limited gaussian function oscillator. Output ranges from minval to 1. LFGauss implements the formula:

f(x) = exp(squared(x - iphase) / (-2.0 * squared(width)))

where x is to vary in the range -1 to 1 over the period dur. minval is the initial value at -1.

func (LFGauss) Rate added in v0.1.4

func (l LFGauss) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFNoise

type LFNoise struct {
	Interpolation NoiseInterpolation
	Freq          Input
}

LFNoise generates random values at a rate given by the nearest integer division of the sample rate by the Freq input. The values will be interpolated according to the Interpolation input.

func (LFNoise) Rate

func (lfnoise LFNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFPar added in v0.1.4

type LFPar struct {
	// Freq is frequency in Hz.
	Freq Input

	// IPhase is the initial phase (0..1).
	IPhase Input
}

LFPar is a sine-like shape made of two parabolas and the integral of a triangular wave. It has audible odd harmonics and is non-band-limited. Output ranges from -1 to +1.

func (LFPar) Rate added in v0.1.4

func (l LFPar) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFPulse

type LFPulse struct {
	// Freq in Hz
	Freq Input
	// IPhase initial phase offset in cycles (0..1)
	IPhase Input
	// Width pulse width duty cycle from 0 to 1
	Width Input
}

LFPulse a non-band-limited pulse oscillator

func (LFPulse) Rate

func (lfpulse LFPulse) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFSaw

type LFSaw struct {
	// Freq frequency in Hz
	Freq Input
	// Iphase initial phase offset in cycles:
	// for efficiency this is in the rage [0, 2]
	Iphase Input
}

LFSaw a non-band-limited sawtooth oscillator output ranges from -1 to +1

func (LFSaw) Rate

func (lfsaw LFSaw) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LFTri

type LFTri struct {
	// Freq is the approximate rate at which to
	// generate random values
	Freq Input
	// Iphase initial phase offset in the range [0, 4]
	Iphase Input
}

LFTri is a non-band-limited triangle oscillator. Output is [-1, 1].

func (LFTri) Rate

func (lftri LFTri) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LPF added in v0.1.4

type LPF struct {
	// In is the input signal
	In Input
	// Freq cutoff in Hz
	Freq Input
}

LPF is a second order low pass filter.

func (LPF) Rate added in v0.1.4

func (lpf LPF) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Lag added in v0.1.4

type Lag struct {
	// In is the input signal.
	In Input

	// LagTime is the 60 dB lag time in seconds.
	LagTime Input
}

Lag is essentially the same as OnePole except that instead of supplying the coefficient directly, it is calculated from a 60 dB lag time. This is the time required for the filter to converge to within 0.01% of a value. This is useful for smoothing out control signals.

func (Lag) Rate added in v0.1.4

func (l Lag) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type Latch added in v0.1.4

type Latch struct {
	// In is the input signal.
	In Input

	// Trig can be any signal.
	// A trigger happens when the signal changes from non-positive to positive.
	Trig Input
}

Latch is a sample and hold. It holds input signal value when triggered. Latch will output 0 until it receives its first trigger.

func (Latch) Rate added in v0.1.4

func (l Latch) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic. If the trig signal is nil this method will panic.

type LeakDC added in v0.1.4

type LeakDC struct {
	// In is the input signal.
	In Input

	// Coeff is the leak coefficient.
	Coeff Input
	// contains filtered or unexported fields
}

LeakDC removes DC offset from a signal.

func (LeakDC) Rate added in v0.1.4

func (ldc LeakDC) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will cause a runtime panic.

type Limiter

type Limiter struct {
	In    Input // The signal to be processed.
	Level Input // The peak output amplitude level to which to normalize the input.
	Dur   Input // The buffer delay time. Shorter times will produce smaller delays and quicker transient response times, but may introduce amplitude modulation artifacts.
}

Limiter limits the input amplitude to the given level. Limiter will not overshoot like Compander will, but it needs to look ahead in the audio. Thus there is a delay equal to twice the value of the dur parameter. Limiter, unlike Compander, is completely transparent for an in range signal. The Rate method of Limiter will panic if In is nil.

func (Limiter) Rate

func (limiter Limiter) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LinPan2 added in v0.1.4

type LinPan2 struct {
	In    Input
	Pos   Input
	Level Input
}

LinPan2 is a two channel linear panner. The signal is lowered as it pans from left (or right) to center using a straight line from 1 (left or right) to 0.5 (center) for a 6dB reduction in the middle. A problem inherent to linear panning is that the perceived volume of the signal drops in the middle. Pan2 solves this by taking the square root of the linear scaling factor going from 1 (left or right) to 0.5.sqrt (~=0.707) in the center, which is about 3dB reduction. This is equal power panning. LinPan2 sounds more like the Rhodes tremolo than Pan2.

func (LinPan2) Rate added in v0.1.4

func (l LinPan2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type LinXFade2 added in v0.1.4

type LinXFade2 struct {
	A     Input
	B     Input
	Pan   Input // Cross fade position from -1 to +1.
	Level Input
}

LinXFade2 is a two channel linear crossfader.

func (LinXFade2) Rate added in v0.1.4

func (x LinXFade2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Line

type Line struct {
	Start Input
	End   Input
	Dur   Input
	Done  int
}

Line generates a line from the start value to the end value

func (Line) Rate

func (line Line) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type LocalBuf added in v0.1.4

type LocalBuf struct {
	NumChannels Input
	NumFrames   Input
}

LocalBuf allocates a buffer local to a synth node.

func (LocalBuf) Rate added in v0.1.4

func (lb LocalBuf) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Median added in v0.1.4

type Median struct {
	In     Input
	Length Input
}

Median returns the median of the last length input points. This non-linear filter is good at reducing impulse noise from a signal.

func (Median) Rate added in v0.1.4

func (m Median) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type MouseX

type MouseX struct {
	// Min is the value of this ugen's output when the
	// mouse is at the left edge of the screen
	Min Input
	// Max is the value of this ugen's output when the
	// mouse is at the right edge of the screen
	Max Input
	// Warp is the mapping curve. 0 is linear, 1 is exponential
	Warp Input
	// Lag factor to dezipper cursor movements
	Lag Input
}

MouseX allpass delay with cubic interpolation

func (MouseX) Rate

func (m MouseX) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type MouseY

type MouseY struct {
	// Min is the value of this ugen's output when the
	// mouse is at the left edge of the screen
	Min Input
	// Max is the value of this ugen's output when the
	// mouse is at the right edge of the screen
	Max Input
	// Warp is the mapping curve. 0 is linear, 1 is exponential
	Warp Input
	// Lag factor to dezipper cursor movements
	Lag Input
}

MouseY allpass delay with cubic interpolation

func (MouseY) Rate

func (m MouseY) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type MultiInput

type MultiInput interface {
	Input
	InputArray() []Input
}

MultiInput is the interface of an input that causes cascading multi-channel expansion. See http://doc.sccode.org/Guides/Multichannel-Expansion.html

type Node

type Node interface {
	Free() error
	ID() int32
}

Node is a node in a synth execution tree. It could be a synth node or a group.

type NoiseInterpolation

type NoiseInterpolation int

NoiseInterpolation defines different types of interpolation for LFNoise ugens.

const (
	NoiseStep NoiseInterpolation = iota
	NoiseLinear
	NoiseQuadratic
)

Noise interpolation types.

type NumOutputBuses added in v0.1.4

type NumOutputBuses struct{}

NumOutputBuses provides the number of output buses in a synthdef.

func (NumOutputBuses) Rate added in v0.1.4

func (n NumOutputBuses) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is not IR this method will cause a runtime panic.

type OffsetOut added in v0.1.4

type OffsetOut struct {
	Bus      Input
	Channels Input
}

OffsetOut outputs a signal to a bus. Tthe sample offset within the bus is kept exactly; i.e. if the synth is scheduled to be started part way through a control cycle, OffsetOut will maintain the correct offset by buffering the output and delaying it until the exact time that the synth was scheduled for.

func (OffsetOut) Rate added in v0.1.4

func (out OffsetOut) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type OnePole added in v0.1.4

type OnePole struct {
	// In is the input signal.
	In Input

	// Coeff is the feedback coefficient. Should be between -1 and +1
	Coeff Input
}

OnePole is a one pole filter. Implements the formula:

out(i) = ((1 - abs(coef)) * in(i)) + (coef * out(i-1))

func (OnePole) Rate added in v0.1.4

func (o OnePole) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type OneZero added in v0.1.4

type OneZero struct {
	// In is the input signal.
	In Input

	// Coeff is the feed forward coefficient.
	// +0.5 makes a two point averaging filter (see also LPZ1 ).
	// -0.5 makes a differentiator (see also HPZ1 ).
	// +1 makes a single sample delay (see also Delay1 ).
	// -1 makes an inverted single sample delay.
	Coeff Input
}

OneZero is a one zero filter. Implements the formula:

out(i) = ((1 - abs(coef)) * in(i)) + (coef * in(i-1))

func (OneZero) Rate added in v0.1.4

func (o OneZero) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Osc added in v0.1.4

type Osc struct {
	BufNum Input
	Freq   Input
	Phase  Input
}

Osc is a Linear interpolating wavetable lookup oscillator with frequency and phase modulation inputs. This oscillator requires a buffer to be filled with a wavetable format signal. This preprocesses the Signal into a form which can be used efficiently by the Oscillator. The buffer size must be a power of 2. This can be achieved by creating a Buffer object and sending it one of the "b_gen" messages ( Buffer: -sine1, Buffer: -sine2, Buffer: -sine3 ) with the wavetable flag set to true. This can also be achieved by creating a Signal object and sending it the 'asWavetable' message, thereby creating a Wavetable object in the required format. Then, the wavetable data may be transmitted to the server using the Buffer: *sendCollection or Buffer: *loadCollection methods.

func (Osc) Rate added in v0.1.4

func (o Osc) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If BufNum is nil this method will panic.

type OscN added in v0.1.4

type OscN struct {
	BufNum Input
	Freq   Input
	Phase  Input
}

OscN is a noninterpolating wavetable lookup oscillator with frequency and phase modulation inputs. It is usually better to use the interpolating oscillator Osc.

func (OscN) Rate added in v0.1.4

func (o OscN) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If BufNum is nil this method will panic.

type Out

type Out struct {
	Bus      Input
	Channels Input
}

Out writes a signal to a bus.

func (Out) Rate

func (out Out) Rate(rate int8) Ugen

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Output

type Output int8

Output is a ugen output.

func (Output) Write

func (o Output) Write(w io.Writer) error

Write writes the output to an io.Writer.

type PMOsc

type PMOsc struct {
	// CarFreq is the carrier frequency in Hz.
	CarFreq Input
	// ModFreq is the modulator frequency in Hz.
	ModFreq Input
	// PMIndex in the modulation index in radians.
	PMIndex Input
	// ModPhase is a modulation input for the modulator's phase in radians.
	ModPhase Input
}

PMOsc is a phase modulation sine-wave oscillator pair.

func (PMOsc) Rate

func (pmosc PMOsc) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type PSinGrain added in v0.1.4

type PSinGrain struct {
	// Frequency in Hz.
	Freq Input

	// Grain duration in seconds.
	Dur Input

	// Grain amplitude.
	Amp Input
}

PSinGrain is a very fast sine grain with a parabolic envelope.

func (PSinGrain) Rate added in v0.1.4

func (p PSinGrain) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is a supported value this method will cause a runtime panic.

type PVBrickWall added in v0.1.4

type PVBrickWall struct {
	// FFT Buffer.
	Buffer Input

	// Can range between -1 and +1.
	// If wipe == 0 then there is no effect.
	// If wipe > 0 then it acts like a high pass filter, clearing bins from the bottom up.
	// If wipe < 0 then it acts like a low pass filter, clearing bins from the top down.
	Wipe Input
}

PVBrickWall clears bins above or below a cutoff point.

func (PVBrickWall) Rate added in v0.1.4

func (bw PVBrickWall) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If Buffer is nil this method will panic.

type Pairs

type Pairs [][2]float32

Pairs are pairs of floats: the first float is time, the second is level. They get sorted by time.

func (Pairs) Len

func (p Pairs) Len() int

func (Pairs) Less

func (p Pairs) Less(i, j int) bool

func (Pairs) Swap

func (p Pairs) Swap(i, j int)

type Pan2

type Pan2 struct {
	// In is the input signal.
	In Input

	// Pos is the pan position, -1 is hard left, +1 is hard right.
	Pos Input

	// Level is a control rate level input.
	Level Input
}

Pan2 is a two-channel equal power panner. It takes the square root of the linear scaling factor going from 1 (left or right) to 0.5.sqrt (~=0.707) in the center, which is about 3dB reduction. With linear panning (LinPan2) the signal is lowered as it approaches center using a straight line from 1 (left or right) to 0.5 (center) for a 6dB reduction in the middle. A problem inherent to linear panning is that the perceived volume of the signal drops in the middle. Pan2 solves this.

func (Pan2) Rate

func (pan Pan2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Pan4 added in v0.1.4

type Pan4 struct {
	// In is the input signal.
	In Input

	// XPos is the X pan position from -1 to +1 (left to right).
	XPos Input

	// YPos is the Y pan position from -1 to +1 (back to front).
	YPos Input

	// Level is a control rate level input.
	Level Input
}

Pan4 is a four channel equal power panner. Outputs are in order LeftFront, RightFront, LeftBack, RightBack.

func (Pan4) Rate added in v0.1.4

func (pan Pan4) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type PanAz added in v0.1.4

type PanAz struct {
	NumChans int

	// In is the input signal.
	In Input

	// Pos is the pan position.
	// Channels are evenly spaced over a cyclic period of 2.0
	// in pos with 0.0 equal to channel zero and 2.0/numChans equal to
	// channel 1, 4.0/numChans equal to channel 2, etc.
	Pos Input

	// Level is a control rate level input.
	Level Input

	// Width is the width of the panning envelope.
	// Nominally this is 2.0 which pans between pairs of adjacent speakers.
	// Width values greater than two will spread the pan over greater numbers of speakers.
	// Width values less than one will leave silent gaps between speakers.
	Width Input

	// Orientation should be zero if the front is a vertex of the polygon.
	// The first speaker will be directly in front.
	// Should be 0.5 if the front bisects a side of the polygon.
	// Then the first speaker will be the one left of center.
	Orientation Input
}

PanAz is a four channel equal power panner. Outputs are in order LeftFront, RightFront, LeftBack, RightBack.

func (PanAz) Rate added in v0.1.4

func (pan PanAz) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type PanB2 added in v0.1.4

type PanB2 struct {
	// In is the input signal.
	In Input

	// Azimuth is the position around the circle from -1 to +1. -1 is behind,
	// -0.5 is left, 0 is forward, +0.5 is right, +1 is behind.
	Azimuth Input

	// Gain controls the amplitude of the output signal.
	Gain Input
}

PanB2 encodes a mono signal to 2-dimensional ambisonic B-format.

func (PanB2) Rate added in v0.1.4

func (pan PanB2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type Param

type Param interface {
	// Name returns the name of the synthdef param
	Name() string
	// Index returns the index of the synthdef param
	Index() int32
	// InitialValue returns the initial value of the synthdef param
	InitialValue() float32
}

Param is the interface of a single synthdef parameter.

type ParamName

type ParamName struct {
	Name  string `json:"name,omitempty"`
	Index int32  `json:"index"`
}

ParamName represents a parameter name of a synthdef

func (*ParamName) Write

func (pn *ParamName) Write(w io.Writer) error

type Params

type Params interface {
	// Add adds a named parameter to a synthdef, with an initial value
	Add(name string, initialValue float32) Input
	// List returns a list of the params that have been added to a synthdef
	List() []Param
	// Control returns a Ugen that should be used as the first ugen
	// of any synthdef that has parameters
	Control() *Ugen
}

Params is an interface that allows you to add parameters to a synthdef.

type PinkNoise

type PinkNoise struct {
}

PinkNoise generates noise whose spectrum falls off in power by 3 dB per octave. This gives equal power over the span of each octave. This version gives 8 octaves of pink noise.

func (PinkNoise) Rate

func (pink PinkNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type PlayBuf

type PlayBuf struct {
	// NumChannels number of playback channels
	NumChannels int
	// BufNum buffer to use
	BufNum Input
	// Speed is the playback speed: 1.0 for original speed,
	// 2.0 for Chipmunks, 0.5 for DJ Screw
	Speed Input
	// Trigger when this input changes from negative to positive
	// playback will jump to the beginning of the buffer
	Trigger Input
	// Start is the sample frame to start playback
	Start Input
	// Loop 1 is on, 0 is off
	Loop Input
	// Done action to take when done playing buffer.
	// See http://doc.sccode.org/Reference/UGen-doneActions.html
	Done int
}

PlayBuf plays back a sample from memory. If Buf is nil a runtime panic will occur.

func (PlayBuf) Rate

func (playbuf PlayBuf) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. There will also be a runtime panic if BufNum is nil.

type Pulse

type Pulse struct {
	// Freq in Hz
	Freq Input
	// Width pulse width duty cycle from 0 to 1
	Width Input
}

Pulse band-limited pulse wave generator with pulse width modulation.

func (Pulse) Rate

func (pulse Pulse) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type PulseCount added in v0.1.4

type PulseCount struct {
	// Trig is the trigger signal.
	// A trigger happens when the signal changes from non-positive to positive.
	Trig Input

	// Reset resets the counter to zero when triggered.
	Reset Input
}

PulseCount counts pulses. Each trigger increments a counter which is output as a signal.

func (PulseCount) Rate added in v0.1.4

func (pc PulseCount) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type PulseDivider added in v0.1.4

type PulseDivider struct {
	// Trig can be any signal.
	// A trigger happens when the signal changes from non-positive to positive.
	Trig Input

	// Div is the number of triggers to count before outputting an impulse.
	Div Input

	// Start is the starting value for the trigger count.
	// This lets you start somewhere in the middle of a count.
	// If start is negative it adds that many counts to the first time the output is triggered.
	Start Input
}

PulseDivider outputs one impulse each time it receives a certain number of triggers at its input.

func (PulseDivider) Rate added in v0.1.4

func (pd PulseDivider) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type RLPF

type RLPF struct {
	// In is the input signal
	In Input
	// Freq cutoff in Hz
	Freq Input
	// RQ Reciprocal of Q
	RQ Input
}

RLPF a resonant low pass filter

func (RLPF) Rate

func (rlpf RLPF) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Rand added in v0.1.3

type Rand struct {
	Lo, Hi Input
}

Rand generates a single random float value in uniform distribution from Lo to Hi. It generates this when the SynthDef first starts playing, and remains fixed for the duration of the synth's existence.

func (Rand) Rate added in v0.1.3

func (rand Rand) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Rater added in v0.1.4

type Rater interface {
	Rate(int8) Input
}

Rater is the interface of a Ugen that can compute its output at different rates.

type Resonz added in v0.1.4

type Resonz struct {
	// In is the input signal.
	In Input

	// Freq is the resonant frequency in Hertz.
	// WARNING: due to the nature of its implementation frequency
	// values close to 0 may cause glitches and/or extremely loud audio artifacts!
	Freq Input

	// BWR is the bandwidth ratio (reciprocal of Q). rq = bandwidth / centerFreq.
	// The reciprocal of Q is used rather than Q because it saves a divide operation
	// inside the unit generator.
	BWR Input
}

Resonz is the same as Ringz, except that it has a constant gain at 0 dB instead of being constant skirt. It is a two pole resonant filter with zeroes at z = +-1.

func (Resonz) Rate added in v0.1.4

func (r Resonz) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Ringz added in v0.1.4

type Ringz struct {
	// In is the input signal.
	In Input

	// Freq is the resonant frequency in Hertz.
	// WARNING: due to the nature of its implementation frequency
	// values close to 0 may cause glitches and/or extremely loud audio artifacts!
	Freq Input

	// DecayTime is the 60 dB decay time of the filter.
	DecayTime Input
}

Ringz is the same as Resonz, except that it is a constant skirt gain filter, meaning that the peak gain depends on the value of Q. Also, instead of the resonance parameter in Resonz, the bandwidth is specified in a 60dB ring decay time. One Ringz is equivalent to one component of the Klank UGen.

func (Ringz) Rate added in v0.1.4

func (r Ringz) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Rotate2 added in v0.1.4

type Rotate2 struct {
	// X and Y are the input signals.
	X, Y Input

	// Pos is the angle to rotate around the circle from -1 to +1.
	// -1 is 180 degrees, -0.5 is left, 0 is forward, +0.5 is right, +1 is behind.
	Pos Input
}

Rotate2 can be used for rotating an ambisonic B-format sound field around an axis. Rotate2 does an equal power rotation so it also works well on stereo sounds. It takes two audio inputs (x, y) and an angle control (pos). It outputs two channels (x, y). It computes this:

xout = cos(angle) * xin + sin(angle) * yin;
yout = cos(angle) * yin - sin(angle) * xin;

where angle = pos * pi, so that -1 becomes -pi and +1 becomes +pi. This allows you to use an LFSaw to do continuous rotation around a circle.

func (Rotate2) Rate added in v0.1.4

func (r Rotate2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If X or Y is nil this method will panic. TODO: we have to be able to access individual outputs of a ugen to be able to implement the Rotate2 example from the SuperCollider help files.

type RunningSum added in v0.1.4

type RunningSum struct {
	In      Input
	NumSamp Input
}

RunningSum is a running sum over a user specified number of samples, useful for running RMS power windowing.

func (RunningSum) Rate added in v0.1.4

func (r RunningSum) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If the input signal is nil this method will panic.

type SampleDur added in v0.1.4

type SampleDur struct{}

SampleDur returns the current sample duration of the server. Equivalent to 1/SampleRate.

func (SampleDur) Rate added in v0.1.4

func (s SampleDur) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is not IR this method will cause a runtime panic.

type SampleRate added in v0.1.4

type SampleRate struct{}

SampleRate returns the current sample rate of the server.

func (SampleRate) Rate added in v0.1.4

func (s SampleRate) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is not IR this method will cause a runtime panic.

type Saw

type Saw struct {
	Freq Input
}

Saw is a band-limited sawtooth wave generator.

func (Saw) Rate

func (saw Saw) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Select

type Select struct {
	Which  Input
	Inputs []Input
}

Select selects an output from an array of inputs.

func (Select) Rate

func (sel Select) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Server

type Server struct {
	*exec.Cmd

	Network      string
	Port         int
	StartTimeout time.Duration
}

Server represents a running instance of scsynth.

func (*Server) Start

func (s *Server) Start(timeout time.Duration) (io.ReadCloser, io.ReadCloser, error)

Start starts a new instance of scsynth. If the server doesn't print a line containing ServerReadyMessage within the timeout then ErrTimeout is returned.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops a running server.

type ServerStatus

type ServerStatus struct {
	NumUgens          int32   `json:"numUgens"`
	NumSynths         int32   `json:"numSynths"`
	NumGroups         int32   `json:"numGroups"`
	NumSynthdefs      int32   `json:"numSynthdefs"`
	AvgCPU            float32 `json:"avgCPU"`
	PeakCPU           float32 `json:"peakCPU"`
	NominalSampleRate float32 `json:"nominalSampleRate"`
	ActualSampleRate  float32 `json:"actualSampleRate"`
}

ServerStatus represents the reply to the /status command.

type Shaper added in v0.1.4

type Shaper struct {
	// BufNum is the number of a buffer filled in wavetable format
	// containing the transfer function.
	BufNum Input

	// In is the input signal.
	In Input
}

Shaper performs waveshaping on the input signal by indexing into the table.

func (Shaper) Rate added in v0.1.4

func (s Shaper) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If BufNum is nil this method will panic.

type Silent added in v0.1.4

type Silent struct {
	// Number of channels to output. Defaults to 1 if not set.
	NumChannels int
}

Silent outputs silence.

func (Silent) Rate added in v0.1.4

func (s Silent) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type SinOsc

type SinOsc struct {
	// Freq is frequency in Hz
	Freq Input
	// Phase is the initial phase offset
	Phase Input
}

SinOsc is a table-lookup sinewave oscillator

func (SinOsc) Rate

func (sin SinOsc) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type SinOscFB added in v0.1.4

type SinOscFB struct {
	Freq     Input
	Feedback Input
}

SinOscFB is a sine oscillator that has phase modulation feedback: its output plugs back into the phase input. This allows a modulation between a sine wave and a sawtooth like wave. Overmodulation causes chaotic oscillation. It may be useful if you want to simulate feedback FM synths.

func (SinOscFB) Rate added in v0.1.4

func (s SinOscFB) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Slew added in v0.1.4

type Slew struct {
	// In is the input signal
	In Input

	// Up is the maximum upward slope in units per second.
	Up Input

	// Dn is the maximum downward slope in units per second.
	Dn Input
}

Slew limits the slope of an input signal. The slope is expressed in units per second. For smoothing out control signals, take a look at Lag and VarLag.

func (Slew) Rate added in v0.1.4

func (s Slew) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Slope added in v0.1.4

type Slope struct {
	// Input signal.
	In Input
}

Slope measures the rate of change per second of a signal. The formula implemented is:

out[i] = (in[i] - in[i-1]) * sampling_rate

func (Slope) Rate added in v0.1.4

func (s Slope) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type SoundIn added in v0.1.4

type SoundIn struct {
	Bus Input
}

SoundIn is a convenience UGen to read audio from the input of your computer or soundcard. It is a wrapper UGen based on In, which offsets the index such that 0 will always correspond to the first input regardless of the number of inputs present.

func (SoundIn) Rate added in v0.1.4

func (s SoundIn) Rate(rate int8) Input

Rate returns an Input at the specified rate. This method panics if rate is not a supported value.

type Spring added in v0.1.4

type Spring struct {
	// Modulated input force.
	In Input

	// Spring constant (incl. mass)
	Spring Input

	// Damping.
	Damp Input
}

Spring models the force of a resonating spring.

func (Spring) Rate added in v0.1.4

func (b Spring) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Sweep added in v0.1.4

type Sweep struct {
	// Trig triggers when trig input crosses from non-positive to positive.
	Trig Input

	// RaiseRate is the rate/sec raise rate.
	RaiseRate Input
}

Sweep starts a linear raise by rate/sec from zero when trig input crosses from non-positive to positive. When rate == 1, Sweep may be used to get a continually-updating measurement of the time (in seconds) since the last trigger.

func (Sweep) Rate added in v0.1.4

func (sweep Sweep) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type SyncSaw added in v0.1.4

type SyncSaw struct {
	// SyncFreq is the frequency of the fundamental.
	SyncFreq Input

	// SawFreq is the frequency of the slave synched sawtooth wave.
	// It should always be greater than SyncFreq.
	SawFreq Input
}

SyncSaw is a sawtooth wave that is hard synched to a fundamental pitch. This produces an effect similar to moving formants or pulse width modulation. The sawtooth oscillator has its phase reset when the sync oscillator completes a cycle. This is not a band limited waveform, so it may alias.

func (SyncSaw) Rate added in v0.1.4

func (s SyncSaw) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Synth

type Synth struct {
	Controls []SynthControl `json:"control"`
	DefName  string         `json:"defName"`
	ID       int32          `json:"id"`
	// contains filtered or unexported fields
}

Synth encapsulates a synth node.

func PlayDef

func PlayDef(def *Synthdef) (*Synth, error)

PlayDef plays a synthdef by sending the synthdef using DefaultClient, then immediately creating a synth node from the def.

func (*Synth) Get

func (s *Synth) Get(controlName string) (float32, error)

Get the value of a synth control.

func (*Synth) Set

func (s *Synth) Set(ctls map[string]float32) error

Set the value of a synth control.

type SynthArgs added in v0.1.3

type SynthArgs struct {
	DefName string
	ID      int32
	Action  int32
	Target  int32
	Ctls    map[string]float32
}

SynthArgs contains the arguments necessary to create a synth that is part of a group.

type SynthControl added in v0.1.4

type SynthControl struct {
	Name  string
	Value float32
}

SynthControl represents a synth control in a group query.

type SynthNode added in v0.1.4

type SynthNode struct {
	Controls map[string]string
	DefName  string
	// contains filtered or unexported fields
}

SynthNode is a node in a graph

func (*SynthNode) Free added in v0.1.4

func (g *SynthNode) Free() error

Free frees the node.

func (*SynthNode) ID added in v0.1.4

func (g *SynthNode) ID() int32

ID returns the node ID.

type Synthdef

type Synthdef struct {
	// Name is the name of the synthdef
	Name string `json:"name" xml:"Name,attr"`

	// Constants is a list of constants that appear in the synth def
	Constants []float32 `json:"constants,omitempty" xml:"Constants>Constant"`

	// InitialParamValues is an array of initial values for synth params
	InitialParamValues []float32 `json:"initialParamValues,omitempty" xml:"InitialParamValues>initialParamValue"`

	// ParamNames contains the names of the synth parameters
	ParamNames []ParamName `json:"paramNames,omitempty" xml:"ParamNames>ParamName"`

	// Ugens is the list of ugens that appear in the synth def.
	// The root of the ugen graph will always be last.
	Ugens []*Ugen `json:"ugens,omitempty" xml:"Ugens>Ugen"`

	// Variants is the list of variants contained in the synth def
	Variants []*Variant `json:"variants,omitempty" xml:"Variants>Variant"`
	// contains filtered or unexported fields
}

Synthdef defines the structure of synthdef data as defined in http://doc.sccode.org/Reference/Synth-Definition-File-Format.html

func NewSynthdef

func NewSynthdef(name string, graphFunc UgenFunc) *Synthdef

NewSynthdef creates a synthdef by traversing a ugen graph

Example
_ = NewSynthdef("SineTone", func(p Params) Ugen {
	var (
		bus = C(0)
		sig = SinOsc{}.Rate(AR)
	)
	return Out{Bus: bus, Channels: sig}.Rate(AR)
}).WriteJSON(os.Stdout)
Output:

{"name":"SineTone","constants":[440,0],"ugens":[{"name":"SinOsc","rate":2,"specialIndex":0,"inputs":[{"ugenIndex":-1,"outputIndex":0},{"ugenIndex":-1,"outputIndex":1}],"outputs":[2]},{"name":"Out","rate":2,"specialIndex":0,"inputs":[{"ugenIndex":-1,"outputIndex":1},{"ugenIndex":0,"outputIndex":0}]}]}

func ReadSynthdef

func ReadSynthdef(r io.Reader) (*Synthdef, error)

ReadSynthdef reads a synthdef from an io.Reader

func (*Synthdef) Bytes

func (def *Synthdef) Bytes() ([]byte, error)

Bytes writes a synthdef to a byte array

func (*Synthdef) CompareToDef

func (def *Synthdef) CompareToDef(other *Synthdef) (bool, error)

CompareToDef compare this synthdef to another.

func (*Synthdef) CompareToFile

func (def *Synthdef) CompareToFile(path string) (bool, error)

CompareToFile compares this synthdef to another one stored on disk.

func (*Synthdef) Diff added in v0.1.4

func (def *Synthdef) Diff(other *Synthdef) [][2]string

Diff returns a diff of one synthdef and another. A diff is represented as a slice of pairs of strings. The first string in each pair describes the synthdef on the left (the receiver), and the second string describes the other synthdef.

func (*Synthdef) Root added in v0.1.4

func (def *Synthdef) Root() int32

Root returns the root node in the synthdef's ugen graph.

func (*Synthdef) Write

func (def *Synthdef) Write(w io.Writer) error

Write writes a binary representation of a synthdef to an io.Writer. The binary representation written by this method is the data that scsynth expects at its /d_recv endpoint.

func (*Synthdef) WriteJSON

func (def *Synthdef) WriteJSON(w io.Writer) error

WriteJSON writes a json-formatted representation of a synthdef to an io.Writer.

func (*Synthdef) WriteXML

func (def *Synthdef) WriteXML(w io.Writer) error

WriteXML writes an xml-formatted representation of a synthdef to an io.Writer.

type TDelay added in v0.1.4

type TDelay struct {
	// In is the input trigger signal.
	In Input

	// Dur is the delay time in seconds.
	Dur Input
}

TDelay delays a trigger by a given time. Any triggers which arrive in the time between an input trigger and its delayed output, are ignored.

func (TDelay) Rate added in v0.1.4

func (t TDelay) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type TGrains added in v0.1.4

type TGrains struct {
	// Number of output channels.
	NumChannels int
	// At each trigger, the following arguments are sampled and used as the arguments of a new grain.
	// A trigger occurs when a signal changes from non-positive to positive value.
	// If the trigger is audio rate then the grains will start with sample accuracy.
	Trigger Input
	// The index of the buffer to use. It must be a one channel (mono) buffer.
	BufNum Input
	// 1.0 is normal, 2.0 is one octave up, 0.5 is one octave down -1.0 is backwards normal rate… etc.
	// (renamed to GRate, to avoid conflicts with Rate method)
	GRate Input
	// The position in the buffer in seconds at which the grain envelope will reach maximum amplitude.
	CenterPos Input
	// Duration of the grain in seconds.
	Dur Input
	// Determines where to pan the output.
	// If numChannels = 1, the pan argument is ignored.
	// If numChannels = 2, panning is similar to Pan2.
	// If numChannels > 2, panning is the same as PanAz.
	Pan Input
	// Amplitude of the grain.
	Amp Input
	// 1, 2, or 4. Determines whether the grain uses (1) no interpolation, (2) linear interpolation, or (4) cubic interpolation.
	Interp Input
}

TGrains is a buffer granulator

func (TGrains) Rate added in v0.1.4

func (tg TGrains) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type TLC

type TLC struct {
	Time, Level float32
	Curve       interface{}
}

TLC (time, level, curve) triplet

type TRand added in v0.1.4

type TRand struct {
	Lo   Input
	Hi   Input
	Trig Input
}

TRand generates a random float value in uniform distribution from Lo to Hi each time Trig changes from nonpositive to positive values.

func (TRand) Rate added in v0.1.4

func (t TRand) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type ToggleFF added in v0.1.4

type ToggleFF struct {
	Trig Input
}

ToggleFF toggles between 0 and 1 upon receiving a trigger.

func (ToggleFF) Rate added in v0.1.4

func (t ToggleFF) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Trig added in v0.1.4

type Trig struct {
	// In is the input trigger signal.
	// A trigger happens when the signal changes from non-positive to positive.
	In Input

	// Dur is the duration of the trigger output.
	Dur Input
}

Trig outputs the level of the triggering input for the specified duration when a nonpositive to positive transition occurs at the input. Otherwise it outputs zero.

func (Trig) Rate added in v0.1.4

func (t Trig) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Trig1 added in v0.1.4

type Trig1 struct {
	// In is the input trigger signal.
	// A trigger happens when the signal changes from non-positive to positive.
	In Input

	// Dur is the duration of the trigger output.
	Dur Input
}

Trig1 outputs 1 for the specified duration when a nonpositive to positive transition occurs at the trigger input. Otherwise it outputs zero.

func (Trig1) Rate added in v0.1.4

func (t Trig1) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Ugen

type Ugen struct {
	Name         string      `json:"name"              xml:"name,attr"`
	Rate         int8        `json:"rate"              xml:"rate,attr"`
	SpecialIndex int16       `json:"specialIndex"      xml:"specialIndex,attr"`
	Inputs       []UgenInput `json:"inputs,omitempty"  xml:"Inputs>Input"`
	Outputs      []Output    `json:"outputs,omitempty" xml:"Outputs>Output"`
	NumOutputs   int         `json:"numOutputs"        xml:"numOutputs,attr"`
	// contains filtered or unexported fields
}

Ugen is a unit generator.

func NewControl

func NewControl(numOutputs int) *Ugen

NewControl creates a new Control.

func NewUgen added in v0.1.4

func NewUgen(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) *Ugen

NewUgen is a factory function for creating new Ugen instances. Panics if rate is not AR, KR, or IR. Panics if numOutputs <= 0.

func (*Ugen) Abs added in v0.1.4

func (u *Ugen) Abs() Input

Abs computes the absolute value of a signal.

func (*Ugen) Absdif added in v0.1.4

func (u *Ugen) Absdif(val Input) Input

Absdif returns the absolute value of the difference of two inputs.

func (*Ugen) Acos added in v0.1.4

func (u *Ugen) Acos() Input

Acos computes the arccosine of a signal.

func (*Ugen) Add added in v0.1.4

func (u *Ugen) Add(val Input) Input

Add adds an input to a ugen node.

func (*Ugen) Amclip added in v0.1.4

func (u *Ugen) Amclip(val Input) Input

Amclip returns 0 when b <= 0, a*b when b > 0.

func (*Ugen) AmpDb added in v0.1.4

func (u *Ugen) AmpDb() Input

AmpDb converts linear amplitude to decibels.

func (*Ugen) Asin added in v0.1.4

func (u *Ugen) Asin() Input

Asin computes the arcsine of a signal.

func (*Ugen) Atan added in v0.1.4

func (u *Ugen) Atan() Input

Atan computes the arctangent of a signal.

func (*Ugen) Atan2 added in v0.1.4

func (u *Ugen) Atan2(val Input) Input

Atan2 returns the arctangent of y/x.

func (*Ugen) Bilinrand added in v0.1.4

func (u *Ugen) Bilinrand() Input

Bilinrand returns a linearly distributed random value between [+in ... -in].

func (*Ugen) Ceil added in v0.1.4

func (u *Ugen) Ceil() Input

Ceil computes the ceiling (next highest integer) of a signal.

func (*Ugen) Clip2 added in v0.1.4

func (u *Ugen) Clip2(val Input) Input

Clip2 clips input wave a to +/- b

func (*Ugen) Coin added in v0.1.4

func (u *Ugen) Coin() Input

Coin returns one or zero with the probability given by the input.

func (*Ugen) Cos added in v0.1.4

func (u *Ugen) Cos() Input

Cos returns the cosine of a ugen.

func (*Ugen) Cosh added in v0.1.4

func (u *Ugen) Cosh() Input

Cosh returns the hyperbolic cosine of a ugen.

func (*Ugen) Cpsmidi added in v0.1.4

func (u *Ugen) Cpsmidi() Input

Cpsmidi converts frequency in Hz to midi note values.

func (*Ugen) Cpsoct added in v0.1.4

func (u *Ugen) Cpsoct() Input

Cpsoct converts cycles per second to decimal octaves.

func (*Ugen) Cubed added in v0.1.4

func (u *Ugen) Cubed() Input

Cubed computes the cube of a signal.

func (*Ugen) DbAmp added in v0.1.4

func (u *Ugen) DbAmp() Input

DbAmp converts linear amplitude to decibels.

func (*Ugen) Difsqr added in v0.1.4

func (u *Ugen) Difsqr(val Input) Input

Difsqr returns the value of (a*a) - (b*b).

func (*Ugen) Distort added in v0.1.4

func (u *Ugen) Distort() Input

Distort performs non-linear distortion on a signal.

func (*Ugen) Div added in v0.1.4

func (u *Ugen) Div(val Input) Input

Div divides one input by another.

func (*Ugen) Excess added in v0.1.4

func (u *Ugen) Excess(val Input) Input

Excess returns the difference of the original signal and its clipped form: (a - clip2(a,b)).

func (*Ugen) Exp added in v0.1.4

func (u *Ugen) Exp() Input

Exp computes the exponential of a signal.

func (*Ugen) Expon added in v0.1.4

func (u *Ugen) Expon(val Input) Input

Expon raises this input to the power of another.

func (*Ugen) Floor added in v0.1.4

func (u *Ugen) Floor() Input

Floor computes the floor (next lowest integer) of a signal.

func (*Ugen) Fold2 added in v0.1.4

func (u *Ugen) Fold2(val Input) Input

Fold2 folds input wave a to +/- b

func (*Ugen) Frac added in v0.1.4

func (u *Ugen) Frac() Input

Frac computes the fractional part of a signal.

func (*Ugen) GCD added in v0.1.4

func (u *Ugen) GCD(val Input) Input

GCD computes the gcd of one Input and another.

func (*Ugen) GT added in v0.1.4

func (u *Ugen) GT(val Input) Input

GT computes x > y.

func (*Ugen) GTE added in v0.1.4

func (u *Ugen) GTE(val Input) Input

GTE computes x >= y.

func (*Ugen) Hypot added in v0.1.4

func (u *Ugen) Hypot(val Input) Input

Hypot returns the square root of the sum of the squares of a and b. Or equivalently, the distance from the origin to the point (x, y).

func (*Ugen) HypotApx added in v0.1.4

func (u *Ugen) HypotApx(val Input) Input

HypotApx returns an approximation of the square root of the sum of the squares of x and y.

func (*Ugen) LCM added in v0.1.4

func (u *Ugen) LCM(val Input) Input

LCM computes the lcm of one Input and another.

func (*Ugen) LT added in v0.1.4

func (u *Ugen) LT(val Input) Input

LT computes x < y.

func (*Ugen) LTE added in v0.1.4

func (u *Ugen) LTE(val Input) Input

LTE computes x <= y.

func (*Ugen) Linrand added in v0.1.4

func (u *Ugen) Linrand() Input

Linrand returns a linearly distributed random value between in and zero.

func (*Ugen) Log added in v0.1.4

func (u *Ugen) Log() Input

Log computes a natural logarithm.

func (*Ugen) Log10 added in v0.1.4

func (u *Ugen) Log10() Input

Log10 computes a base 10 logarithm.

func (*Ugen) Log2 added in v0.1.4

func (u *Ugen) Log2() Input

Log2 computes a base 2 logarithm.

func (*Ugen) Max added in v0.1.4

func (u *Ugen) Max(other Input) Input

Max computes the maximum of one Input and another.

func (*Ugen) Midicps added in v0.1.4

func (u *Ugen) Midicps() Input

Midicps converts MIDI note number to cycles per second.

func (*Ugen) Midiratio added in v0.1.4

func (u *Ugen) Midiratio() Input

Midiratio converts an interval in MIDI notes into a frequency ratio.

func (*Ugen) Min added in v0.1.4

func (u *Ugen) Min(other Input) Input

Min returns the minimum of one signal and another.

func (*Ugen) Moddif added in v0.1.4

func (u *Ugen) Moddif(y, mod Input) Input

Moddif returns the smaller of the great circle distances between the two points.

func (*Ugen) Modulo added in v0.1.4

func (u *Ugen) Modulo(val Input) Input

Modulo computes the modulo of one signal and another.

func (*Ugen) Mul added in v0.1.4

func (u *Ugen) Mul(val Input) Input

Mul multiplies the ugen node by an input.

func (*Ugen) MulAdd added in v0.1.4

func (u *Ugen) MulAdd(mul, add Input) Input

MulAdd multiplies and adds inputs to a ugen node.

func (*Ugen) Neg added in v0.1.4

func (u *Ugen) Neg() Input

Neg is a convenience operator that multiplies a signal by -1.

func (*Ugen) Octcps added in v0.1.4

func (u *Ugen) Octcps() Input

Octcps converts decimal octaves to cycles per second.

func (*Ugen) Pow added in v0.1.4

func (u *Ugen) Pow(val Input) Input

Pow raises this input to the power of another.

func (*Ugen) Rand added in v0.1.4

func (u *Ugen) Rand() Input

Rand returns an evenly distributed random value between this and zero.

func (*Ugen) Rand2 added in v0.1.4

func (u *Ugen) Rand2() Input

Rand2 returns an evenly distributed random value between [+this ... - this].

func (*Ugen) Ratiomidi added in v0.1.4

func (u *Ugen) Ratiomidi() Input

Ratiomidi converts a frequency ratio to an interval in MIDI notes.

func (*Ugen) Reciprocal added in v0.1.4

func (u *Ugen) Reciprocal() Input

Reciprocal computes the reciprocal of a signal.

func (*Ugen) Ring1 added in v0.1.4

func (u *Ugen) Ring1(val Input) Input

Ring1 is ring modulation plus first source.

func (*Ugen) Ring2 added in v0.1.4

func (u *Ugen) Ring2(val Input) Input

Ring2 is ring modulation plus both sources.

func (*Ugen) Ring3 added in v0.1.4

func (u *Ugen) Ring3(val Input) Input

Ring3 returns the value of (a*a *b)

func (*Ugen) Ring4 added in v0.1.4

func (u *Ugen) Ring4(val Input) Input

Ring4 returns the value of ((a*a *b) - (a*b*b)).

func (*Ugen) Round added in v0.1.4

func (u *Ugen) Round(val Input) Input

Round performs quantization by rounding. Rounds a to the nearest multiple of b.

func (*Ugen) Scaleneg added in v0.1.4

func (u *Ugen) Scaleneg(val Input) Input

Scaleneg returns a*b when a < 0, otherwise a.

func (*Ugen) Sign added in v0.1.4

func (u *Ugen) Sign() Input

Sign computes the sign of a signal.

func (*Ugen) Sin added in v0.1.4

func (u *Ugen) Sin() Input

Sin returns the sine of a ugen.

func (*Ugen) Sinh added in v0.1.4

func (u *Ugen) Sinh() Input

Sinh returns the hyperbolic sine of a ugen.

func (*Ugen) SoftClip added in v0.1.4

func (u *Ugen) SoftClip() Input

SoftClip adds distortion to a ugen.

func (*Ugen) Sqrdif added in v0.1.4

func (u *Ugen) Sqrdif(val Input) Input

Sqrdif computes the square of the difference between the two inputs.

func (*Ugen) Sqrsum added in v0.1.4

func (u *Ugen) Sqrsum(val Input) Input

Sqrsum computes the square of the sum of the two inputs.

func (*Ugen) Sqrt added in v0.1.4

func (u *Ugen) Sqrt() Input

Sqrt computes the square root of a signal.

func (*Ugen) Squared added in v0.1.4

func (u *Ugen) Squared() Input

Squared computes the square of a signal.

func (*Ugen) Sum3rand added in v0.1.4

func (u *Ugen) Sum3rand() Input

Sum3rand returns a value from a gaussian-like random distribution between in and zero.

func (*Ugen) Sumsqr added in v0.1.4

func (u *Ugen) Sumsqr(val Input) Input

Sumsqr returns the value of (a*a) + (b*b).

func (*Ugen) Tan added in v0.1.4

func (u *Ugen) Tan() Input

Tan returns the tangent of a ugen.

func (*Ugen) Tanh added in v0.1.4

func (u *Ugen) Tanh() Input

Tanh returns the hyperbolic tangent of a ugen.

func (*Ugen) Thresh added in v0.1.4

func (u *Ugen) Thresh(val Input) Input

Thresh returns 0 when a < b, otherwise a.

func (*Ugen) Trunc added in v0.1.4

func (u *Ugen) Trunc(val Input) Input

Trunc performs quantization by truncation. Truncate a to a multiple of b.

func (*Ugen) Wrap2 added in v0.1.4

func (u *Ugen) Wrap2(val Input) Input

Wrap2 wraps input wave to +/-b

func (*Ugen) Write added in v0.1.4

func (u *Ugen) Write(w io.Writer) error

Write writes a Ugen

type UgenFunc

type UgenFunc func(p Params) Ugen

UgenFunc is a func that is used to define a ugen graph.

type UgenInput

type UgenInput struct {
	UgenIndex   int32 `json:"ugenIndex"   xml:"ugenIndex,attr"`
	OutputIndex int32 `json:"outputIndex" xml:"outputIndex,attr"`
}

UgenInput defines a ugen input as it appears in the synthdef file format.

func (UgenInput) IsConstant added in v0.1.4

func (ui UgenInput) IsConstant() bool

IsConstant returns true if a UgenInput has a UgenIndex of -1

func (UgenInput) Write added in v0.1.4

func (ui UgenInput) Write(w io.Writer) error

Write writes an input to an io.Writer

type VOsc added in v0.1.4

type VOsc struct {
	// Buffer index. Can be swept continuously among adjacent wavetable buffers of the same size.
	BufNum Input

	// Frequency in Hz.
	Freq Input

	// Phase (0..1)
	Phase Input
}

VOsc is a wavetable lookup oscillator which can be swept smoothly across wavetables. All the wavetables must be allocated to the same size. Fractional values of table will interpolate between two adjacent tables. This oscillator requires at least two buffers to be filled with a wavetable format signal. This preprocesses the Signal into a form which can be used efficiently by the Oscillator. The buffer size must be a power of 2. This can be achieved by creating a Buffer object and sending it one of the "b_gen" messages ( sine1, sine2, sine3 ) with the wavetable flag set to true. This can also be achieved by creating a Signal object and sending it the asWavetable message, saving it to disk, and having the server load it from there. If you use Buffer objects to manage buffer numbers, you can use the [*allocConsecutive] method to allocate a continuous block of buffers. See the Buffer helpfile for details.

func (VOsc) Rate added in v0.1.4

func (o VOsc) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If BufNum is nil this method will panic.

type VOsc3 added in v0.1.4

type VOsc3 struct {
	// Buffer index. Can be swept continuously among adjacent wavetable buffers of the same size.
	BufNum Input

	// Frequency in Hz of oscillator 1.
	Freq1 Input

	// Frequency in Hz of oscillator 2.
	Freq2 Input

	// Frequency in Hz of oscillator 3.
	Freq3 Input
}

VOsc3 is a wavetable lookup oscillator which can be swept smoothly across wavetables. All the wavetables must be allocated to the same size. Fractional values of table will interpolate between two adjacent tables. This unit generator contains three oscillators at different frequencies, mixed together. This oscillator requires at least two buffers to be filled with a wavetable format signal. This preprocesses the Signal into a form which can be used efficiently by the Oscillator. The buffer size must be a power of 2. This can be achieved by creating a Buffer object and sending it one of the "b_gen" messages ( sine1, sine2, sine3 ) with the wavetable flag set to true. This can also be achieved by creating a Signal object and sending it the asWavetable message, saving it to disk, and having the server load it from there. If you use Buffer objects to manage buffer numbers, you can use the [*allocConsecutive] method to allocate a continuous block of buffers. See the Buffer helpfile for details.

func (VOsc3) Rate added in v0.1.4

func (o VOsc3) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic. If BufNum is nil this method will panic.

type VarSaw added in v0.1.4

type VarSaw struct {
	// Freq is the oscillator's frequency in Hz.
	Freq Input

	// IPhase is the oscillator's initial phase in cycles (0..1).
	IPhase Input

	// Width is the duty cycle from 0 to 1.
	Width Input
}

VarSaw is a sawtooth-triangle oscillator with variable duty.

func (VarSaw) Rate added in v0.1.4

func (vs VarSaw) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Variant

type Variant struct {
	Name               string    `json:"name,omitempty"`
	InitialParamValues []float32 `json:"initialParamValues"`
}

Variant provides a way to create synthdef presets.

func (*Variant) Write

func (variant *Variant) Write(w io.Writer) error

Write writes a variant to an io.Writer.

type Vibrato added in v0.1.4

type Vibrato struct {
	Freq           Input
	Speed          Input
	Depth          Input
	Delay          Input
	Onset          Input
	RateVariation  Input
	DepthVariation Input
	IPhase         Input
}

Vibrato is a slow frequency modulation. Consider the systematic deviation in pitch of a singer around a fundamental frequency, or a violinist whose finger wobbles in position on the fingerboard, slightly tightening and loosening the string to add shimmer to the pitch. There is often also a delay before vibrato is established on a note. This UGen models these processes; by setting more extreme settings, you can get back to the timbres of FM synthesis. You can also add in some noise to the vibrato rate and vibrato size (modulation depth) to make for a more realistic motor pattern. The vibrato output is a waveform based on a squared envelope shape with four stages marking out 0.0 to 1.0, 1.0 to 0.0, 0.0 to -1.0, and -1.0 back to 0.0. Vibrato rate determines how quickly you move through these stages.

func (Vibrato) Rate added in v0.1.4

func (v Vibrato) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type Warp1 added in v0.1.4

type Warp1 struct {
	// Number of output channels.
	NumChannels int
	// The index of the buffer to use. It must be a one channel (mono) buffer.
	BufNum Input
	// The position in the buffer. The value should be between 0 and 1, with 0 being the beginning of the buffer, and 1 the end.
	Pointer Input
	// The amount of frequency shift. 1.0 is normal, 0.5 is one octave down, 2.0 is one octave up. Negative values play the soundfile backwards.
	FreqScale Input
	// The size of each grain window.
	WindowSize Input
	// The buffer number containing a signal to use for the grain envelope. -1 uses a built-in Hanning envelope.
	EnvBufNum Input
	// The number of overlapping windows.
	Overlaps Input
	// The amount of randomness to the windowing function. Must be between 0 (no randomness) to 1.0 (probably too random actually)
	WindowRandRatio Input
	// The interpolation method used for pitchshifting grains. 1 = no interpolation. 2 = linear. 4 = cubic interpolation (more computationally intensive).
	Interp Input
}

Warp1 is a granular time stretcher and pitchshifter. Inspired by Chad Kirby's SuperCollider2 Warp1 class, which was inspired by Richard Karpen's sndwarp for CSound.

func (Warp1) Rate added in v0.1.4

func (wrp Warp1) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type WhiteNoise

type WhiteNoise struct {
}

WhiteNoise generates noise whose spectrum has equal power at all frequencies.

func (WhiteNoise) Rate

func (white WhiteNoise) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type XFade2 added in v0.1.4

type XFade2 struct {
	A     Input
	B     Input
	Pan   Input
	Level Input
}

XFade2 is a two channel equal power crossfader.

func (XFade2) Rate added in v0.1.4

func (x XFade2) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

type XLine

type XLine struct {
	Start Input
	End   Input
	Dur   Input
	Done  int
}

XLine generates an exponential curve from the start value to the end value. Both the start and end values must be non-zero and have the same sign.

func (XLine) Rate

func (xline XLine) Rate(rate int8) Input

Rate creates a new ugen at a specific rate. If rate is an unsupported value this method will cause a runtime panic.

Source Files

Jump to

Keyboard shortcuts

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