Documentation
¶
Index ¶
- type ADSR
- func (adsr *ADSR) GetNextSample() float64
- func (adsr ADSR) GetSampleRate() uint
- func (adsr *ADSR) Reset()
- func (adsr *ADSR) SetAttackLength(attackMS uint)
- func (adsr *ADSR) SetDecayLength(decayMS uint)
- func (adsr *ADSR) SetReleaseLength(releaseMS uint)
- func (adsr *ADSR) SetSustain(value float64)
- func (adsr *ADSR) SetSustainLength(sustainMS uint)
- func (adsr *ADSR) TriggerRelease()
- type ADSRPhase
- type FlatModulation
- type LFO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ADSR ¶
type ADSR struct {
AttackCurve easing.Easing
DecayCurve easing.Easing
ReleaseCurve easing.Easing
ManualSustain bool // infinite sustain time when true
// contains filtered or unexported fields
}
TODO: need to rethink this so GetNextSample won't modify the object. For example make ADSR into a separate Envelope object and pass the currSample to the GetNextSample function.
func NewADSR ¶
NewADSR creates a new ADSR envelope. The sample rate is in Hz and can't be changed afterwards.
func (*ADSR) GetNextSample ¶
GetNextSample returns the next envelope value based on the ADSR settings.
func (ADSR) GetSampleRate ¶
GetSampleRate returns the sample rate with which the envelope was created.
func (*ADSR) SetAttackLength ¶
SetAttackLength sets the length of the attack phase in milliseconds.
func (*ADSR) SetDecayLength ¶
SetDecayLength sets the length of the decay phase in milliseconds.
func (*ADSR) SetReleaseLength ¶
SetReleaseLength Sets the release time. Use this if you want to trigger the release specifically with TriggerRelease.
func (*ADSR) SetSustain ¶
SetSustain sets the sustain value directly.
func (*ADSR) SetSustainLength ¶
SetSustainLength Sets the exact sustain time. Make sure you also set the release time! Use this when you know the length of the sound.
func (*ADSR) TriggerRelease ¶
func (adsr *ADSR) TriggerRelease()
TriggerRelease Start the release phase instatly when in sustain phase. Use SetReleaseLength in this case. Useful for triggering on MIDI key release.
type FlatModulation ¶
type FlatModulation struct {
// contains filtered or unexported fields
}
func NewFlatModulation ¶
func NewFlatModulation(sampleRate uint) *FlatModulation
NewFlatModulation creates a flat modulator which will always returns 0. Used for the
func (FlatModulation) GetNextSample ¶
func (fm FlatModulation) GetNextSample() float64
func (FlatModulation) GetSampleRate ¶
func (fm FlatModulation) GetSampleRate() uint
func (*FlatModulation) Reset ¶
func (fm *FlatModulation) Reset()
type LFO ¶
type LFO struct {
Generator generator.FunctionGenerator
Deviation float64 // a multiplyer for the sample
}
func NewLFO ¶
NewLFO creates a new function generator that can be used as a low frequency oscillator. The sample rate is in Hz and can't be changed afterwards.
func (LFO) GetNextSample ¶
GetNextSample returns the next sample from the generator multiplied by the Deviation.
func (LFO) GetSampleRate ¶
GetSampleRate returns the sample rate the function generator is set to.