Documentation ¶
Overview ¶
Package sc is a SuperCollider client for Go.
Index ¶
- Constants
- Variables
- func CheckRate(rate int8)
- func Midicps(note float32) float32
- func Play(c *Client, f UgenFunc) error
- type AllpassC
- type AllpassL
- type AllpassN
- type BLowPass
- type BPF
- type BRF
- type Balance2
- type Blip
- type BrownNoise
- type Buffer
- type C
- type COsc
- type Client
- func (c *Client) AddDefaultGroup() (*Group, error)
- func (c *Client) AllocBuffer(frames, channels int) (*Buffer, error)
- func (c *Client) Close() error
- func (c *Client) Connect(addr string, timeout time.Duration) error
- func (c *Client) DumpOSC(level int32) error
- func (c *Client) FreeAll(gids ...int32) error
- func (c *Client) Group(id, action, target int32) (*Group, error)
- func (c *Client) NextSynthID() int32
- func (c *Client) QueryGroup(id int32) (*Group, error)
- func (c *Client) ReadBuffer(path string, num int32) (*Buffer, error)
- func (c *Client) SendDef(def *Synthdef) error
- func (c *Client) Status(timeout time.Duration) (*ServerStatus, error)
- func (c *Client) Synth(defName string, id, action, target int32, ctls map[string]float32) (*Synth, error)
- func (c *Client) Synths(args []SynthArgs) error
- type ClipNoise
- type Comb
- type Control
- func (ctl *Control) Add(val Input) Input
- func (ctl *Control) Inputs() []Input
- func (ctl *Control) Max(other Input) Input
- func (ctl *Control) Mul(val Input) Input
- func (ctl *Control) MulAdd(mul, add Input) Input
- func (ctl *Control) Name() string
- func (ctl *Control) Outputs() []Output
- func (ctl *Control) Rate() int8
- func (ctl *Control) SoftClip() Input
- func (ctl *Control) SpecialIndex() int16
- type Crackle
- type Decay
- type Decay2
- type Delay
- type DetectSilence
- type Dust
- type Dust2
- type Env
- type EnvADSR
- type EnvASR
- type EnvCutoff
- type EnvDADSR
- type EnvGen
- type EnvLinen
- type EnvPairs
- type EnvPerc
- type EnvSine
- type EnvTLC
- type EnvTriangle
- type Envelope
- type FSinOsc
- type Formlet
- type FreeVerb
- type Gate
- type GrainBuf
- type GrainFM
- type GrayNoise
- type Group
- type Impulse
- type Input
- type Inputs
- type Integrator
- type Interpolation
- type Klank
- type LFCub
- type LFDNoise
- type LFNoise
- type LFPulse
- type LFSaw
- type LFTri
- type Limiter
- type Line
- type MouseX
- type MouseY
- type MultiInput
- type MultiNode
- type Node
- type NoiseInterpolation
- type Out
- type Output
- type PMOsc
- type Pairs
- type Pan2
- type Param
- type ParamName
- type Params
- type PinkNoise
- type PlayBuf
- type Pulse
- type RLPF
- type Rand
- type Saw
- type Select
- type Server
- type ServerStatus
- type SinOsc
- type Synth
- type SynthArgs
- type Synthdef
- func (def *Synthdef) Bytes() ([]byte, error)
- func (def *Synthdef) CompareToDef(other *Synthdef) (bool, error)
- func (def *Synthdef) CompareToFile(path string) (bool, error)
- func (def *Synthdef) Write(w io.Writer) error
- func (def *Synthdef) WriteGraph(w io.Writer) error
- func (def *Synthdef) WriteJSON(w io.Writer) error
- func (def *Synthdef) WriteXML(w io.Writer) error
- type TLC
- type Ugen
- type UgenFunc
- type UgenNode
- func BinOpAdd(rate int8, x, y Input, numOutputs int) *UgenNode
- func BinOpMax(rate int8, x, y Input, numOutputs int) *UgenNode
- func BinOpMul(rate int8, x, y Input, numOutputs int) *UgenNode
- func MulAdd(rate int8, in, mul, add Input, numOutputs int) *UgenNode
- func NewUgenNode(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) *UgenNode
- func UnaryOpSoftClip(rate int8, in Input, numOutputs int) *UgenNode
- func (un *UgenNode) Add(val Input) Input
- func (un *UgenNode) Inputs() []Input
- func (un *UgenNode) IsOutput()
- func (un *UgenNode) Max(other Input) Input
- func (un *UgenNode) Mul(val Input) Input
- func (un *UgenNode) MulAdd(mul, add Input) Input
- func (un *UgenNode) Name() string
- func (un *UgenNode) Outputs() []Output
- func (un *UgenNode) Rate() int8
- func (un *UgenNode) SoftClip() Input
- func (un *UgenNode) SpecialIndex() int16
- type Variant
- type WhiteNoise
- type XLine
Examples ¶
Constants ¶
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" )
const ( DumpOff = 0 DumpParsed = 1 DumpContents = 2 DumpAll = 3 )
Arguments to dumpOSC command. See http://doc.sccode.org/Reference/Server-Command-Reference.html#/dumpOSC
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
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 )
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) )
const ( GrainBufHanningEnv = -1 GrainBufNoInterp = 1 GrainBufLinearInterp = 2 GrainBufCubicInterp = 4 )
Envelope shapes for grain amp envelope.
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.
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
const DefaultServerPort = 57120
DefaultServerPort is the default listening port for scsynth.
const GrainBufDefaultMaxGrains = 512
GrainBufDefaultMaxGrains is the default value of MaxGrains.
const ServerPath = "/usr/bin/scsynth:/usr/local/bin/scsynth"
ServerPath is the path the scsynth executable on linux systems.
Variables ¶
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.
var (
ErrTimeout = errors.New("timeout error")
)
Common errors.
Functions ¶
Types ¶
type AllpassC ¶
type AllpassC struct { // In is the input signal In Input // MaxDelay is maximum delay time in seconds. // This is used to initialize the delay buffer. MaxDelay Input // Delay time in seconds Delay Input // Decay 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. Decay Input }
AllpassC allpass delay with cubic interpolation
type AllpassL ¶
type AllpassL struct { // In is the input signal In Input // MaxDelay is maximum delay time in seconds. // This is used to initialize the delay buffer. MaxDelay Input // Delay time in seconds Delay Input // Decay 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. Decay Input }
AllpassL allpass delay with linear interpolation
type AllpassN ¶
type AllpassN struct { // In is the input signal In Input // MaxDelay is maximum delay time in seconds. // This is used to initialize the delay buffer. MaxDelay Input // Delay time in seconds Delay Input // Decay 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. Decay Input }
AllpassN allpass delay with no interpolation
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.
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
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
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
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 { Num int32 // contains filtered or unexported fields }
Buffer is a client-side representation of an scsynth audio buffer
type C ¶
type C float32
C wraps a float32 and implements the Input interface.
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.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages all communication with scsynth
func DefaultClient ¶
DefaultClient returns the default sc client.
func NewClient ¶
NewClient creates a new SuperCollider client. The client will bind to the provided address and port to receive messages from scsynth.
func (*Client) AddDefaultGroup ¶
AddDefaultGroup adds the default group.
func (*Client) AllocBuffer ¶
AllocBuffer allocates a buffer on the server
func (*Client) DumpOSC ¶
DumpOSC sends a /dumpOSC message to scsynth level should be DumpOff, DumpParsed, DumpContents, DumpAll
func (*Client) NextSynthID ¶
NextSynthID gets the next available ID for creating a synth
func (*Client) QueryGroup ¶
QueryGroup g_queryTree for a particular group.
func (*Client) ReadBuffer ¶
ReadBuffer tells the server to read an audio file and load it into a buffer
func (*Client) SendDef ¶
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.
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.
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.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control represents a synth control. See http://doc.sccode.org/Classes/Control.html.
func (*Control) SpecialIndex ¶
SpecialIndex returns the special index of the Control.
type Crackle ¶
type Crackle struct {
Chaos Input
}
Crackle is a noise generator based on a chaotic function.
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.
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.
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.
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 Dust ¶
type Dust struct { // Density is the average number of impulses per second Density Input }
Dust generates random impulses from 0 to +1
type Dust2 ¶
type Dust2 struct { // Density is the average number of impulses per second Density Input }
Dust2 generates random impulses from -1 to +1
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
type EnvADSR ¶
type EnvADSR struct {
A, D, S, R, Peak, Curve, Bias Input
}
EnvADSR represents the ever-popular ADSR envelope
type EnvASR ¶
type EnvASR struct {
A, S, R, Curve Input
}
EnvASR is an attack-sustain-release envelope
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.
type EnvDADSR ¶
type EnvDADSR struct {
Delay, A, D, S, R, Peak, Curve, Bias Input
}
EnvDADSR is EnvADSR with its onset delayed by D seconds
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.
type EnvLinen ¶
type EnvLinen struct {
Attack, Sustain, Release, Level Input
Curve interface{}
}
EnvLinen creates a new envelope which has a trapezoidal shape
type EnvPairs ¶
type EnvPairs struct { Pairs Pairs Curve interface{} }
EnvPairs creates a new envelope from coordinates/pairs
type EnvPerc ¶
type EnvPerc struct {
Attack, Release, Level, Curve Input
}
EnvPerc creates a new envelope that has a percussive shape
type EnvSine ¶
type EnvSine struct {
Dur, Level Input
}
EnvSine creates a new envelope which has a hanning window shape
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.
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 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.
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.
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
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.
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
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
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.
type Group ¶
type Group struct { Node `json:"node" xml:"node"` Children []*Node `json:"children" xml:"children>child"` // contains filtered or unexported fields }
Group is a group of synth nodes
func (*Group) Synths ¶ added in v0.1.3
Synths creates multiple synth nodes at once with an OSC bundle.
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
type Input ¶
type Input interface { // Max returns the max of one signal and another. Max(other Input) Input // Mul multiplies one Input by another. Mul(val Input) Input // Add adds one Input to another. Add(val Input) Input // MulAdd multiplies and adds an Input using two others. MulAdd(mul, add Input) Input // SoftClip distorts a signal with a perfectly linear range from -0.5 to 0.5 SoftClip() Input }
Input is implemented by any value that can serve as a ugen input. This includes synthdef parameters, constants, and other ugens.
type Inputs ¶
type Inputs []Input
Inputs is a slice of Input.
func Multi ¶
Multi does multichannel expansion. See http://doc.sccode.org/Guides/Multichannel-Expansion.html.
func (Inputs) InputArray ¶
InputArray provides access to the list of inputs.
func (Inputs) Max ¶ added in v0.1.3
Max returns Inputs that contain the max of all the inputs and the provided Input.
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 Klank ¶ added in v0.1.3
type Klank struct { // Spec is three float 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 [3][]float32 In Input // In is the excitation input to the resonant filter bank. FreqScale Input // FreqScale is a scale factor multiplied by all frequencies at initialization time. FreqOffset Input // FreqOffset is an offset added to all frequencies at initialization time. DecayScale Input // DecayScale is a scale factor multiplied by all ring times at initialization time. }
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.
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.
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.
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.
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
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
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].
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.
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
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
type MultiInput ¶
MultiInput is the interface of an input that causes cascading multi-channel expansion. See http://doc.sccode.org/Guides/Multichannel-Expansion.html
type MultiNode ¶
type MultiNode struct {
// contains filtered or unexported fields
}
MultiNode is a MultiInput that consists of ugens.
func NewMultiNode ¶
NewMultiNode creates a new MultiNode.
func (*MultiNode) InputArray ¶
InputArray returns the ugens as a slice of Inputs.
type NoiseInterpolation ¶
type NoiseInterpolation int
NoiseInterpolation defines different types of interpolation for LFNoise ugens.
const ( NoiseStep NoiseInterpolation = iota NoiseLinear NoiseQuadratic )
Noise interpolation types.
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.
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.
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.
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 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.
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.
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.
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
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.
type Server ¶
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.
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 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
type Synth ¶
type Synth struct { DefName string `json:"defName"` ID int32 `json:"id"` // contains filtered or unexported fields }
Synth encapsulates a synth node.
func PlayDef ¶
PlayDef plays a synthdef by sending the synthdef using DefaultClient, then immediately creating a synth node from the def.
type SynthArgs ¶ added in v0.1.3
SynthArgs contains the arguments necessary to create a synth that is part of a group.
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" xml:"Constants>Constant"` // InitialParamValues is an array of initial values for synth params InitialParamValues []float32 `json:"initialParamValues" xml:"InitialParamValues>initialParamValue"` // ParamNames contains the names of the synth parameters ParamNames []ParamName `json:"paramNames" 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" xml:"Ugens>Ugen"` // Variants is the list of variants contained in the synth def Variants []*Variant `json:"variants" 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 ¶
NewSynthdef creates a synthdef by traversing a ugen graph
Example ¶
NewSynthdef("SineTone", func(p Params) Ugen { bus := C(0) sine := SinOsc{}.Rate(AR) return Out{bus, sine}.Rate(AR) }).WriteJSON(os.Stdout)
Output: {"name":"SineTone","constants":[440,0],"initialParamValues":[],"paramNames":[],"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}],"outputs":[]}],"variants":[]}
func ReadSynthdef ¶
ReadSynthdef reads a synthdef from an io.Reader
func (*Synthdef) CompareToDef ¶
CompareToDef compare this synthdef to another.
func (*Synthdef) CompareToFile ¶
CompareToFile compares this synthdef to another one stored on disk.
func (*Synthdef) Write ¶
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) WriteGraph ¶
WriteGraph writes a dot-formatted representation of a synthdef's ugen graph to an io.Writer. See http://www.graphviz.org/content/dot-language.
type TLC ¶
type TLC struct {
Time, Level float32
Curve interface{}
}
TLC (time, level, curve) triplet
type Ugen ¶
type Ugen interface { // Name returns the name of the ugen node Name() string // Rate returns the rate of the ugen node Rate() int8 // SpecialIndex returns the special index of the ugen node SpecialIndex() int16 // Inputs returns the inputs of the ugen node. // Inputs can be // (1) Constant (float32) // (2) Control (synthdef param) // (3) Ugen Inputs() []Input // Outputs returns the outputs of the ugen node Outputs() []Output }
Ugen defines the interface between synthdefs and ugens.
type UgenNode ¶
type UgenNode struct {
// contains filtered or unexported fields
}
UgenNode represents a node in a ugen graph.
func BinOpMax ¶ added in v0.1.3
BinOpMax creates a BinaryOpUgen that represents the maximum of two signals.
func NewUgenNode ¶
func NewUgenNode(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) *UgenNode
NewUgenNode is a factory function for creating new UgenNode instances. Panics if rate is not AR, KR, or IR. Panics if numOutputs <= 0.
func UnaryOpSoftClip ¶ added in v0.1.3
UnaryOpSoftClip adds distortion to a ugen.
func (*UgenNode) IsOutput ¶
func (un *UgenNode) IsOutput()
IsOutput initializes the outputs array of the ugen node.
func (*UgenNode) SpecialIndex ¶
SpecialIndex returns the special index of the ugen node.
type Variant ¶
type Variant struct { Name string `json:"name,omitempty"` InitialParamValues []float32 `json:"initialParamValues"` }
Variant provides a way to create synthdef presets.
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.
Source Files ¶
- allpassc.go
- allpassl.go
- allpassn.go
- balance2.go
- binop.go
- blip.go
- blowpass.go
- bpf.go
- brf.go
- brownnoise.go
- buffer.go
- c.go
- client.go
- clipnoise.go
- comb.go
- control.go
- conv.go
- cosc.go
- crackle.go
- decay.go
- decay2.go
- delay.go
- detect_silence.go
- doc.go
- dust.go
- dust2.go
- env.go
- envelope.go
- envgen.go
- formlet.go
- freeverb.go
- fsinosc.go
- gate.go
- grainbuf.go
- grainfm.go
- graynoise.go
- group.go
- impulse.go
- input.go
- integrator.go
- interpolation.go
- klank.go
- lfcub.go
- lfdnoise.go
- lfnoise.go
- lfpulse.go
- lfsaw.go
- lftri.go
- limiter.go
- line.go
- mix.go
- mousex.go
- mousey.go
- multiInput.go
- multiNode.go
- out.go
- output.go
- pan2.go
- param.go
- paramName.go
- pinknoise.go
- playbuf.go
- pmosc.go
- pstring.go
- pulse.go
- rand.go
- rate.go
- rlpf.go
- saw.go
- select.go
- server.go
- server_linux.go
- sinosc.go
- stack.go
- status.go
- sums.go
- synth.go
- synthdef.go
- synthdef_read.go
- synthdef_write.go
- ugen.go
- ugenFunc.go
- ugenNode.go
- ugeninput.go
- variant.go
- whitenoise.go
- xline.go