flowlang-cc / elm-audio-graph / AudioGraph.Units

The value of an AudioParam or NodeProperty is highly context relevant. Something that is expecting frequency in hertz may produce very unexpected output if it receives a decibal value, even though they both represent Floats. To encode this context the Value union type defines all the possible contexts for primative types to exist in.


type Value
    = Attribute Basics.Bool
    | Buffer (List Basics.Float)
    | Coefficients (List Basics.Float)
    | Cents Basics.Float
    | Decibels Basics.Float
    | DistanceModelType DistanceModel
    | FilterType Filter
    | FFT_Size Basics.Int
    | Hertz Basics.Float
    | MIDI_Note Basics.Int
    | MIDI_CC Basics.Int
    | OversampleType Oversample
    | PanningModelType PanningModel
    | WaveformType Waveform
    | WaveshaperCurve (List Basics.Float)
    | Number Basics.Float

Union Types

Some values, such as WaveformType are better expressed as their own union type, rather than arbitrary string values.


type DistanceModel
    = Linear
    | Inverse
    | Exponential


type Filter
    = Lowpass
    | Highpass
    | Bandpass
    | Lowshelf
    | Highshelf
    | Peaking
    | Notch
    | Allpass


type Oversample
    = None
    | TwoX
    | FourX


type PanningModel
    = EqualPower
    | HRTF


type Waveform
    = Sine
    | Triangle
    | Sawtooth
    | Square