Klang C++
Language Reference (draft)
Loading...
Searching...
No Matches
klang::Phase

Control parameter (phase) More...

#include <klang.h>

+ Inheritance diagram for klang::Phase:

Public Member Functions

paramoperator+= (float increment)
 
paramoperator+= (const increment &increment)
 
Phase operator+ (const increment &increment) const
 
Phase operator% (float modulus)
 
 param (constant in)
 
 param (const float initial=0.f)
 
 param (const signal &in)
 
 param (signal &in)
 
 param (Control &in)
 
signaloperator+= (Output &in)
 Adds processed output of in to signal.
 
signaloperator+= (const signal &x)
 Add (mix) another signal to the signal.
 
signaloperator+= (double x)
 Add the specified amount to the signal.
 
signaloperator+= (int x)
 Add the specified amount to the signal.
 
const signaloperator<< (const signal &input)
 Feedback operator (prevents further processing of returned value).
 
signaloperator>> (signal &destination) const
 Stream operator (feedforward; allows further processing)
 
signaloperator-= (const signal &x)
 Subtract another signal from the signal.
 
signaloperator-= (float x)
 Subtract the specified amount from the signal.
 
signaloperator-= (double x)
 Subtract the specified amount from the signal.
 
signaloperator-= (int x)
 Subtract the specified amount from the signal.
 
signaloperator*= (const signal &x)
 Multiply (modulate) signal by another signal.
 
signaloperator*= (float x)
 Multiply signal by the specified amount.
 
signaloperator*= (double x)
 Multiply signal by the specified amount.
 
signaloperator*= (int x)
 Multiply signal by the specified amount.
 
signaloperator/= (const signal &x)
 Divide signal by another signal.
 
signaloperator/= (float x)
 Divide signal by the specified amount.
 
signaloperator/= (double x)
 Divide signal by the specified amount.
 
signaloperator/= (int x)
 Divide signal by the specified amount.
 
signal operator+ (float x) const
 Add two signals together.
 
signal operator+ (double x) const
 Return a copy of the signal offset by x.
 
signal operator+ (int x) const
 Return a copy of the signal offset by x.
 
relative operator+ () const
 Returns a copy of the signal to treat as a relative offset (e.g. for phase modulation).
 
signal operator- (float x) const
 Subtract one signal from another.
 
signal operator- (double x) const
 Return a copy of the signal offset by -x.
 
signal operator- (int x) const
 Return a copy of the signal offset by -x.
 
signal operator* (float x) const
 Multiply (modulate) two signals.
 
signal operator* (double x) const
 Return a copy of the signal scaled by x.
 
signal operator* (int x) const
 Return a copy of the signal scaled by x.
 
signal operator/ (float x) const
 Divide one signal by another.
 
signal operator/ (double x) const
 Return a copy of the signal divided by.
 
signal operator/ (int x) const
 Return a copy of the signal divided by x.
 
signal operator^ (float x) const
 Return a copy of the signal raised to the power of x.
 
signal operator^ (double x) const
 Return a copy of the signal raised to the power of x.
 
signal operator^ (int x) const
 Return a copy of the signal raised to the power of x.
 
 operator const float () const
 
 operator float & ()
 
bool isDenormal () const
 Check if the signal contains a denormal value.
 
int channels () const
 Returns the number of channels (1 = mono).
 
relative relative () const
 Returns a copy of the signal to treat as a relative offset (e.g. for phase modulation).
 

Public Attributes

float value
 

Detailed Description

Definition at line 811 of file klang.h.

Member Function Documentation

◆ channels()

int klang::signal::channels ( ) const
inlineinherited

Definition at line 474 of file klang.h.

474{ return 1; }

◆ isDenormal()

bool klang::signal::isDenormal ( ) const
inlineinherited

Definition at line 468 of file klang.h.

468 {
469 const unsigned int bits = *(const unsigned int*)&value;
470 return !(bits & 0x7F800000) && (bits & 0x007FFFFF);
471 }
float value
Definition klang.h:363

References klang::signal::value.

◆ operator const float()

klang::signal::operator const float ( ) const
inlineinherited

Definition at line 464 of file klang.h.

464{ return value; }

References klang::signal::value.

◆ operator float &()

klang::signal::operator float & ( )
inlineinherited

Definition at line 465 of file klang.h.

465{ return value; }

References klang::signal::value.

◆ operator%()

Phase klang::Phase::operator% ( float modulus)
inline

Definition at line 843 of file klang.h.

843 {
844 return fast_mod(value, modulus);
845 }
float fast_mod(float x, float y)
Definition klang.h:697

References klang::fast_mod(), and klang::signal::value.

◆ operator*() [1/3]

signal klang::signal::operator* ( double x) const
inlineinherited

Definition at line 444 of file klang.h.

444{ return value * (float)x; }

References klang::signal::value.

◆ operator*() [2/3]

◆ operator*() [3/3]

signal klang::signal::operator* ( int x) const
inlineinherited

Definition at line 453 of file klang.h.

453{ return value * (float)x; }

References klang::signal::value.

◆ operator*=() [1/4]

signal & klang::signal::operator*= ( const signal & x)
inlineinherited

◆ operator*=() [2/4]

signal & klang::signal::operator*= ( double x)
inlineinherited

Definition at line 417 of file klang.h.

417{ value *= (float)x; return *this; }

References klang::signal::value.

◆ operator*=() [3/4]

signal & klang::signal::operator*= ( float x)
inlineinherited

◆ operator*=() [4/4]

signal & klang::signal::operator*= ( int x)
inlineinherited

Definition at line 426 of file klang.h.

426{ value *= (float)x; return *this; }

References klang::signal::value.

◆ operator+() [1/5]

Phase klang::Phase::operator+ ( const increment & increment) const
inline

Definition at line 834 of file klang.h.

834 {
835 if (increment.amount >= increment.size)
836 return value;
837 Phase value = Phase::value + increment.amount;
838 if (value > increment.size)
839 value -= increment.size;
840 return value;
841 }

References klang::increment::amount, klang::signal::operator-=(), klang::increment::size, and klang::signal::value.

◆ operator+() [2/5]

relative klang::signal::operator+ ( ) const
inlineinherited

Definition at line 490 of file klang.h.

490{ return { value }; }

References klang::signal::value.

◆ operator+() [3/5]

signal klang::signal::operator+ ( double x) const
inlineinherited

Definition at line 440 of file klang.h.

440{ return value + (float)x; }

References klang::signal::value.

◆ operator+() [4/5]

◆ operator+() [5/5]

signal klang::signal::operator+ ( int x) const
inlineinherited

Definition at line 449 of file klang.h.

449{ return value + (float)x; }

References klang::signal::value.

◆ operator+=() [1/6]

param & klang::Phase::operator+= ( const increment & increment)
inline

Definition at line 825 of file klang.h.

825 {
826 if (increment.amount >= increment.size)
827 return *this;
828 value += increment.amount;
829 if (value > increment.size)
830 value -= increment.size;
831 return *this;
832 }

References klang::increment::amount, klang::increment::size, and klang::signal::value.

Referenced by klang::Wavetable::process().

◆ operator+=() [2/6]

param & klang::Phase::operator+= ( float increment)
inline

Definition at line 816 of file klang.h.

816 {
817 if (increment >= (2 * pi))
818 return *this;
819 value += increment;
820 if (value > (2 * pi))
821 value -= (2 * pi);
822 return *this;
823 }
constexpr constant pi
The mathematical constant, pi (and it's inverse).
Definition klang.h:218

References klang::pi, and klang::signal::value.

Referenced by klang::Generators::Basic::Pulse::process(), klang::Generators::Basic::Saw::process(), klang::Generators::Basic::Sine::process(), klang::Generators::Basic::Square::process(), and klang::Generators::Basic::Triangle::process().

◆ operator+=() [3/6]

signal & klang::signal::operator+= ( const signal & x)
inlineinherited

◆ operator+=() [4/6]

signal & klang::signal::operator+= ( double x)
inlineinherited

Definition at line 413 of file klang.h.

413{ value += (float)x; return *this; }

References klang::signal::value.

◆ operator+=() [5/6]

signal & klang::signal::operator+= ( int x)
inlineinherited

Definition at line 422 of file klang.h.

422{ value += (float)x; return *this; }

References klang::signal::value.

◆ operator+=() [6/6]

signal & klang::signal::operator+= ( Output & in)
inlineinherited

Definition at line 2155 of file klang.h.

2155 { // e.g. out += osc;
2156 value += signal(in);
2157 return *this;
2158 }
signal(constant initial)
Create signal from a constant.
Definition klang.h:366

References klang::signal::value.

◆ operator-() [1/3]

signal klang::signal::operator- ( double x) const
inlineinherited

Definition at line 442 of file klang.h.

442{ return value - (float)x; }

References klang::signal::value.

◆ operator-() [2/3]

◆ operator-() [3/3]

signal klang::signal::operator- ( int x) const
inlineinherited

Definition at line 451 of file klang.h.

451{ return value - (float)x; }

References klang::signal::value.

◆ operator-=() [1/4]

signal & klang::signal::operator-= ( const signal & x)
inlineinherited

Definition at line 397 of file klang.h.

397{ value -= x.value; return *this; }

References klang::signal::value.

Referenced by klang::Stereo::frame::operator-=(), klang::Stereo::frame::operator-=(), and klang::Stereo::frame::operator-=().

◆ operator-=() [2/4]

signal & klang::signal::operator-= ( double x)
inlineinherited

Definition at line 415 of file klang.h.

415{ value -= (float)x; return *this; }

References klang::signal::value.

◆ operator-=() [3/4]

signal & klang::signal::operator-= ( float x)
inlineinherited

◆ operator-=() [4/4]

signal & klang::signal::operator-= ( int x)
inlineinherited

Definition at line 424 of file klang.h.

424{ value -= (float)x; return *this; }

References klang::signal::value.

◆ operator/() [1/3]

signal klang::signal::operator/ ( double x) const
inlineinherited

Definition at line 446 of file klang.h.

446{ return value / (float)x; }

References klang::signal::value.

◆ operator/() [2/3]

◆ operator/() [3/3]

signal klang::signal::operator/ ( int x) const
inlineinherited

Definition at line 455 of file klang.h.

455{ return value / (float)x; }

References klang::signal::value.

◆ operator/=() [1/4]

signal & klang::signal::operator/= ( const signal & x)
inlineinherited

Definition at line 401 of file klang.h.

401{ value /= x.value; return *this; }

References klang::signal::value.

Referenced by klang::Stereo::frame::operator/=(), klang::Stereo::frame::operator/=(), and klang::Stereo::frame::operator/=().

◆ operator/=() [2/4]

signal & klang::signal::operator/= ( double x)
inlineinherited

Definition at line 419 of file klang.h.

419{ value /= (float)x; return *this; }

References klang::signal::value.

◆ operator/=() [3/4]

signal & klang::signal::operator/= ( float x)
inlineinherited

◆ operator/=() [4/4]

signal & klang::signal::operator/= ( int x)
inlineinherited

Definition at line 428 of file klang.h.

428{ value /= (float)x; return *this; }

References klang::signal::value.

◆ operator<<()

const signal & klang::signal::operator<< ( const signal & input)
inlineinherited

Definition at line 378 of file klang.h.

378 {
379 value = input;
380 return *this;
381 }

References klang::signal::value.

◆ operator>>()

signal & klang::signal::operator>> ( signal & destination) const
inlineinherited

Definition at line 384 of file klang.h.

384 {
385 destination.value = value;
386 return destination;
387 }

References klang::signal::value.

Referenced by klang::Envelope::Follower::AR::process().

◆ operator^() [1/3]

signal klang::signal::operator^ ( double x) const
inlineinherited

Definition at line 460 of file klang.h.

460{ return power(value, x); }
constexpr power_t< BASE, EXP > power(BASE base, EXP exp)
Raise base to the power exp.
Definition klang.h:150

References klang::power(), and klang::signal::value.

◆ operator^() [2/3]

signal klang::signal::operator^ ( float x) const
inlineinherited

Definition at line 458 of file klang.h.

458{ return power(value, x); }

References klang::power(), and klang::signal::value.

◆ operator^() [3/3]

signal klang::signal::operator^ ( int x) const
inlineinherited

Definition at line 462 of file klang.h.

462{ return power(value, x); }

References klang::power(), and klang::signal::value.

◆ param() [1/5]

klang::param::param ( const float initial = 0.f)
inline

Definition at line 659 of file klang.h.

659: signal(initial) { }

◆ param() [2/5]

klang::param::param ( const signal & in)
inline

Definition at line 660 of file klang.h.

660: signal(in) { }

◆ param() [3/5]

klang::param::param ( constant in)
inline

Definition at line 658 of file klang.h.

658: signal(in.f) { }

◆ param() [4/5]

klang::param::param ( Control & in)
inline

Definition at line 662 of file klang.h.

1061: signal(in.value) { }

◆ param() [5/5]

klang::param::param ( signal & in)
inline

Definition at line 661 of file klang.h.

661: signal(in) { }

◆ relative()

relative klang::signal::relative ( ) const
inlineinherited

Definition at line 492 of file klang.h.

492{ return { value }; }

References klang::signal::value.

Member Data Documentation

◆ value

float klang::signal::value
inherited

Definition at line 363 of file klang.h.

Referenced by klang::Amplitude::Amplitude(), klang::signal::signal(), klang::signal::signal(), klang::signal::signal(), klang::signal::signal(), klang::signal::isDenormal(), klang::signal::operator const float(), klang::Control::operator float(), klang::signal::operator float &(), operator%(), klang::signal::operator*(), klang::signal::operator*(), klang::signal::operator*(), klang::signal::operator*=(), klang::signal::operator*=(), klang::signal::operator*=(), klang::signal::operator*=(), operator+(), klang::signal::operator+(), klang::signal::operator+(), klang::signal::operator+(), klang::signal::operator+(), klang::param::operator+=(), operator+=(), operator+=(), klang::signal::operator+=(), klang::signal::operator+=(), klang::signal::operator+=(), klang::signal::operator+=(), klang::signal::operator+=(), klang::signal::operator-(), klang::signal::operator-(), klang::signal::operator-(), klang::signal::operator-=(), klang::signal::operator-=(), klang::signal::operator-=(), klang::signal::operator-=(), klang::Amplitude::operator->(), klang::dB::operator->(), klang::Pitch::operator->(), klang::signal::operator/(), klang::signal::operator/(), klang::signal::operator/(), klang::signal::operator/=(), klang::signal::operator/=(), klang::signal::operator/=(), klang::signal::operator/=(), klang::signal::operator<<(), klang::signal::operator>>(), klang::signal::operator^(), klang::signal::operator^(), klang::signal::operator^(), klang::signal::relative(), and klang::Pitch::text().