Klang C++ 0.7.15
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 5562 of file klang.h.

Member Enumeration Documentation

◆ Stage

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

Definition at line 5625 of file klang.h.

5625{ 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 5587 of file klang.h.

5587: synth(nullptr) {}

◆ ~NoteBase()

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

Definition at line 5588 of file klang.h.

5588{}

Member Function Documentation

◆ attach()

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

Definition at line 5590 of file klang.h.

5590 {
5591 NoteBase::synth = synth;
5592 controls = synth->controls;
5593 init();
5594 }
virtual void init()
Definition klang.h:5596
Controls controls
Definition klang.h:5585

◆ control()

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

Definition at line 5509 of file klang.h.

5509{};

◆ controlChange()

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

Definition at line 5627 of file klang.h.

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

◆ finished()

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

Definition at line 5623 of file klang.h.

5623{ return stage == Off; }

◆ getSynth()

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

Definition at line 5581 of file klang.h.

5581{ return static_cast<std::remove_pointer_t<decltype(synth)>*>(synth); }

◆ init()

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

Definition at line 5596 of file klang.h.

5596{}

◆ midi()

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

Definition at line 5511 of file klang.h.

5511{};

◆ off()

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

Definition at line 5578 of file klang.h.

5578{ stage = Off; }

◆ on()

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

Definition at line 5577 of file klang.h.

5577{}

◆ onControl()

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

Reimplemented in klang::Stereo::Synth, and klang::Synth.

Definition at line 5513 of file klang.h.

5513{ this->control(index, value); };
virtual event control(int index, float value)
Definition klang.h:5509

◆ onMIDI()

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

Reimplemented in klang::Stereo::Synth, and klang::Synth.

Definition at line 5515 of file klang.h.

5515{ this->midi(status, byte1, byte2); }

◆ onPreset()

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

Reimplemented in klang::Stereo::Synth, and klang::Synth.

Definition at line 5514 of file klang.h.

5514{ this->preset(index); };
virtual event preset(int index)
Definition klang.h:5510

◆ preset()

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

Definition at line 5510 of file klang.h.

5510{};

◆ release()

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

Definition at line 5606 of file klang.h.

5606 {
5607 if (stage == Off)
5608 return true;
5609
5610 if (stage != Release) {
5611 stage = Release;
5612 off(v);
5613 }
5614
5615 return stage == Off;
5616 }
virtual event off(Velocity v=0)
Definition klang.h:5578

◆ start()

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

Definition at line 5598 of file klang.h.

5598 {
5599 stage = Onset;
5600 pitch = p;
5601 velocity = v;
5602 on(pitch, velocity);
5603 stage = Sustain;
5604 }
virtual event on(Pitch p, Velocity v)
Definition klang.h:5577
Velocity velocity
Definition klang.h:5584

◆ stop()

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

Definition at line 5618 of file klang.h.

5618 {
5619 stage = Off;
5620 return true;
5621 }

Referenced by klang::Stereo::Synth::process().

Member Data Documentation

◆ controls

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

Definition at line 5585 of file klang.h.

◆ pitch

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

Definition at line 5583 of file klang.h.

◆ 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 5584 of file klang.h.