Source Academy Modules
    Preparing search index...

    Function stacking_adsr

    • Returns a Sound that results from applying a list of envelopes to a given wave form. The wave form is a Sound generator that takes a frequency and a duration as arguments and produces a Sound with the given frequency and duration. Each envelope is applied to a harmonic: the first harmonic has the given frequency, the second has twice the frequency, the third three times the frequency etc. The harmonics are then layered simultaneously to produce the resulting Sound.

      Parameters

      • waveform: SoundProducer

        function from pair(frequency, duration) to Sound

      • base_frequency: number

        frequency of the first harmonic

      • duration: number

        duration of the produced Sound, in seconds

      • envelopes: List

        – list of envelopes, which are functions from Sound to Sound

      Returns Sound

      Sound resulting Sound

      stacking_adsr(sine_sound, 300, 5, list(adsr(0.1, 0.3, 0.2, 0.5), adsr(0.2, 0.5, 0.6, 0.1), adsr(0.3, 0.1, 0.7, 0.3)));