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

Synthesiser note (mono) More...

#include <klang.h>

+ Inheritance diagram for klang::Note:

Public Types

enum  Stage
 

Public Member Functions

virtual void prepare ()
 
virtual void process () override=0
 
virtual bool process (buffer buffer)
 
virtual bool process (buffer *buffer)
 
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)
 
Output< signal > & operator() (params... p)
 
 operator const signal & () override
 
 operator const signal & () const override
 
virtual const signaloutput () const
 
TYPE & operator>> (TYPE &destination)
 
signal operator+ (TYPE &other)
 
signal operator* (TYPE &other)
 
signal operator- (TYPE &other)
 
signal operator/ (TYPE &other)
 

Public Attributes

Pitch pitch
 
Velocity velocity
 
Controls controls
 
enum klang::NoteBase::Stage stage
 
signal out
 

Detailed Description

Definition at line 3172 of file klang.h.

Member Enumeration Documentation

◆ Stage

enum klang::NoteBase::Stage
inherited

Member Function Documentation

◆ attach()

void klang::NoteBase< Synth >::attach ( Synth * synth)
inlineinherited

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:3081

◆ 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()

virtual void klang::NoteBase< Synth >::controlChange ( int controller,
int value )
inlinevirtualinherited

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

◆ finished()

bool klang::NoteBase< Synth >::finished ( ) const
inlineinherited

Definition at line 3162 of file klang.h.

3162{ return stage == Off; }

◆ getSynth()

Synth * klang::NoteBase< Synth >::getSynth ( )
inlineprotectedinherited

Definition at line 3120 of file klang.h.

3120{ return synth; }

◆ init()

virtual void klang::NoteBase< Synth >::init ( )
inlinevirtualinherited

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()

virtual event klang::NoteBase< Synth >::off ( Velocity v = 0)
inlineprotectedvirtualinherited

Definition at line 3118 of file klang.h.

3118{ stage = Off; }

◆ on()

virtual event klang::NoteBase< Synth >::on ( Pitch p,
Velocity v )
inlineprotectedvirtualinherited

Definition at line 3117 of file klang.h.

3117{ }

◆ 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().

◆ operator const signal &() [1/2]

klang::Generic::Generator< signal >::operator const signal & ( ) const
inlineoverridevirtualinherited

Reimplemented from klang::Generic::Output< signal >.

Definition at line 1416 of file klang.h.

1416{ return out; } // return last output

◆ operator const signal &() [2/2]

klang::Generic::Generator< signal >::operator const signal & ( )
inlineoverridevirtualinherited

Reimplemented from klang::Generic::Output< signal >.

Definition at line 1415 of file klang.h.

1415{ process(); return out; } // return processed output

◆ operator()()

Output< signal > & klang::Generic::Generator< signal >::operator() ( params... p)
inlineinherited

Definition at line 1409 of file klang.h.

1409 {
1410 set(p...); return *this;
1411 }

◆ operator*()

signal klang::Generic::Output< signal >::operator* ( TYPE & other)
inlineinherited

Definition at line 1372 of file klang.h.

1372{ process(); return out * (other); }

◆ operator+()

signal klang::Generic::Output< signal >::operator+ ( TYPE & other)
inlineinherited

Definition at line 1371 of file klang.h.

1371{ process(); return out + (other); }

◆ operator-()

signal klang::Generic::Output< signal >::operator- ( TYPE & other)
inlineinherited

Definition at line 1373 of file klang.h.

1373{ process(); return out - (other); }

◆ operator/()

signal klang::Generic::Output< signal >::operator/ ( TYPE & other)
inlineinherited

Definition at line 1374 of file klang.h.

1374{ process(); return out / (other); }

◆ operator>>()

TYPE & klang::Generic::Output< signal >::operator>> ( TYPE & destination)
inlineinherited

Definition at line 1364 of file klang.h.

1364{ process(); return destination = out; }

◆ output()

virtual const signal & klang::Generic::Output< signal >::output ( ) const
inlinevirtualinherited

Definition at line 1360 of file klang.h.

1360{ return out; }

◆ prepare()

virtual void klang::Note::prepare ( )
inlinevirtual

Definition at line 3173 of file klang.h.

3173{ }

Referenced by process().

◆ 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().

◆ process() [1/3]

virtual void klang::Note::process ( )
overridepure virtual

Implements klang::Generic::Output< signal >.

Referenced by process().

◆ process() [2/3]

virtual bool klang::Note::process ( buffer * buffer)
inlinevirtual

Definition at line 3184 of file klang.h.

3184 {
3185 return process(buffer[0]);
3186 }
virtual void process() override=0

References process().

◆ process() [3/3]

virtual bool klang::Note::process ( buffer buffer)
inlinevirtual

Definition at line 3175 of file klang.h.

3175 {
3176 prepare();
3177 while (!buffer.finished()) {
3178 process();
3179 buffer++ = out;
3180 debug.buffer++;
3181 }
3182 return !finished();
3183 }
bool finished() const
Definition klang.h:3162
static Debug debug
Definition klang.h:2397
static THREAD_LOCAL Buffer buffer
Definition klang.h:2294
virtual void prepare()
Definition klang.h:3173

References klang::Debug::buffer, klang::debug, klang::buffer::finished(), klang::NoteBase< SYNTH >::finished(), klang::buffer::operator++(), prepare(), and process().

Referenced by process().

◆ release()

virtual bool klang::NoteBase< Synth >::release ( Velocity v = 0)
inlinevirtualinherited

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

◆ start()

virtual void klang::NoteBase< Synth >::start ( Pitch p,
Velocity v )
inlinevirtualinherited

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

◆ stop()

virtual bool klang::NoteBase< Synth >::stop ( Velocity v = 0)
inlinevirtualinherited

Definition at line 3157 of file klang.h.

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

Member Data Documentation

◆ controls

Controls klang::NoteBase< Synth >::controls
inherited

Definition at line 3124 of file klang.h.

◆ out

Definition at line 1357 of file klang.h.

1357{ 0.f };

◆ pitch

Pitch klang::NoteBase< Synth >::pitch
inherited

Definition at line 3122 of file klang.h.

◆ stage

enum klang::NoteBase::Stage klang::NoteBase< Synth >::stage
inherited

◆ velocity

Velocity klang::NoteBase< Synth >::velocity
inherited

Definition at line 3123 of file klang.h.