modulator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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

func NewADSR(sampleRate uint) *ADSR

NewADSR creates a new ADSR envelope. The sample rate is in Hz and can't be changed afterwards.

func (*ADSR) GetNextSample

func (adsr *ADSR) GetNextSample() float64

GetNextSample returns the next envelope value based on the ADSR settings.

func (ADSR) GetSampleRate

func (adsr ADSR) GetSampleRate() uint

GetSampleRate returns the sample rate with which the envelope was created.

func (*ADSR) Reset

func (adsr *ADSR) Reset()

Reset will set the

func (*ADSR) SetAttackLength

func (adsr *ADSR) SetAttackLength(attackMS uint)

SetAttackLength sets the length of the attack phase in milliseconds.

func (*ADSR) SetDecayLength

func (adsr *ADSR) SetDecayLength(decayMS uint)

SetDecayLength sets the length of the decay phase in milliseconds.

func (*ADSR) SetReleaseLength

func (adsr *ADSR) SetReleaseLength(releaseMS uint)

SetReleaseLength Sets the release time. Use this if you want to trigger the release specifically with TriggerRelease.

func (*ADSR) SetSustain

func (adsr *ADSR) SetSustain(value float64)

SetSustain sets the sustain value directly.

func (*ADSR) SetSustainLength

func (adsr *ADSR) SetSustainLength(sustainMS uint)

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 ADSRPhase

type ADSRPhase int
const (
	Attack ADSRPhase = iota
	Decay
	Sustain
	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

func NewLFO(sampleRate uint) *LFO

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

func (lfo LFO) GetNextSample() float64

GetNextSample returns the next sample from the generator multiplied by the Deviation.

func (LFO) GetSampleRate

func (lfo LFO) GetSampleRate() uint

GetSampleRate returns the sample rate the function generator is set to.

func (*LFO) Reset

func (lfo *LFO) Reset()

Reset simply resets the generator for the LFO.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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