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

Templates supporting common audio functionality.

Classes

struct  Function
 Applies a function to a signal (input-output) More...
 
struct  Generator
 Signal generator object (output only) More...
 
struct  Graph
 A line graph plotter. More...
 
struct  Input
 Audio input object. More...
 
struct  Modifier
 Signal modifier object (input-output) More...
 
struct  Oscillator
 Audio oscillator object (output) More...
 
struct  Output
 Audio output object. More...
 

Typedefs

template<typename OBJECT >
using OutputSignal = std::decay_t<decltype(std::declval<OBJECT&>().out)>
 
template<typename OBJECT , typename SCALAR >
using ScalarOutput
 

Functions

template<typename SIGNAL >
SIGNAL operator+ (float other, Output< SIGNAL > &output)
 
template<typename SIGNAL >
SIGNAL operator* (float other, Output< SIGNAL > &output)
 
template<typename SIGNAL >
SIGNAL operator- (float other, Output< SIGNAL > &output)
 
template<typename SIGNAL >
SIGNAL operator/ (float other, Output< SIGNAL > &output)
 
template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > operator+ (OBJECT &output, SCALAR &&other)
 
template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > operator* (OBJECT &output, SCALAR &&other)
 
template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > operator- (OBJECT &output, SCALAR &&other)
 
template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > operator/ (OBJECT &output, SCALAR &&other)
 
template<typename... Args>
 Function (float(*)(Args...)) -> Function< signal, Args... >
 
template<typename... Args>
 Function () -> Function< signal, Args... >
 
template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL operator+ (TYPE &x, Function< SIGNAL, float > &func)
 
template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL operator- (TYPE &x, Function< SIGNAL, float > &func)
 
template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL operator* (TYPE &x, Function< SIGNAL, float > &func)
 
template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL operator/ (TYPE &x, Function< SIGNAL, float > &func)
 

Typedef Documentation

◆ OutputSignal

template<typename OBJECT >
using klang::Generic::OutputSignal = std::decay_t<decltype(std::declval<OBJECT&>().out)>

Definition at line 3001 of file klang.h.

◆ ScalarOutput

template<typename OBJECT , typename SCALAR >
using klang::Generic::ScalarOutput
Initial value:
std::enable_if_t<
(std::is_arithmetic_v<SCALAR> ||
(std::is_same_v<std::decay_t<SCALAR>, OutputSignal<OBJECT>> &&
!std::is_lvalue_reference_v<SCALAR>)) && !std::is_const_v<OBJECT> &&
std::is_base_of_v<Output<OutputSignal<OBJECT>>, OBJECT> &&
!std::is_convertible_v<OBJECT&, float>, OutputSignal<OBJECT>>

Definition at line 3002 of file klang.h.

Function Documentation

◆ Function() [1/2]

template<typename... Args>
klang::Generic::Function ( ) -> Function< signal, Args... >

◆ Function() [2/2]

template<typename... Args>
klang::Generic::Function ( float(*  )(Args...)) -> Function< signal, Args... >

◆ operator*() [1/3]

template<typename SIGNAL >
SIGNAL klang::Generic::operator* ( float other,
Output< SIGNAL > & output )
inline

Definition at line 2995 of file klang.h.

2995{ return SIGNAL(output) * other; }

◆ operator*() [2/3]

template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > klang::Generic::operator* ( OBJECT & output,
SCALAR && other )
inline

Definition at line 3017 of file klang.h.

3017 {
3018 if constexpr (std::is_arithmetic_v<SCALAR>)
3019 return OutputSignal<OBJECT>(output) * float(other);
3020 else
3021 return OutputSignal<OBJECT>(output) * other;
3022 }
std::decay_t< decltype(std::declval< OBJECT & >().out)> OutputSignal
Definition klang.h:3001

◆ operator*() [3/3]

template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL klang::Generic::operator* ( TYPE & x,
Function< SIGNAL, float > & func )

Definition at line 3320 of file klang.h.

3320{ return func * (SIGNAL)x; }

◆ operator+() [1/3]

template<typename SIGNAL >
SIGNAL klang::Generic::operator+ ( float other,
Output< SIGNAL > & output )
inline

Definition at line 2994 of file klang.h.

2994{ return SIGNAL(output) + other; }

◆ operator+() [2/3]

template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > klang::Generic::operator+ ( OBJECT & output,
SCALAR && other )
inline

Definition at line 3010 of file klang.h.

3010 {
3011 if constexpr (std::is_arithmetic_v<SCALAR>)
3012 return OutputSignal<OBJECT>(output) + float(other);
3013 else
3014 return OutputSignal<OBJECT>(output) + other;
3015 }

◆ operator+() [3/3]

template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL klang::Generic::operator+ ( TYPE & x,
Function< SIGNAL, float > & func )

Definition at line 3318 of file klang.h.

3318{ return func + (SIGNAL)x; }

◆ operator-() [1/3]

template<typename SIGNAL >
SIGNAL klang::Generic::operator- ( float other,
Output< SIGNAL > & output )
inline

Definition at line 2996 of file klang.h.

2996{ return SIGNAL(other) - SIGNAL(output); }

◆ operator-() [2/3]

template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > klang::Generic::operator- ( OBJECT & output,
SCALAR && other )
inline

Definition at line 3024 of file klang.h.

3024 {
3025 if constexpr (std::is_arithmetic_v<SCALAR>)
3026 return OutputSignal<OBJECT>(output) - float(other);
3027 else
3028 return OutputSignal<OBJECT>(output) - other;
3029 }

◆ operator-() [3/3]

template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL klang::Generic::operator- ( TYPE & x,
Function< SIGNAL, float > & func )

Definition at line 3319 of file klang.h.

3319{ return -func + (SIGNAL)x; }

◆ operator/() [1/3]

template<typename SIGNAL >
SIGNAL klang::Generic::operator/ ( float other,
Output< SIGNAL > & output )
inline

Definition at line 2997 of file klang.h.

2997{ return SIGNAL(other) / SIGNAL(output); }

◆ operator/() [2/3]

template<typename OBJECT , typename SCALAR >
ScalarOutput< OBJECT, SCALAR > klang::Generic::operator/ ( OBJECT & output,
SCALAR && other )
inline

Definition at line 3031 of file klang.h.

3031 {
3032 if constexpr (std::is_arithmetic_v<SCALAR>)
3033 return OutputSignal<OBJECT>(output) / float(other);
3034 else
3035 return OutputSignal<OBJECT>(output) / other;
3036 }

◆ operator/() [3/3]

template<typename TYPE , typename SIGNAL , typename... Args>
SIGNAL klang::Generic::operator/ ( TYPE & x,
Function< SIGNAL, float > & func )

Definition at line 3321 of file klang.h.

3321 {
3322 SIGNAL y = (SIGNAL)func;
3323 return (SIGNAL)x / y;
3324 }