Klang C++
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 signaloutput () const
 
TYPE & operator>> (TYPE &destination)
 
signal operator+ (TYPE &other)
 
signal operator* (TYPE &other)
 
signal operator- (TYPE &other)
 
signal operator/ (TYPE &other)
 

Public Attributes

float target
 
float rate
 
bool active = false
 
signal out
 

Detailed Description

Definition at line 2668 of file klang.h.

Member Function Documentation

◆ isActive()

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

Definition at line 2638 of file klang.h.

2638 {
2639 return active;
2640 }

References klang::Envelope::Ramp::active.

Referenced by klang::Envelope::operator++().

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

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

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

Definition at line 1416 of file klang.h.

1416{ 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 1415 of file klang.h.

1415{ process(); return out; } // return processed output

◆ operator()()

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

Definition at line 1409 of file klang.h.

1409 {
1410 set(p...); return *this;
1411 }

◆ operator*()

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

Definition at line 1372 of file klang.h.

1372{ process(); return out * (other); }

◆ operator+()

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

Definition at line 1371 of file klang.h.

1371{ process(); return out + (other); }

◆ operator++()

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

Implements klang::Envelope::Ramp.

Definition at line 2671 of file klang.h.

2671 {
2672 const signal output = out;
2673
2674 if (active) {
2675 if (target > out) {
2676 out += rate;
2677 if (out >= target) {
2678 out = target;
2679 active = false;
2680 }
2681 }
2682 else {
2683 out -= rate;
2684 if (out <= target) {
2685 out = target;
2686 active = false;
2687 }
2688 }
2689 }
2690
2691 return output;
2692 }
signals< 2 > signal
Stereo audio signal.
Definition klang.h:3308
virtual const signal & output() const
Definition klang.h:1360

References klang::Envelope::Ramp::active, klang::signal::operator+=(), klang::signal::operator-=(), klang::Envelope::Ramp::rate, and klang::Envelope::Ramp::target.

◆ operator-()

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

Definition at line 1373 of file klang.h.

1373{ process(); return out - (other); }

◆ operator/()

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

Definition at line 1374 of file klang.h.

1374{ process(); return out / (other); }

◆ operator>>()

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

Definition at line 1364 of file klang.h.

1364{ process(); return destination = out; }

◆ output()

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

Definition at line 1360 of file klang.h.

1360{ return out; }

◆ process()

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

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

Definition at line 2664 of file klang.h.

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

◆ setRate()

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

Definition at line 2656 of file klang.h.

2656{ Ramp::rate = rate; }

References klang::Envelope::Ramp::rate.

Referenced by klang::Envelope::setTargetRate(), and klang::Envelope::setTargetTime().

◆ setTarget()

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

◆ setTime()

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

Definition at line 2659 of file klang.h.

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

References klang::Envelope::Ramp::rate.

Referenced by klang::Envelope::Ramp::Ramp().

◆ setValue()

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

Member Data Documentation

◆ active

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

◆ out

Definition at line 1357 of file klang.h.

1357{ 0.f };

◆ rate

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

◆ target

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