Klang C++
Language Reference (draft)
Loading...
Searching...
No Matches
klang::NoteBase< SYNTH >

Base class for synthesiser notes. More...

#include <klang.h>

+ Inheritance diagram for klang::NoteBase< SYNTH >:

Public Types

enum  Stage { Onset , Sustain , Release , Off }
 

Public Member Functions

 NoteBase ()
 
virtual ~NoteBase ()
 
void attach (SYNTH *synth)
 
virtual void init ()
 
virtual void start (Pitch p, Velocity v)
 
virtual bool release (Velocity v=0)
 
virtual bool stop (Velocity v=0)
 
bool finished () const
 
virtual void controlChange (int controller, int value)
 
virtual void onControl (int index, float value)
 
virtual void onPreset (int index)
 
virtual void onMIDI (int status, int byte1, int byte2)
 

Public Attributes

Pitch pitch
 
Velocity velocity
 
Controls controls
 
enum klang::NoteBase::Stage stage = Off
 

Detailed Description

template<class SYNTH>
class klang::NoteBase< SYNTH >

Definition at line 3104 of file klang.h.

Member Enumeration Documentation

◆ Stage

template<class SYNTH >
enum klang::NoteBase::Stage
Values
Onset 
Sustain 
Release 
Off 

Definition at line 3164 of file klang.h.

3164{ Onset, Sustain, Release, Off } stage = Off;
enum klang::NoteBase::Stage stage

Constructor & Destructor Documentation

◆ NoteBase()

template<class SYNTH >
klang::NoteBase< SYNTH >::NoteBase ( )
inline

Definition at line 3126 of file klang.h.

3126: synth(nullptr) { }

◆ ~NoteBase()

template<class SYNTH >
virtual klang::NoteBase< SYNTH >::~NoteBase ( )
inlinevirtual

Definition at line 3127 of file klang.h.

3127{ }

Member Function Documentation

◆ attach()

template<class SYNTH >
void klang::NoteBase< SYNTH >::attach ( SYNTH * synth)
inline

Definition at line 3129 of file klang.h.

3129 {
3130 NoteBase::synth = synth;
3131 controls = synth->controls;
3132 init();
3133 }
virtual void init()
Definition klang.h:3135
Controls controls
Definition klang.h:3124

◆ control()

virtual event klang::Controller::control ( int index,
float value )
inlineprotectedvirtualinherited

Definition at line 3068 of file klang.h.

3068{ };

Referenced by klang::Controller::onControl(), and klang::Synth::onControl().

◆ controlChange()

template<class SYNTH >
virtual void klang::NoteBase< SYNTH >::controlChange ( int controller,
int value )
inlinevirtual

Definition at line 3166 of file klang.h.

3166{ midi(0xB0, controller, value); };
virtual event midi(int status, int byte1, int byte2)
Definition klang.h:3070

References klang::Controller::midi().

◆ finished()

template<class SYNTH >
bool klang::NoteBase< SYNTH >::finished ( ) const
inline

Definition at line 3162 of file klang.h.

3162{ return stage == Off; }

References klang::NoteBase< SYNTH >::Off.

Referenced by klang::Note::process(), and klang::Stereo::Note::process().

◆ getSynth()

template<class SYNTH >
SYNTH * klang::NoteBase< SYNTH >::getSynth ( )
inlineprotected

Definition at line 3120 of file klang.h.

3120{ return synth; }

◆ init()

template<class SYNTH >
virtual void klang::NoteBase< SYNTH >::init ( )
inlinevirtual

Definition at line 3135 of file klang.h.

3135{ }

◆ midi()

virtual event klang::Controller::midi ( int status,
int byte1,
int byte2 )
inlineprotectedvirtualinherited

Definition at line 3070 of file klang.h.

3070{ };

Referenced by klang::NoteBase< SYNTH >::controlChange(), and klang::Controller::onMIDI().

◆ off()

template<class SYNTH >
virtual event klang::NoteBase< SYNTH >::off ( Velocity v = 0)
inlineprotectedvirtual

Definition at line 3118 of file klang.h.

3118{ stage = Off; }

References klang::NoteBase< SYNTH >::Off.

Referenced by klang::NoteBase< SYNTH >::release().

◆ on()

template<class SYNTH >
virtual event klang::NoteBase< SYNTH >::on ( Pitch p,
Velocity v )
inlineprotectedvirtual

Definition at line 3117 of file klang.h.

3117{ }

Referenced by klang::NoteBase< SYNTH >::start().

◆ onControl()

virtual void klang::Controller::onControl ( int index,
float value )
inlinevirtualinherited

Reimplemented in klang::Synth.

Definition at line 3072 of file klang.h.

3072{ control(index, value); };
virtual event control(int index, float value)
Definition klang.h:3068

References klang::Controller::control().

Referenced by klang::Synth::onControl().

◆ onMIDI()

virtual void klang::Controller::onMIDI ( int status,
int byte1,
int byte2 )
inlinevirtualinherited

Definition at line 3074 of file klang.h.

3074{ midi(status, byte1, byte2); }

References klang::Controller::midi().

◆ onPreset()

virtual void klang::Controller::onPreset ( int index)
inlinevirtualinherited

Reimplemented in klang::Synth.

Definition at line 3073 of file klang.h.

3073{ preset(index); };
virtual event preset(int index)
Definition klang.h:3069

References klang::Controller::preset().

Referenced by klang::Synth::onPreset().

◆ preset()

virtual event klang::Controller::preset ( int index)
inlineprotectedvirtualinherited

Definition at line 3069 of file klang.h.

3069{ };

Referenced by klang::Controller::onPreset(), and klang::Synth::onPreset().

◆ release()

template<class SYNTH >
virtual bool klang::NoteBase< SYNTH >::release ( Velocity v = 0)
inlinevirtual

Definition at line 3145 of file klang.h.

3145 {
3146 if (stage == Off)
3147 return true;
3148
3149 if (stage != Release) {
3150 stage = Release;
3151 off(v);
3152 }
3153
3154 return stage == Off;
3155 }
virtual event off(Velocity v=0)
Definition klang.h:3118

References klang::NoteBase< SYNTH >::Off, klang::NoteBase< SYNTH >::off(), and klang::NoteBase< SYNTH >::Release.

◆ start()

template<class SYNTH >
virtual void klang::NoteBase< SYNTH >::start ( Pitch p,
Velocity v )
inlinevirtual

Definition at line 3137 of file klang.h.

3137 {
3138 stage = Onset;
3139 pitch = p;
3140 velocity = v;
3141 on(pitch, velocity);
3142 stage = Sustain;
3143 }
virtual event on(Pitch p, Velocity v)
Definition klang.h:3117
Velocity velocity
Definition klang.h:3123

References klang::NoteBase< SYNTH >::on(), klang::NoteBase< SYNTH >::Onset, klang::NoteBase< SYNTH >::pitch, klang::NoteBase< SYNTH >::Sustain, and klang::NoteBase< SYNTH >::velocity.

◆ stop()

template<class SYNTH >
virtual bool klang::NoteBase< SYNTH >::stop ( Velocity v = 0)
inlinevirtual

Definition at line 3157 of file klang.h.

3157 {
3158 stage = Off;
3159 return true;
3160 }

References klang::NoteBase< SYNTH >::Off.

Member Data Documentation

◆ controls

template<class SYNTH >
Controls klang::NoteBase< SYNTH >::controls

Definition at line 3124 of file klang.h.

◆ pitch

template<class SYNTH >
Pitch klang::NoteBase< SYNTH >::pitch

Definition at line 3122 of file klang.h.

Referenced by klang::NoteBase< SYNTH >::start().

◆ stage

template<class SYNTH >
enum klang::NoteBase::Stage klang::NoteBase< SYNTH >::stage = Off

◆ velocity

template<class SYNTH >
Velocity klang::NoteBase< SYNTH >::velocity

Definition at line 3123 of file klang.h.

Referenced by klang::NoteBase< SYNTH >::start().