supergollider

package module
v0.0.0-...-94d39a7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2015 License: MIT Imports: 19 Imported by: 0

README

supergollider

NRT sound generation in Go with help from supercollider

an opinionated approach to musical organization in go. is based on and requires supercollider.

musical terms reflect not exactly the conventional meaning

Work in progress - anything may change at any time

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChangeEvent = EventGenerator(func(v *Voice, params ...Parameter) *Event {
	return &Event{
		Voice:  v,
		Params: MixParams(params...),
		runner: v.ChangeEvent,
		type_:  "CHANGE",
	}
})
View Source
var DefaultStage = New()
View Source
var MuteEvent = EventGenerator(func(v *Voice, params ...Parameter) *Event {
	return &Event{
		Voice:  v,
		runner: v.OffEvent,
		type_:  "MUTE",
	}
})

params are ignored, just to fullfill the EventGenerator interface

View Source
var OffEvent = EventGenerator(func(v *Voice, params ...Parameter) *Event {
	return &Event{
		Voice:  v,
		runner: v.OffEvent,
		type_:  "OFF",
	}
})

params are ignored, just to fullfill the EventGenerator interface

View Source
var OnEvent = EventGenerator(func(v *Voice, params ...Parameter) *Event {
	return &Event{
		Voice:  v,
		Params: MixParams(params...),
		runner: v.OnEvent,
		type_:  "ON",
	}
})
View Source
var SynthDefPool = filepath.Join(home, ".local/share/SuperCollider/quarks/SynthDefPool/pool")
View Source
var UnMuteEvent = EventGenerator(func(v *Voice, params ...Parameter) *Event {
	return &Event{
		Voice:  v,
		runner: v.donothing,
		type_:  "UNMUTE",
	}
})

params are ignored, just to fullfill the EventGenerator interface

Functions

func ExponentialDistribution

func ExponentialDistribution(param string, from, to float64, n int, dur Measure) *expDistribute

ExponentialDistribution creates a transformer that modifies the given parameter param from the value from to the value to in n steps in exponential growth for a total duration dur

func ExponentialTempoChange

func ExponentialTempoChange(from, to float64, n int, dur Measure) *expTempoLine

func FloatToInt

func FloatToInt(x float64) int

func LinearDistribution

func LinearDistribution(param string, from, to float64, n int, dur Measure) *linearDistribute

LinearDistribution creates a transformer that modifies the given parameter param from the value from to the value to in n steps in linear growth for a total duration dur

func LinearTempoChange

func LinearTempoChange(from, to float64, n int, dur Measure) *linearTempoLine

func Loop

func Loop(patterns ...Pattern) *loop

func MillisecsToTick

func MillisecsToTick(ms float64) int

func PlayAll

func PlayAll(startOffset uint)

func RoundFloat

func RoundFloat(x float64, decimals int) float64

RoundFloat rounds the given float by the given decimals after the dot

func SeqTempo

func SeqTempo(start float64, step float64, modifier func(current, step float64) float64) *tempoSpan

for start = -1 takes the current tempo

func SetTempo

func SetTempo(at string, t Tempo) *setTempo

func SlotPattern

func SlotPattern(relations ...float64) *slotPattern

SlotPattern creates slots by scaling the given relations to the current Bar of the used tracker. The slots are Measure positions on which the events that are passed via SetEvents() are positioned. Each of events may be *Event or []*Event If len(relations) < len(events), the positions of the events will rotate through the slots. If len(events) < len(relations), the events will rotate through the slot positions. The scaling base can be customized by calling SetBase(). The default base is the current Bar. The pattern by default starts at position 0 inside the bar, but that could be changed by calling At()

func StepAdd

func StepAdd(current, step float64) float64

func StepMultiply

func StepMultiply(current, step float64) float64

func TickToSeconds

func TickToSeconds(tick int) float32

func Voices

func Voices(v ...interface{}) voices

v may be []*Voice or *Voice

Types

type Add

type Add float64

func (Add) Value

func (m Add) Value(current float64) float64

type Amp

type Amp float64

func (Amp) Params

func (f Amp) Params() map[string]float64

type Attack

type Attack float64

func (Attack) Params

func (f Attack) Params() map[string]float64

type BPM

type BPM float64

func (BPM) BPM

func (b BPM) BPM() float64

func (BPM) Event

func (b BPM) Event() *Event

func (BPM) MilliSecs

func (b BPM) MilliSecs(m Measure) float64

func (BPM) Params

func (b BPM) Params() map[string]float64

func (BPM) Pattern

func (b BPM) Pattern(pos string) Pattern

type Dur

type Dur float64

func (Dur) Params

func (f Dur) Params() map[string]float64

type Dyn

type Dyn float64

Dynamic (how it is player in contrast to amplitude)

func (Dyn) Params

func (f Dyn) Params() map[string]float64

type End

type End string

func (End) Events

func (e End) Events(barNum int, t Tracker) map[Measure][]*Event

func (End) NumBars

func (e End) NumBars() int

func (End) Pattern

func (e End) Pattern(t Tracker)

type Event

type Event struct {
	Voice  *Voice
	Params Parameter // a special parameter offset may be used to set a per event offset
	// contains filtered or unexported fields
}

func CustomEvent

func CustomEvent(fn func(*Event)) *Event

func (*Event) ChangeMerged

func (ev *Event) ChangeMerged(voice *Voice, ps ...Parameter) *Event

merges the given params of the event into a clone of ev, returning the clone may be used with events that have modifiers, like Scale, Rhythm etc the given voice is set and we get a change event func (ev *Event) ChangeMerged(voice Voice, m map[string]float64) *Event {

func (*Event) Clone

func (ev *Event) Clone() *Event

func (*Event) OnMerged

func (ev *Event) OnMerged(voice *Voice, ps ...Parameter) *Event

merges the given params of the event into a clone of ev, returning the clone may be used with events that have modifiers, like Scale, Rhythm etc the given voice is set and we get an On event func (ev *Event) OnMerged(voice Voice, m map[string]float64) *Event {

type EventGenerator

type EventGenerator func(v *Voice, params ...Parameter) *Event

type Freq

type Freq float64

func (Freq) Params

func (f Freq) Params() map[string]float64

type Gate

type Gate float64

func (Gate) Params

func (f Gate) Params() map[string]float64

type HumanizeV1

type HumanizeV1 struct {
	OffsetFactor float64
	AmpFactor    float64
	FreqFactor   float64
	RateFactor   float64
}

func (HumanizeV1) Modify

func (h HumanizeV1) Modify(params Parameter) Parameter

type In

type In float64

func (In) Params

func (f In) Params() map[string]float64

type Max

type Max float64

func (Max) Value

func (m Max) Value(current float64) float64

type Measure

type Measure int
const (
	SemiFusa   Measure = 1 << iota // element has default flags
	Fusa                           // element should not have an id attribute
	SemiMinima                     // element should not have a class attribute
	Minima
	SemiBrevis
	Brevis
	Longa
	Maxima
)

func ExponentialDistributedValues

func ExponentialDistributedValues(from, to float64, steps int, dur Measure) (width Measure, diffs []float64)

ExponentialDistributedValues returns the width (time difference) and values for and exponential growth from the given value from to the given value to in the total time of dur with the given number of steps

func LinearDistributedValues

func LinearDistributedValues(from, to float64, steps int, dur Measure) (width Measure, diff float64)

LinearDistributedValues fill duration dur linearily with values from from to to in steps steps

func M

func M(s string) Measure

func (Measure) Add

func (b Measure) Add(m Measure) (numBars int, posLastBar Measure)

Add starts at pos and returns the number of bars needed until m can be reached and the position with the last bar

func (Measure) Name

func (m Measure) Name() string

func (Measure) Scale

func (total Measure) Scale(relations ...float64) []Measure

func (Measure) String

func (m Measure) String() string

type Min

type Min float64

func (Min) Value

func (m Min) Value(current float64) float64

type Multiply

type Multiply float64

func (Multiply) Value

func (m Multiply) Value(current float64) float64

type NegOffset

type NegOffset uint

func (NegOffset) Params

func (i NegOffset) Params() map[string]float64

type Out

type Out float64

func (Out) Params

func (f Out) Params() map[string]float64

type Pan

type Pan float64

func (Pan) Params

func (f Pan) Params() map[string]float64

type Parameter

type Parameter interface {
	Params() map[string]float64
}

func MixParams

func MixParams(parameter ...Parameter) Parameter

func MultiSet

func MultiSet(valuerParamsPair ...interface{}) Parameter

func Param

func Param(name string, value float64) Parameter

func SeqParams

func SeqParams(initParams Parameter, seq ...Parameter) Parameter

func Set

func Set(v Valuer, params ...Parameter) Parameter

type ParameterFunc

type ParameterFunc func() map[string]float64

func (ParameterFunc) Params

func (p ParameterFunc) Params() map[string]float64

type ParamsMap

type ParamsMap map[string]float64

func (ParamsMap) Params

func (p ParamsMap) Params() map[string]float64

type ParamsModifier

type ParamsModifier interface {
	Modify(Parameter) Parameter
}

type ParamsModifierFunc

type ParamsModifierFunc func(Parameter) Parameter

func (ParamsModifierFunc) Modify

func (p ParamsModifierFunc) Modify(param Parameter) Parameter

type Pattern

type Pattern interface {
	Events(barNum int, t Tracker) map[Measure][]*Event
	NumBars() int
}

func EventFuncPattern

func EventFuncPattern(pos string, fn func(e *Event)) Pattern

returns a Pattern for an event func at a certain position

func Exec

func Exec(pos string, fns ...func()) Pattern

func MixPatterns

func MixPatterns(trafos ...Pattern) Pattern

func RandomPattern

func RandomPattern(patterns ...Pattern) Pattern

each pattern must have the same NumBars

func RepeatPattern

func RepeatPattern(n int, loop Pattern) Pattern

func SeqPatterns

func SeqPatterns(seq ...Pattern) Pattern

func SeqSwitch

func SeqSwitch(trafo Pattern, seq ...bool) Pattern

type PatternFunc

type PatternFunc func(barNum int, t Tracker) map[Measure][]*Event

func (PatternFunc) Events

func (tf PatternFunc) Events(barNum int, t Tracker) map[Measure][]*Event

func (PatternFunc) NumBars

func (tf PatternFunc) NumBars() int

type Random

type Random float64

Random adds a random float multiplied by the given value to the existing value

func (Random) Value

func (r Random) Value(current float64) float64

type Rate

type Rate float64

func (Rate) Params

func (f Rate) Params() map[string]float64

type Release

type Release float64

func (Release) Params

func (f Release) Params() map[string]float64

type Sample

type Sample struct {
	Path   string  // the path of the sample
	Offset float64 // offset in milliseconds until max amplitude must be positiv
	MaxAmp float64 // max amplitude value, must be between 0 and 1

	Channels     uint    // number of channels
	NumFrames    int     // number of frames
	SampleRate   int     // e.g. 44100
	SampleFormat string  // e.g. int16
	Duration     float64 // duration in seconds
	HeaderFormat string  // e.g. WAV
	Frequency    float64
	// contains filtered or unexported fields
}

type SampleLibrary

type SampleLibrary interface {
	SamplePath(instrument string, params map[string]float64) string
	Channels() []int // channel variants
}

type Sequencer

type Sequencer interface {
	Next(v *Voice) Pattern
}

type Stage

type Stage struct {
	AudioFile string
	ScoreFile string

	WriteSynthDefs bool
	LoadSamples    bool
	// contains filtered or unexported fields
}

func New

func New() *Stage

func (*Stage) Bus

func (s *Stage) Bus(name string, numchannels int) *Voice

func (*Stage) Group

func (s *Stage) Group(parent int) *Voice

func (*Stage) Instrument

func (s *Stage) Instrument(name string, dir string, numVoices int) []*Voice

func (*Stage) Play

func (s *Stage) Play(startOffset uint)

startOffset is in milliseconds and must be positive

func (*Stage) Route

func (s *Stage) Route(name, dir string, numVoices int) []*Voice

func (*Stage) Sample

func (s *Stage) Sample(path string, numVoices int) []*Voice

func (*Stage) SampleFreq

func (s *Stage) SampleFreq(path string, freq float64, numVoices int) []*Voice

func (*Stage) SampleInstrument

func (s *Stage) SampleInstrument(instrument string, sampleLib SampleLibrary, numVoices int) []*Voice

func (*Stage) Track

func (s *Stage) Track(bar string, tempo Tempo) *Track

type Start

type Start string

func (Start) Events

func (s Start) Events(barNum int, t Tracker) map[Measure][]*Event

func (Start) NumBars

func (s Start) NumBars() int

type Tempo

type Tempo interface {
	// returns the milliseconds of the measure
	MilliSecs(m Measure) float64 //uint
	// return the beats per minute
	BPM() float64
}

type Track

type Track struct {
	Bars []Measure

	Events []*Event
	// contains filtered or unexported fields
}

func NewTrack

func NewTrack(bar string, tempo Tempo) *Track

func (*Track) At

func (t *Track) At(pos Measure, events ...*Event)

func (*Track) BarNum

func (t *Track) BarNum() int

func (*Track) Change

func (t *Track) Change(bar string, tr ...Pattern) *Track

func (*Track) CurrentBar

func (t *Track) CurrentBar() Measure

func (*Track) Fill

func (t *Track) Fill(num int, tr ...Pattern) *Track

fill with num bars, transformers are repeated each bar

func (*Track) MixPatterns

func (t *Track) MixPatterns(patterns ...Pattern)

func (*Track) Next

func (t *Track) Next(tr ...Pattern) *Track

func (*Track) Print

func (t *Track) Print(tempo Tempo, unit string, wr io.Writer)

func (*Track) RemoveLoops

func (t *Track) RemoveLoops(names ...string) *Track

RemoveLoops removes all loops if no names is passed

func (*Track) SetLoop

func (t *Track) SetLoop(name string, pattern Pattern) *Track

SetLoop sets a Loop so that position "0" inside the loop matches position "0" inside the track bar

func (*Track) SetLoopAt

func (t *Track) SetLoopAt(name string, startPos string, pattern Pattern) *Track

SetLoopAt sets a Loop so that startPos inside the loop matches position "0" inside the track bar

func (*Track) SetLoops

func (t *Track) SetLoops(namePatternPairs ...interface{}) *Track

func (*Track) SetTempo

func (t *Track) SetTempo(pos Measure, tempo Tempo)

func (*Track) Start

func (t *Track) Start(patterns ...Pattern) *Track

type TrackLoop

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

func (TrackLoop) Events

func (l TrackLoop) Events(barNum int, t Tracker) map[Measure][]*Event

func (TrackLoop) Next

func (l TrackLoop) Next(patterns ...Pattern) *loop

func (TrackLoop) NumBars

func (l TrackLoop) NumBars() int

func (*TrackLoop) Off

func (l *TrackLoop) Off() *TrackLoopStop

func (*TrackLoop) On

func (l *TrackLoop) On() *TrackLoopStart

func (*TrackLoop) OnAt

func (l *TrackLoop) OnAt(pos string) *TrackLoopStart

func (*TrackLoop) Replace

func (l *TrackLoop) Replace(n *loop) *TrackLoopReplacer

func (*TrackLoop) ReplaceAt

func (l *TrackLoop) ReplaceAt(start string, n *loop) *TrackLoopReplacer

func (TrackLoop) TrackLoop

func (l TrackLoop) TrackLoop() *TrackLoop

type TrackLoopReplacer

type TrackLoopReplacer struct {
	*TrackLoop
	// contains filtered or unexported fields
}

func (TrackLoopReplacer) Events

func (l TrackLoopReplacer) Events(barNum int, t Tracker) map[Measure][]*Event

func (TrackLoopReplacer) Next

func (l TrackLoopReplacer) Next(patterns ...Pattern) *loop

func (TrackLoopReplacer) NumBars

func (l TrackLoopReplacer) NumBars() int

func (TrackLoopReplacer) TrackLoop

func (l TrackLoopReplacer) TrackLoop() *TrackLoop

type TrackLoopStart

type TrackLoopStart struct {
	*TrackLoop
	// contains filtered or unexported fields
}

func (TrackLoopStart) Events

func (l TrackLoopStart) Events(barNum int, t Tracker) map[Measure][]*Event

func (TrackLoopStart) Next

func (l TrackLoopStart) Next(patterns ...Pattern) *loop

func (TrackLoopStart) NumBars

func (l TrackLoopStart) NumBars() int

func (TrackLoopStart) TrackLoop

func (l TrackLoopStart) TrackLoop() *TrackLoop

type TrackLoopStop

type TrackLoopStop struct {
	// stopAt Measure
	*TrackLoop
}

func (TrackLoopStop) Events

func (l TrackLoopStop) Events(barNum int, t Tracker) map[Measure][]*Event

func (TrackLoopStop) Next

func (l TrackLoopStop) Next(patterns ...Pattern) *loop

func (TrackLoopStop) NumBars

func (l TrackLoopStop) NumBars() int

func (TrackLoopStop) TrackLoop

func (l TrackLoopStop) TrackLoop() *TrackLoop

type Tracker

type Tracker interface {
	/*
		SetTempo(pos Measure, tempo Tempo)
		TempoAt(abspos Measure) Tempo
	*/
	At(pos Measure, events ...*Event)
	// TempoAt(abspos Measure) Tempo
	CurrentBar() Measure
}

Tracker limits the available functions for a Pattern

type Valuer

type Valuer interface {
	Value(current float64) float64
}

func ValuePipe

func ValuePipe(v ...Valuer) Valuer

type Voice

type Voice struct {
	Group int
	Bus   int

	// lastSampleFrequency float64 // frequency of the last played sample
	ParamsModifier ParamsModifier
	// contains filtered or unexported fields
}

func NewBus

func NewBus(name string, numchannels int) *Voice

func NewGroup

func NewGroup(parent int) *Voice

func NewInstrument

func NewInstrument(name string, dir string, numVoices int) []*Voice

func NewRoute

func NewRoute(name, dir string, numVoices int) []*Voice

func NewSample

func NewSample(path string, numVoices int) []*Voice

func NewSampleFreq

func NewSampleFreq(path string, freq float64, numVoices int) []*Voice

func NewSampleInstrument

func NewSampleInstrument(instrument string, sampleLib SampleLibrary, numVoices int) []*Voice

func (*Voice) Bar

func (v *Voice) Bar(parameter ...Parameter) Pattern

func (*Voice) ChangeEvent

func (v *Voice) ChangeEvent(ev *Event)

func (*Voice) Exec

func (v *Voice) Exec(pos string, fn func() *Event) Pattern

func (v *Voice) Exec(numBars int, pos string, fn PatternFunc) Pattern { func (v *Voice) Exec(numBars int, pos string, fn PatternFunc) Pattern {

func (*Voice) Metronome

func (v *Voice) Metronome(unit Measure, parameter ...Parameter) *metronome

func (*Voice) Modify

func (v *Voice) Modify(pos string, params ...Parameter) Pattern

func (*Voice) Mute

func (v *Voice) Mute(pos string) Pattern

func (*Voice) OffEvent

func (v *Voice) OffEvent(ev *Event)

func (*Voice) OnEvent

func (v *Voice) OnEvent(ev *Event)

func (*Voice) Phrase

func (v *Voice) Phrase(pos string) *phrase

func (*Voice) Play

func (v *Voice) Play(pos string, params ...Parameter) Pattern

func (*Voice) PlayDur

func (v *Voice) PlayDur(pos, dur string, params ...Parameter) Pattern

func (*Voice) Rhythm

func (v *Voice) Rhythm(start string, positions ...string) *rhythm

func (*Voice) Sequencer

func (v *Voice) Sequencer(s Sequencer) Pattern

func (*Voice) SetOffset

func (v *Voice) SetOffset(o float64)

func (*Voice) Stop

func (v *Voice) Stop(pos string) Pattern

func (*Voice) UnMute

func (v *Voice) UnMute(pos string) Pattern

Directories

Path Synopsis
Package amp provides shortcuts for amplitude measures contrasting with the dyn package that affects how something is played
Package amp provides shortcuts for amplitude measures contrasting with the dyn package that affects how something is played
Package beat provides shortcuts for beat positions within a bar
Package beat provides shortcuts for beat positions within a bar
Package chord provides shortcuts for chords
Package chord provides shortcuts for chords
Package dyn provides shortcuts for dynamic measures as a matter of how something is played contrasting to amp that affects the amplitude
Package dyn provides shortcuts for dynamic measures as a matter of how something is played contrasting to amp that affects the amplitude
Package amp provides shortcuts for midi notes and their frequencies
Package amp provides shortcuts for midi notes and their frequencies
Package sample provides shortcuts for parameters that are useful for samples
Package sample provides shortcuts for parameters that are useful for samples
Package sampleplayer provides an instrument based on different samples for different frequencies and dynamics
Package sampleplayer provides an instrument based on different samples for different frequencies and dynamics
Package scale provides shortcuts for chromatic and periodic (diatonic) scales
Package scale provides shortcuts for chromatic and periodic (diatonic) scales

Jump to

Keyboard shortcuts

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