Documentation
¶
Index ¶
- Constants
- Variables
- func TotalVoices[T any, S ~[]T, P NumVoicerPointer[T]](slice S) (ret int)
- type AudioBuffer
- type AudioContext
- type AudioSource
- type BufferSource
- type CloserWaiter
- type Instrument
- type NumVoicer
- type NumVoicerPointer
- type Order
- type ParamMap
- type Patch
- func (p Patch) Copy() Patch
- func (p Patch) FindUnit(id int) (instrIndex int, unitIndex int, err error)
- func (p Patch) FirstVoiceForInstrument(instrIndex int) int
- func (p Patch) InstrumentForVoice(voice int) (int, error)
- func (p Patch) NumDelayLines() int
- func (p Patch) NumSyncs() int
- func (p Patch) NumVoices() int
- type Pattern
- type Score
- func (s *Score) Clamp(songPos SongPos) SongPos
- func (l Score) Copy() Score
- func (l Score) FirstVoiceForTrack(track int) int
- func (l Score) LengthInRows() int
- func (l Score) NumVoices() int
- func (s *Score) SongPos(songRow int) SongPos
- func (s *Score) SongRow(songPos SongPos) int
- func (s *Score) Wrap(songPos SongPos) SongPos
- type Song
- type SongPos
- type StackUse
- type Synth
- type Synther
- type Track
- type Unit
- type UnitParameter
- type UnitParameterDisplayFunc
Constants ¶
When unit.Type = "oscillator", its unit.Parameter["Type"] tells the type of the oscillator. There is five different oscillator types, so these consts just enumerate them.
Variables ¶
var License string
var Ports = make(map[string]([]string))
Ports is static map allowing quickly finding the parameters of a unit that can be modulated. This is populated based on the UnitTypes list during init(). Thus, should be immutable, but Go not supporting that, then this will have to suffice: DO NOT EVER CHANGE THIS MAP.
var UnitNames []string
UnitNames is a list of all the names of units, sorted alphabetically.
var UnitTypes = map[string]([]UnitParameter){ "add": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "addp": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "pop": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "loadnote": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "mul": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "mulp": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "push": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "xch": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "distort": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "drive", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true}}, "hold": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "holdfreq", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}}, "crush": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "resolution", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(24 * float64(v) / 128), "bits" }}}, "gain": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}}, "invgain": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(128/float64(v)), 'g', 3, 64), "dB" }}}, "dbgain": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "decibels", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(40 * (float64(v)/64 - 1)), "dB" }}}, "filter": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "frequency", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: filterFrequencyDispFunc}, {Name: "resonance", MinValue: 0, Neutral: 128, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(128/float64(v)), 'g', 3, 64), "Q dB" }}, {Name: "lowpass", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "bandpass", MinValue: -1, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "highpass", MinValue: -1, MaxValue: 1, CanSet: true, CanModulate: false}}, "clip": []UnitParameter{{Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "pan": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "panning", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true}}, "delay": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "pregain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "dry", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "feedback", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "damp", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "notetracking", MinValue: 0, MaxValue: 2, CanSet: true, CanModulate: false, DisplayFunc: arrDispFunc(noteTrackingNames[:])}, {Name: "delaytime", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true}}, "compressor": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "attack", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: compressorTimeDispFunc}, {Name: "release", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: compressorTimeDispFunc}, {Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(128/float64(v)), 'g', 3, 64), "dB" }}, {Name: "threshold", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}, {Name: "ratio", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(1 - float64(v)/128), "" }}}, "speed": []UnitParameter{}, "out": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}}, "outaux": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "outgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}, {Name: "auxgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}}, "aux": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}, {Name: "channel", MinValue: 0, MaxValue: 6, CanSet: true, CanModulate: false, DisplayFunc: arrDispFunc(channelNames[:])}}, "send": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "amount", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(float64(v)/64 - 1), "" }}, {Name: "voice", MinValue: 0, MaxValue: 32, CanSet: true, CanModulate: false, DisplayFunc: sendVoiceDispFunc}, {Name: "target", MinValue: 0, MaxValue: math.MaxInt32, CanSet: true, CanModulate: false}, {Name: "port", MinValue: 0, MaxValue: 7, CanSet: true, CanModulate: false}, {Name: "sendpop", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}}, "envelope": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "attack", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return engineeringTime(math.Pow(2, 24*float64(v)/128) / 44100) }}, {Name: "decay", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return engineeringTime(math.Pow(2, 24*float64(v)/128) / 44100) }}, {Name: "sustain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}, {Name: "release", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return engineeringTime(math.Pow(2, 24*float64(v)/128) / 44100) }}, {Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}}, "noise": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "shape", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}}, "oscillator": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "transpose", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: oscillatorTransposeDispFunc}, {Name: "detune", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(float64(v-64) / 64), "st" }}, {Name: "phase", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(float64(v)/128*360, 'f', 1, 64), "°" }}, {Name: "color", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "shape", MinValue: 0, Neutral: 64, MaxValue: 128, CanSet: true, CanModulate: true}, {Name: "gain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return strconv.FormatFloat(toDecibel(float64(v)/128), 'g', 3, 64), "dB" }}, {Name: "frequency", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true}, {Name: "type", MinValue: int(Sine), MaxValue: int(Sample), CanSet: true, CanModulate: false, DisplayFunc: arrDispFunc(oscTypes[:])}, {Name: "lfo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "unison", MinValue: 0, MaxValue: 3, CanSet: true, CanModulate: false}, {Name: "samplestart", MinValue: 0, MaxValue: 1720329, CanSet: true, CanModulate: false}, {Name: "loopstart", MinValue: 0, MaxValue: 65535, CanSet: true, CanModulate: false}, {Name: "looplength", MinValue: 0, MaxValue: 65535, CanSet: true, CanModulate: false}}, "loadval": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "value", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(float64(v)/64 - 1), "" }}}, "receive": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "left", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true}, {Name: "right", MinValue: 0, MaxValue: -1, CanSet: false, CanModulate: true}}, "in": []UnitParameter{ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "channel", MinValue: 0, MaxValue: 6, CanSet: true, CanModulate: false, DisplayFunc: arrDispFunc(channelNames[:])}}, "sync": []UnitParameter{}, }
UnitTypes documents all the available unit types and if they support stereo variant and what parameters they take.
Functions ¶
func TotalVoices ¶ added in v0.5.0
func TotalVoices[T any, S ~[]T, P NumVoicerPointer[T]](slice S) (ret int)
TotalVoices returns the total number of voices used in the slice; summing the GetNumVoices of every element
Types ¶
type AudioBuffer ¶ added in v0.3.0
type AudioBuffer [][2]float32
AudioBuffer is a buffer of stereo audio samples of variable length, each sample represented by [2]float32. [0] is left channel, [1] is right
func Play ¶
func Play(synther Synther, song Song, progress func(float32)) (AudioBuffer, error)
Play plays the Song by first compiling the patch with the given Synther, returning the stereo audio buffer as a result (and possible errors).
func (AudioBuffer) Fill ¶ added in v0.3.0
func (buffer AudioBuffer) Fill(synth Synth) error
Fill fills the AudioBuffer using a Synth, disregarding all syncs and time limits. Note that this will change the state of the Synth.
func (AudioBuffer) Raw ¶ added in v0.3.0
func (buffer AudioBuffer) Raw(pcm16 bool) ([]byte, error)
Raw converts an AudioBuffer into a raw audio file, returned as a []byte array.
If pcm16 is set to true, the samples will be 16-bit signed integers; otherwise the samples will be 32-bit floats
func (AudioBuffer) Source ¶ added in v0.5.0
func (b AudioBuffer) Source() AudioSource
func (AudioBuffer) Wav ¶ added in v0.3.0
func (buffer AudioBuffer) Wav(pcm16 bool) ([]byte, error)
Wav converts an AudioBuffer into a valid WAV-file, returned as a []byte array.
If pcm16 is set to true, the samples in the WAV-file will be 16-bit signed integers; otherwise the samples will be 32-bit floats
type AudioContext ¶
type AudioContext interface {
Play(r AudioSource) CloserWaiter
}
AudioContext represents the low-level audio drivers. There should be at most one AudioContext at a time. The interface is implemented at least by oto.OtoContext, but in future we could also mock it.
AudioContext is used to play one or more AudioSources. Playing can be stopped by closing the returned io.Closer.
type AudioSource ¶ added in v0.5.0
type AudioSource func(buf AudioBuffer) error
AudioSource is an function for reading audio samples into an AudioBuffer. Returns error if the buffer is not filled.
type BufferSource ¶ added in v0.5.0
type BufferSource struct {
// contains filtered or unexported fields
}
func (*BufferSource) ReadAudio ¶ added in v0.5.0
func (a *BufferSource) ReadAudio(buf AudioBuffer) error
ReadAudio reads audio samples from an AudioSource into an AudioBuffer. Returns an error when the buffer is fully consumed.
type CloserWaiter ¶ added in v0.5.0
type Instrument ¶
type Instrument struct {
Name string `yaml:",omitempty"`
Comment string `yaml:",omitempty"`
NumVoices int
Units []Unit
Mute bool `yaml:",omitempty"` // Mute is only used in the tracker for soloing/muting instruments; the compiled player ignores this field
}
Instrument includes a list of units consisting of the instrument, and the number of polyphonic voices for this instrument
func Read4klangInstrument ¶ added in v0.2.0
func Read4klangInstrument(r io.Reader) (instr Instrument, err error)
Read4klangInstrument reads a 4klang instrument (a file usually with .4ki extension) from r and returns an Instrument, making best attempt to convert 4ki file to a sointu Instrument. It returns an error if the file is malformed or if the 4ki file version is not supported.
func (*Instrument) Copy ¶
func (instr *Instrument) Copy() Instrument
Copy makes a deep copy of an Instrument
func (*Instrument) GetNumVoices ¶ added in v0.5.0
func (i *Instrument) GetNumVoices() int
Implement the counter interface
func (*Instrument) SetNumVoices ¶ added in v0.5.0
func (i *Instrument) SetNumVoices(count int)
type NumVoicer ¶ added in v0.5.0
NumVoicer is used for slices where elements have NumVoices, of which there are two: Tracks and Instruments.
type NumVoicerPointer ¶ added in v0.5.0
NumVoicerPointer is a helper interface for type constraints, as SetNumVoices needs to be defined with a pointer receiver to be able to actually modify the value.
type Order ¶ added in v0.2.0
type Order []int
Order is the pattern order for a track, in practice just a slice of integers, but provides convenience functions that return -1 values for indices out of bounds of the array, and functions to increase the size of the slice only by necessary amount when a new item is added, filling the unused slots with -1s.
type Patch ¶
type Patch []Instrument
Patch is simply a list of instruments used in a song
func Read4klangPatch ¶ added in v0.2.0
Read4klangPatch reads a 4klang patch (a file usually with .4kp extension) from r and returns a Patch, making best attempt to convert 4klang file to a sointu Patch. It returns an error if the file is malformed or if the 4kp file version is not supported.
func (Patch) FindUnit ¶ added in v0.3.0
FindUnit searches the instrument index and unit index for a unit with the given id. Two units should never have the same id, but if they do, then the first match is returned. Id 0 is interpreted as "no id", thus searching for id 0 returns an error. Error is also returned if the searched id is not found. FindUnit considers disabled units as non-existent.
func (Patch) FirstVoiceForInstrument ¶
FirstVoiceForInstrument returns the index of the first voice of given instrument. For example, if the Patch has three instruments (0, 1 and 2), with 1, 3, 2 voices, respectively, then FirstVoiceForInstrument(0) returns 0, FirstVoiceForInstrument(1) returns 1 and FirstVoiceForInstrument(2) returns 4. Essentially computes just the cumulative sum.
func (Patch) InstrumentForVoice ¶
InstrumentForVoice returns the instrument number for the given voice index. For example, if the Patch has three instruments (0, 1 and 2), with 1, 3, 2 voices, respectively, then InstrumentForVoice(0) returns 0, InstrumentForVoice(1) returns 1 and InstrumentForVoice(3) returns 1.
func (Patch) NumDelayLines ¶
NumDelayLines return the total number of delay lines used in the patch; summing the number of delay lines of every delay unit in every instrument
type Pattern ¶ added in v0.2.0
type Pattern []byte
Pattern represents a single pattern of note, in practice just a slice of bytes, but provides convenience functions that return 1 values (hold) for indices out of bounds of the array, and functions to increase the size of the slice only by necessary amount when a new item is added, filling the unused slots with 1s.
type Score ¶
type Score struct {
Tracks []Track
RowsPerPattern int // number of rows in each pattern
Length int // length of the song, in number of patterns
}
Score represents the arrangement of notes in a song; just a list of tracks and RowsPerPattern and Length (in patterns) to know the desired length of a song in rows. If any of the tracks is too short, all the notes outside the range should be just considered as holding the last note.
func (Score) FirstVoiceForTrack ¶
FirstVoiceForTrack returns the index of the first voice of given track. For example, if the Score has three tracks (0, 1 and 2), with 1, 3, 2 voices, respectively, then FirstVoiceForTrack(0) returns 0, FirstVoiceForTrack(1) returns 1 and FirstVoiceForTrack(2) returns 4. Essentially computes just the cumulative sum.
func (Score) LengthInRows ¶
LengthInRows returns just RowsPerPattern * Length, as the length is the length in the number of patterns.
type Song ¶
Song includes a Score (the arrangement of notes in the song in one or more tracks) and a Patch (the list of one or more instruments). Additionally, BPM and RowsPerBeat fields set how fast the song should be played. Currently, BPM is an integer as it offers already quite much granularity for controlling the playback speed, but this could be changed to a floating point in future if finer adjustments are necessary.
func (*Song) SamplesPerRow ¶
Assuming 44100 Hz playback speed, return the number of samples of each row of the song.
type SongPos ¶ added in v0.4.0
SongPos represents a position in a song, in terms of order row and pattern row. The order row is the index of the pattern in the order list, and the pattern row is the index of the row in the pattern.
type StackUse ¶ added in v0.5.0
type StackUse struct {
Inputs [][]int // Inputs documents which inputs contribute to which outputs. len(Inputs) is the number of inputs. Each input can contribute to multiple outputs, so its a slice.
Modifies []bool // Modifies documents which of the (mixed) inputs are actually modified by the unit
NumOutputs int // NumOutputs is the number of outputs produced by the unit. This is used to determine how many outputs are needed for the unit.
}
StackUse documents how a unit will affect the signal stack.
type Synth ¶
type Synth interface {
// Render tries to fill a stereo signal buffer with sound from the
// synthesizer, until either the buffer is full or a given number of
// timesteps is advanced. Normally, 1 sample = 1 unit of time, but speed
// modulations may change this. It returns the number of samples filled (in
// stereo samples i.e. number of elements of AudioBuffer filled), the
// number of sync outputs written, the number of time steps time advanced,
// and a possible error.
Render(buffer AudioBuffer, maxtime int) (sample int, time int, err error)
// Update recompiles a patch, but should maintain as much as possible of its
// state as reasonable. For example, filters should keep their state and
// delaylines should keep their content. Every change in the Patch triggers
// an Update and if the Patch would be started fresh every time, it would
// lead to very choppy audio.
Update(patch Patch, bpm int) error
// Trigger triggers a note for a given voice. Called between synth.Renders.
Trigger(voice int, note byte)
// Release releases the currently playing note for a given voice. Called
// between synth.Renders.
Release(voice int)
}
Synth represents a state of a synthesizer, compiled from a Patch.
type Synther ¶ added in v0.3.0
type Synther interface {
Name() string // Name of the synther, e.g. "Go" or "Native"
Synth(patch Patch, bpm int) (Synth, error)
}
Synther compiles a given Patch into a Synth, throwing errors if the Patch is malformed.
type Track ¶
type Track struct {
// NumVoices is the number of voices this track triggers, cycling through
// the voices. When this track triggers a new voice, the previous should be
// released.
NumVoices int
// Effect hints the GUI if this is more of an effect track than a note
// track: if true, e.g. the GUI can display the values as hexadecimals
// instead of note values.
Effect bool `yaml:",omitempty"`
// Order is a list telling which pattern comes in which order in the song in
// this track.
Order Order `yaml:",flow"`
// Patterns is a list of Patterns for this track.
Patterns []Pattern `yaml:",flow"`
}
Track represents the patterns and orderlist for each track. Note that each track has its own patterns, so one track cannot use another tracks patterns. This makes the data more intuitive to humans, as the reusing of patterns over tracks is a rather rare occurence. However, the compiler will put all the patterns in one global table (identical patterns only appearing once), to optimize the runtime code.
func (*Track) GetNumVoices ¶ added in v0.5.0
func (*Track) SetNote ¶ added in v0.4.0
SetNote sets the note at the given position. If uniquePatterns is true, the pattern is copied to a new pattern if the pattern is used by more than one order row.
func (*Track) SetNumVoices ¶ added in v0.5.0
type Unit ¶
type Unit struct {
// Type is the type of the unit, e.g. "add","oscillator" or "envelope".
// Always in lowercase. "" type should be ignored, no invalid types should
// be used.
Type string `yaml:",omitempty"`
// ID should be a unique ID for this unit, used by SEND units to target
// specific units. ID = 0 means that no ID has been given to a unit and thus
// cannot be targeted by SENDs. When possible, units that are not targeted
// by any SENDs should be cleaned from having IDs, e.g. to keep the exported
// data clean.
ID int `yaml:",omitempty"`
// Parameters is a map[string]int of parameters of a unit. For example, for
// an oscillator, unit.Type == "oscillator" and unit.Parameters["attack"]
// could be 64. Most parameters are either limites to 0 and 1 (e.g. stereo
// parameters) or between 0 and 128, inclusive.
Parameters ParamMap `yaml:",flow"`
// VarArgs is a list containing the variable number arguments that some
// units require, most notably the DELAY units. For example, for a DELAY
// unit, VarArgs is the delaytimes, in samples, of the different delaylines
// in the unit.
VarArgs []int `yaml:",flow,omitempty"`
// Disabled is a flag that can be set to true to disable the unit.
// Disabled units are considered to be not present in the patch.
Disabled bool `yaml:",omitempty"`
// Comment is a free-form comment about the unit that can be displayed
// instead of/besides the type of the unit in the GUI, to make it easier
// to track what the unit is doing & to make it easier to target sends.
Comment string `yaml:",omitempty"`
}
Unit is e.g. a filter, oscillator, envelope and its parameters
func (*Unit) StackChange ¶
StackChange returns how this unit will affect the signal stack. "pop" and "addp" and such will consume the topmost signal, and thus return -1 (or -2, if the unit is a stereo unit). On the other hand, "oscillator" and "envelope" will produce a signal, and thus return 1 (or 2, if the unit is a stereo unit). Effects that just change the topmost signal and will not change the number of signals on the stack and thus return 0.
type UnitParameter ¶
type UnitParameter struct {
Name string // thould be found with this name in the Unit.Parameters map
MinValue int // minimum value of the parameter, inclusive
MaxValue int // maximum value of the parameter, inclusive
Neutral int // neutral value of the parameter
CanSet bool // if this parameter can be set before hand i.e. through the gui
CanModulate bool // if this parameter can be modulated i.e. has a port number in "send" unit
DisplayFunc UnitParameterDisplayFunc
}
UnitParameter documents one parameter that an unit takes
func FindParamForModulationPort ¶ added in v0.5.0
func FindParamForModulationPort(unitName string, index int) (up UnitParameter, upIndex int, ok bool)
type UnitParameterDisplayFunc ¶ added in v0.5.0
Directories
¶
| Path | Synopsis |
|---|---|
|
sointu-compile
command
|
|
|
sointu-play
command
|
|
|
sointu-track
command
|
|
|
Package tracker contains the data model for the Sointu tracker GUI.
|
Package tracker contains the data model for the Sointu tracker GUI. |
|
Package vm implements a virtual machine based synthesizer that runs Sointu bytecode, and methods to convert patches into bytecode.
|
Package vm implements a virtual machine based synthesizer that runs Sointu bytecode, and methods to convert patches into bytecode. |
