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

Language Guide / Signal Flow

relative

klang::relative

A value expressed relative to a complete unit.

An overload that accepts relative interprets the value according to the object. For the standard oscillator phase-offset setter, 1 represents a whole cycle and 0.25 represents a quarter cycle. Unary + on a Klang value such as a signal selects the relative form. Apply it to a named value to write +phase inline.

Example ยท Offset an oscillator by a quarter cycle

const signal phase = 0.25;
sine.set(440, +phase);

A signal used as an offset relative to another signal. More...

#include <klang.h>

+ Inheritance diagram for klang::relative:

Public Member Functions

const signal & operator<< (const signal &input)
 Feedback operator (prevents further processing of returned value).
 
signal & operator>> (signal &destination) const
 Stream operator (feedforward; allows further processing)
 
signal & operator+= (Output &in)
 Adds processed output of in to signal.
 
signal & operator+= (const signal &x)
 Add (mix) another signal to the signal.
 
signal & operator+= (float x)
 Add the specified amount to the signal.
 
signal & operator+= (double x)
 Add the specified amount to the signal.
 
signal & operator+= (int x)
 Add the specified amount to the signal.
 
signal & operator-= (const signal &x)
 Subtract another signal from the signal.
 
signal & operator-= (float x)
 Subtract the specified amount from the signal.
 
signal & operator-= (double x)
 Subtract the specified amount from the signal.
 
signal & operator-= (int x)
 Subtract the specified amount from the signal.
 
signal & operator*= (const signal &x)
 Multiply (modulate) signal by another signal.
 
signal & operator*= (float x)
 Multiply signal by the specified amount.
 
signal & operator*= (double x)
 Multiply signal by the specified amount.
 
signal & operator*= (int x)
 Multiply signal by the specified amount.
 
signal & operator/= (const signal &x)
 Divide signal by another signal.
 
signal & operator/= (float x)
 Divide signal by the specified amount.
 
signal & operator/= (double x)
 Divide signal by the specified amount.
 
signal & operator/= (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 1248 of file klang.h.

Member Function Documentation

◆ channels()

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

Definition at line 1235 of file klang.h.

1235{ return 1; }

◆ isDenormal()

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

Definition at line 1229 of file klang.h.

1229 {
1230 const unsigned int bits = *(const unsigned int*)&value;
1231 return !(bits & 0x7F800000) && (bits & 0x007FFFFF);
1232 }
float value
Definition klang.h:1124

References klang::signal::value.

◆ operator const float()

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

Definition at line 1225 of file klang.h.

1225{ return value; }

References klang::signal::value.

◆ operator float &()

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

Definition at line 1226 of file klang.h.

1226{ return value; }

References klang::signal::value.

◆ operator*() [1/3]

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

Definition at line 1205 of file klang.h.

1205{ return value * (float)x; }

References klang::signal::value.

◆ operator*() [2/3]

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

Definition at line 1196 of file klang.h.

1196{ return value * x; }

References klang::signal::value.

◆ operator*() [3/3]

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

Definition at line 1214 of file klang.h.

1214{ return value * (float)x; }

References klang::signal::value.

◆ operator*=() [1/4]

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

Definition at line 1160 of file klang.h.

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

References klang::signal::value.

◆ operator*=() [2/4]

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

Definition at line 1178 of file klang.h.

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

References klang::signal::value.

◆ operator*=() [3/4]

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

Definition at line 1169 of file klang.h.

1169{ value *= x; return *this; }

References klang::signal::value.

◆ operator*=() [4/4]

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

Definition at line 1187 of file klang.h.

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

References klang::signal::value.

◆ operator+() [1/4]

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

Definition at line 1251 of file klang.h.

1251{ return { value }; }

References klang::signal::value.

◆ operator+() [2/4]

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

Definition at line 1201 of file klang.h.

1201{ return value + (float)x; }

References klang::signal::value.

◆ operator+() [3/4]

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

Definition at line 1192 of file klang.h.

1192{ return value + x; }

References klang::signal::value.

◆ operator+() [4/4]

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

Definition at line 1210 of file klang.h.

1210{ return value + (float)x; }

References klang::signal::value.

◆ operator+=() [1/5]

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

Definition at line 1156 of file klang.h.

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

References klang::signal::value.

◆ operator+=() [2/5]

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

Definition at line 1174 of file klang.h.

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

References klang::signal::value.

◆ operator+=() [3/5]

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

Definition at line 1165 of file klang.h.

1165{ value += x; return *this; }

References klang::signal::value.

◆ operator+=() [4/5]

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

Definition at line 1183 of file klang.h.

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

References klang::signal::value.

◆ operator+=() [5/5]

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

Definition at line 3872 of file klang.h.

3872 { // e.g. out += osc;
3873 value += signal(in);
3874 return *this;
3875 }
signal(constant initial)
Create signal from a constant.
Definition klang.h:1127

◆ operator-() [1/3]

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

Definition at line 1203 of file klang.h.

1203{ return value - (float)x; }

References klang::signal::value.

◆ operator-() [2/3]

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

Definition at line 1194 of file klang.h.

1194{ return value - x; }

References klang::signal::value.

◆ operator-() [3/3]

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

Definition at line 1212 of file klang.h.

1212{ return value - (float)x; }

References klang::signal::value.

◆ operator-=() [1/4]

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

Definition at line 1158 of file klang.h.

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

References klang::signal::value.

◆ operator-=() [2/4]

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

Definition at line 1176 of file klang.h.

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

References klang::signal::value.

◆ operator-=() [3/4]

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

Definition at line 1167 of file klang.h.

1167{ value -= x; return *this; }

References klang::signal::value.

◆ operator-=() [4/4]

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

Definition at line 1185 of file klang.h.

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

References klang::signal::value.

◆ operator/() [1/3]

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

Definition at line 1207 of file klang.h.

1207{ return value / (float)x; }

References klang::signal::value.

◆ operator/() [2/3]

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

Definition at line 1198 of file klang.h.

1198{ return value / x; }

References klang::signal::value.

◆ operator/() [3/3]

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

Definition at line 1216 of file klang.h.

1216{ return value / (float)x; }

References klang::signal::value.

◆ operator/=() [1/4]

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

Definition at line 1162 of file klang.h.

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

References klang::signal::value.

◆ operator/=() [2/4]

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

Definition at line 1180 of file klang.h.

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

References klang::signal::value.

◆ operator/=() [3/4]

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

Definition at line 1171 of file klang.h.

1171{ value /= x; return *this; }

References klang::signal::value.

◆ operator/=() [4/4]

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

Definition at line 1189 of file klang.h.

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

References klang::signal::value.

◆ operator<<()

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

Definition at line 1139 of file klang.h.

1139 {
1140 value = input;
1141 return *this;
1142 }

References klang::signal::value.

◆ operator>>()

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

Definition at line 1145 of file klang.h.

1145 {
1146 destination.value = value;
1147 return destination;
1148 }

References klang::signal::value.

◆ operator^() [1/3]

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

Definition at line 1221 of file klang.h.

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

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

◆ operator^() [2/3]

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

Definition at line 1219 of file klang.h.

1219{ 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 1223 of file klang.h.

1223{ return power(value, x); }

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

◆ relative()

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

Definition at line 1253 of file klang.h.

1253{ return { value }; }

References klang::signal::value.

Member Data Documentation

◆ value