ADSR_envelope Derived Type

type, public :: ADSR_envelope


Components

Type Visibility Attributes Name Initial
real(kind=wp), public :: attack = 30.0_wp

A D S R /\ / ____ / \ / \ https://en.wikipedia.org/wiki/Envelope_(music) Default parameters of the ADSR envelope:

real(kind=wp), public :: decay = 20.0_wp
real(kind=wp), public :: release = 30.0_wp
real(kind=wp), public :: sustain = 80.0_wp

Type-Bound Procedures

procedure, public :: get_level => ADSR_level

  • private pure function ADSR_level(self, t, t1, t2)

    Returns the level in [0, 1] of the ADSR envelope at time t1 < t < t2

    Arguments

    Type IntentOptional Attributes Name
    class(ADSR_envelope), intent(in) :: self
    real(kind=wp), intent(in) :: t
    real(kind=wp), intent(in) :: t1
    real(kind=wp), intent(in) :: t2

    Return Value real(kind=wp)

procedure, public :: new => ADSR_new

  • private subroutine ADSR_new(self, A, D, S, R)

    Arguments

    Type IntentOptional Attributes Name
    class(ADSR_envelope), intent(inout) :: self
    real(kind=wp), intent(in) :: A
    real(kind=wp), intent(in) :: D
    real(kind=wp), intent(in) :: S
    real(kind=wp), intent(in) :: R

Source Code

    type ADSR_envelope
        !> A   D S   R
        !>    /\
        !>   /  \____
        !>  /        \
        !> /          \
        !> https://en.wikipedia.org/wiki/Envelope_(music)
        !> Default parameters of the ADSR envelope:
        real(wp) :: attack  = 30.0_wp      ! duration %
        real(wp) :: decay   = 20.0_wp      ! duration %
        real(wp) :: sustain = 80.0_wp      ! max level %
        real(wp) :: release = 30.0_wp      ! duration %
    contains
        procedure :: new => ADSR_new
        procedure :: get_level => ADSR_level
    end type ADSR_envelope