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

A mono audio signal (equivalent to a float). More...

#include <klang.h>

+ Inheritance diagram for klang::signal:

Public Member Functions

 signal (constant initial)
 Create signal from a constant.
 
 signal (const float initial=0.f)
 Create signal from a 32-bit float..
 
 signal (const double initial)
 Create signal from a 64-bit double.
 
 signal (const int value)
 Create signal from an 32-bit signed integer.
 
const signaloperator<< (const signal &input)
 Feedback operator (prevents further processing of returned value).
 
signaloperator>> (signal &destination) const
 Stream operator (feedforward; allows further processing)
 
signaloperator= (Output &in)
 Assign processed output of in to signal.
 
signaloperator+= (Output &in)
 Adds processed output of in to signal.
 
signaloperator+= (const signal &x)
 Add (mix) another signal to the signal.
 
signaloperator-= (const signal &x)
 Subtract another signal from the signal.
 
signaloperator*= (const signal &x)
 Multiply (modulate) signal by another signal.
 
signaloperator/= (const signal &x)
 Divide signal by another signal.
 
signaloperator+= (float x)
 Add the specified amount to the signal.
 
signaloperator-= (float x)
 Subtract the specified amount from the signal.
 
signaloperator*= (float x)
 Multiply signal by the specified amount.
 
signaloperator/= (float x)
 Divide signal by the specified amount.
 
signaloperator+= (double x)
 Add the specified amount to the signal.
 
signaloperator-= (double x)
 Subtract the specified amount from the signal.
 
signaloperator*= (double x)
 Multiply signal by the specified amount.
 
signaloperator/= (double x)
 Divide signal by the specified amount.
 
signaloperator+= (int x)
 Add the specified amount to the signal.
 
signaloperator-= (int x)
 Subtract the specified amount from the signal.
 
signaloperator*= (int x)
 Multiply 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- (float x) const
 Subtract one signal from another.
 
signal operator* (float x) const
 Multiply (modulate) two signals.
 
signal operator/ (float x) const
 Divide one signal by another.
 
signal operator+ (double x) const
 Return a copy of the signal offset by x.
 
signal operator- (double x) const
 Return a copy of the signal offset by -x.
 
signal operator* (double x) const
 Return a copy of the signal scaled by x.
 
signal operator/ (double x) const
 Return a copy of the signal divided by.
 
signal operator+ (int 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* (int x) const
 Return a copy of the signal scaled by x.
 
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 operator+ () const
 Returns a copy of the signal to treat as a relative offset (e.g. for phase modulation).
 
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 362 of file klang.h.

Constructor & Destructor Documentation

◆ signal() [1/4]

klang::signal::signal ( constant initial)
inline

Definition at line 366 of file klang.h.

366: value(initial.f) { }
float value
Definition klang.h:363

References klang::constant::f, and value.

◆ signal() [2/4]

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

◆ signal() [3/4]

klang::signal::signal ( const double initial)
inline

Definition at line 372 of file klang.h.

372: value((const float)initial) { }

References value.

◆ signal() [4/4]

klang::signal::signal ( const int value)
inline

Definition at line 375 of file klang.h.

375: value((const float)value) { }

References value.

Member Function Documentation

◆ channels()

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

Definition at line 474 of file klang.h.

474{ return 1; }

◆ isDenormal()

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

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 }

References value.

◆ operator const float()

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

Definition at line 464 of file klang.h.

464{ return value; }

References value.

◆ operator float &()

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

Definition at line 465 of file klang.h.

465{ return value; }

References value.

◆ operator*() [1/3]

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

Definition at line 444 of file klang.h.

444{ return value * (float)x; }

References value.

◆ operator*() [2/3]

◆ operator*() [3/3]

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

Definition at line 453 of file klang.h.

453{ return value * (float)x; }

References value.

◆ operator*=() [1/4]

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

Definition at line 399 of file klang.h.

399{ value *= x.value; return *this; }

References value.

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

◆ operator*=() [2/4]

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

Definition at line 417 of file klang.h.

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

References value.

◆ operator*=() [3/4]

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

◆ operator*=() [4/4]

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

Definition at line 426 of file klang.h.

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

References value.

◆ operator+() [1/4]

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

Definition at line 490 of file klang.h.

490{ return { value }; }

References value.

◆ operator+() [2/4]

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

Definition at line 440 of file klang.h.

440{ return value + (float)x; }

References value.

◆ operator+() [3/4]

◆ operator+() [4/4]

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

Definition at line 449 of file klang.h.

449{ return value + (float)x; }

References value.

◆ operator+=() [1/5]

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

Definition at line 395 of file klang.h.

395{ value += x.value; return *this; }

References value.

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

◆ operator+=() [2/5]

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

Definition at line 413 of file klang.h.

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

References value.

◆ operator+=() [3/5]

signal & klang::signal::operator+= ( float x)
inline

◆ operator+=() [4/5]

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

Definition at line 422 of file klang.h.

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

References value.

◆ operator+=() [5/5]

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

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 value.

◆ operator-() [1/3]

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

Definition at line 442 of file klang.h.

442{ return value - (float)x; }

References value.

◆ operator-() [2/3]

◆ operator-() [3/3]

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

Definition at line 451 of file klang.h.

451{ return value - (float)x; }

References value.

◆ operator-=() [1/4]

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

Definition at line 397 of file klang.h.

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

References 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)
inline

Definition at line 415 of file klang.h.

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

References value.

◆ operator-=() [3/4]

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

◆ operator-=() [4/4]

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

Definition at line 424 of file klang.h.

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

References value.

◆ operator/() [1/3]

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

Definition at line 446 of file klang.h.

446{ return value / (float)x; }

References value.

◆ operator/() [2/3]

◆ operator/() [3/3]

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

Definition at line 455 of file klang.h.

455{ return value / (float)x; }

References value.

◆ operator/=() [1/4]

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

Definition at line 401 of file klang.h.

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

References 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)
inline

Definition at line 419 of file klang.h.

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

References value.

◆ operator/=() [3/4]

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

◆ operator/=() [4/4]

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

Definition at line 428 of file klang.h.

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

References value.

◆ operator<<()

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

Definition at line 378 of file klang.h.

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

References value.

◆ operator=()

signal & klang::signal::operator= ( Output & in)
inline

Definition at line 2149 of file klang.h.

2149 {
2150 b >> *this;
2151 return *this;
2152 }

◆ operator>>()

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

Definition at line 384 of file klang.h.

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

References value.

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

◆ operator^() [1/3]

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

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 value.

◆ operator^() [2/3]

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

Definition at line 458 of file klang.h.

458{ return power(value, x); }

References klang::power(), and value.

◆ operator^() [3/3]

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

Definition at line 462 of file klang.h.

462{ return power(value, x); }

References klang::power(), and value.

◆ relative()

relative klang::signal::relative ( ) const
inline

Definition at line 492 of file klang.h.

492{ return { value }; }

References value.

Member Data Documentation

◆ value