Klang C++ 0.7.15
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Envelope::Linear

Linear envelope ramp (default) More...

#include <klang.h>

+ Inheritance diagram for klang::Envelope::Linear:

Public Member Functions

signal operator++ (int) override
 
bool isActive () const
 
virtual void setTarget (float target)
 
virtual void setValue (float value)
 
virtual void setRate (float rate)
 
virtual void setTime (float time)
 
void process () override
 
Output< signal > & operator() (params &&... p)
 
 operator const signal & () override
 
 operator const signal & () const override
 
virtual const signal & output () const
 
TYPE & operator>> (TYPE &destination)
 
signal operator+ (TYPE &other)
 
signal operator* (TYPE &other)
 
signal operator- (TYPE &other)
 
signal operator/ (TYPE &other)
 
void reset ()
 

Public Attributes

float target
 
float rate
 
bool active = false
 
signal out
 

Detailed Description

Definition at line 5100 of file klang.h.

Member Function Documentation

◆ isActive()

bool klang::Envelope::Ramp::isActive ( ) const
inlineinherited

Definition at line 5070 of file klang.h.

5070 {
5071 return active;
5072 }

◆ operator const signal &() [1/2]

klang::Generic::Generator< signal >::operator const signal & ( ) const
inlineoverridevirtualinherited

Reimplemented from klang::Generic::Output< signal >.

Definition at line 3057 of file klang.h.

3057{ return out; } // return last output

◆ operator const signal &() [2/2]

klang::Generic::Generator< signal >::operator const signal & ( )
inlineoverridevirtualinherited

Reimplemented from klang::Generic::Output< signal >.

Definition at line 3056 of file klang.h.

3056{ this->process(); return out; } // return processed output

◆ operator()()

Output< signal > & klang::Generic::Generator< signal >::operator() ( params &&... p)
inlineinherited

Definition at line 3050 of file klang.h.

3050 {
3051 set(std::forward<params>(p)...); return *this;
3052 }

◆ operator*()

signal klang::Generic::Output< signal >::operator* ( TYPE & other)
inlineinherited

Definition at line 2977 of file klang.h.

2977{ this->process(); return out * SIGNAL(other); }

◆ operator+()

signal klang::Generic::Output< signal >::operator+ ( TYPE & other)
inlineinherited

Definition at line 2976 of file klang.h.

2976{ this->process(); return out + SIGNAL(other); }

◆ operator++()

signal klang::Envelope::Linear::operator++ ( int )
inlineoverridevirtual

Implements klang::Envelope::Ramp.

Definition at line 5103 of file klang.h.

5103 {
5104 const signal output = out;
5105
5106 if (active) {
5107 if (target > out) {
5108 out += rate;
5109 if (out >= target) {
5110 out = target;
5111 active = false;
5112 }
5113 }
5114 else {
5115 out -= rate;
5116 if (out <= target) {
5117 out = target;
5118 active = false;
5119 }
5120 }
5121 }
5122
5123 return output;
5124 }
signals< 2 > signal
Stereo audio signal.
Definition klang.h:5840
virtual const signal & output() const
Definition klang.h:2964

◆ operator-()

signal klang::Generic::Output< signal >::operator- ( TYPE & other)
inlineinherited

Definition at line 2978 of file klang.h.

2978{ this->process(); return out - SIGNAL(other); }

◆ operator/()

signal klang::Generic::Output< signal >::operator/ ( TYPE & other)
inlineinherited

Definition at line 2979 of file klang.h.

2979{ this->process(); return out / SIGNAL(other); }

◆ operator>>()

TYPE & klang::Generic::Output< signal >::operator>> ( TYPE & destination)
inlineinherited

Definition at line 2969 of file klang.h.

2969{ this->process(); return destination = out; }

◆ output()

virtual const signal & klang::Generic::Output< signal >::output ( ) const
inlinevirtualinherited

Definition at line 2964 of file klang.h.

2964{ return out; }

◆ process()

void klang::Envelope::Ramp::process ( )
inlineoverridevirtualinherited

Implements klang::Generic::Output< signal >.

Definition at line 5096 of file klang.h.

5096{ /* do nothing -> only process on ++ */ }

◆ reset()

void klang::Generic::Output< signal >::reset ( )
inlineinherited

Definition at line 2981 of file klang.h.

2981{ out = 0; }

◆ setRate()

virtual void klang::Envelope::Ramp::setRate ( float rate)
inlinevirtualinherited

Definition at line 5088 of file klang.h.

5088{ Ramp::rate = rate; }

◆ setTarget()

virtual void klang::Envelope::Ramp::setTarget ( float target)
inlinevirtualinherited

Definition at line 5075 of file klang.h.

5075 {
5077 active = (out != target);
5078 }

◆ setTime()

virtual void klang::Envelope::Ramp::setTime ( float time)
inlinevirtualinherited

Definition at line 5091 of file klang.h.

5091{ Ramp::rate = time ? 1.f / (time * fs) : 0; }
klang::dB fs

◆ setValue()

virtual void klang::Envelope::Ramp::setValue ( float value)
inlinevirtualinherited

Definition at line 5081 of file klang.h.

5081 {
5082 out = value;
5083 Ramp::target = value;
5084 active = false;
5085 }

Member Data Documentation

◆ active

bool klang::Envelope::Ramp::active = false
inherited

Definition at line 5052 of file klang.h.

◆ out

Definition at line 2961 of file klang.h.

2961{ 0.f };

◆ rate

float klang::Envelope::Ramp::rate
inherited

Definition at line 5051 of file klang.h.

◆ target

float klang::Envelope::Ramp::target
inherited

Definition at line 5050 of file klang.h.