hydrogen 1.1.1
Note Class Reference

A note plays an associated instrument with a velocity left and right pan. More...

#include <Note.h>

Inheritance diagram for Note:
Object

Public Types

enum  Key {
  C =KEY_MIN , Cs , D , Ef ,
  E , F , Fs , G ,
  Af , A , Bf , B
}
 possible keys More...
 
enum  Octave {
  P8Z =-3 , P8Y =-2 , P8X =-1 , P8 =OCTAVE_DEFAULT ,
  P8A =1 , P8B =2 , P8C =3
}
 possible octaves More...
 

Public Member Functions

 Note (Instrument *instrument, int position, float velocity, float pan_l, float pan_r, int length, float pitch)
 constructor More...
 
 Note (Note *other, Instrument *instrument=nullptr)
 copy constructor with an optional parameter More...
 
 ~Note ()
 destructor More...
 
void save_to (XMLNode *node)
 
void dump ()
 output details through logger with DEBUG severity More...
 
void map_instrument (InstrumentList *instruments)
 find the corresponding instrument and point to it, or an empty instrument More...
 
Instrumentget_instrument ()
 __instrument accessor More...
 
bool has_instrument () const
 return true if __instrument is set More...
 
void set_instrument_id (int value)
 __instrument_id setter More...
 
int get_instrument_id () const
 __instrument_id accessor More...
 
void set_specific_compo_id (int value)
 __specific_compo_id setter More...
 
int get_specific_compo_id () const
 __specific_compo_id accessor More...
 
void set_position (int value)
 __position setter More...
 
int get_position () const
 __position accessor More...
 
void set_velocity (float value)
 __velocity setter More...
 
float get_velocity () const
 __velocity accessor More...
 
void set_pan_l (float value)
 __pan_l setter More...
 
float get_pan_l () const
 __pan_l accessor More...
 
void set_pan_r (float value)
 __pan_r setter More...
 
float get_pan_r () const
 __pan_r accessor More...
 
void set_lead_lag (float value)
 __lead_lag setter More...
 
float get_lead_lag () const
 __lead_lag accessor More...
 
void set_length (int value)
 __length setter More...
 
int get_length () const
 __length accessor More...
 
void set_pitch (float value)
 __pitch setter More...
 
float get_pitch () const
 __pitch accessor More...
 
void set_note_off (bool value)
 __note_off setter More...
 
bool get_note_off () const
 __note_off accessor More...
 
int get_midi_msg () const
 __midi_msg accessor More...
 
void set_pattern_idx (int value)
 __pattern_idx setter More...
 
int get_pattern_idx () const
 __pattern_idx accessor More...
 
void set_just_recorded (bool value)
 __just_recorded setter More...
 
bool get_just_recorded () const
 __just_recorded accessor More...
 
SelectedLayerInfoget_layer_selected (int CompoID)
 
void set_probability (float value)
 
float get_probability () const
 
void set_humanize_delay (int value)
 __humanize_delay setter More...
 
int get_humanize_delay () const
 __humanize_delay accessor More...
 
float get_cut_off () const
 __cut_off accessor More...
 
float get_resonance () const
 __resonance accessor More...
 
float get_bpfb_l () const
 __bpfb_l accessor More...
 
float get_bpfb_r () const
 __bpfb_r accessor More...
 
float get_lpfb_l () const
 __lpfb_l accessor More...
 
float get_lpfb_r () const
 __lpfb_r accessor More...
 
bool filter_sustain () const
 Filter output is sustaining note. More...
 
Key get_key ()
 __key accessor More...
 
Octave get_octave ()
 __octave accessor More...
 
int get_midi_key () const
 return scaled key for midi output, !!! DO NOT CHECK IF INSTRUMENT IS SET !!! More...
 
int get_midi_velocity () const
 midi velocity accessor More...
 
float get_notekey_pitch () const
 note key pitch accessor More...
 
float get_total_pitch () const
 returns More...
 
QString key_to_string ()
 return a string representation of key-octave More...
 
void set_key_octave (const QString &str)
 parse str and set __key and __octave More...
 
void set_key_octave (Key key, Octave octave)
 set __key and __octave only if within acceptable range More...
 
void set_midi_info (Key key, Octave octave, int msg)
 set __key, __octave and __midi_msg only if within acceptable range More...
 
ADSRget_adsr () const
 get the ADSR of the note More...
 
bool match (Instrument *instrument, Key key, Octave octave) const
 call release on adsr More...
 
bool match (const Note *pNote) const
 Return true if two notes match in instrument, key and octave. More...
 
void compute_lr_values (float *val_l, float *val_r)
 compute left and right output based on filters More...
 
QString toQString (const QString &sPrefix, bool bShort=true) const override
 Formatted string version for debugging purposes. More...
 
- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 

Static Public Member Functions

static Noteload_from (XMLNode *node, InstrumentList *instruments)
 load a note from an XMLNode More...
 
static double pitchToFrequency (double fPitch)
 Convert a logarithmic pitch-space value in semitones to a frequency-domain value. More...
 
- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 

Private Attributes

Instrument__instrument
 the instrument to be played by this note More...
 
int __instrument_id
 the id of the instrument played by this note More...
 
int __specific_compo_id
 play a specific component, -1 if playing all More...
 
int __position
 note position inside the pattern More...
 
float __velocity
 velocity (intensity) of the note [0;1] More...
 
float __pan_l
 pan of the note (left volume) [0;0.5] More...
 
float __pan_r
 pan of the note (right volume) [0;0.5] More...
 
int __length
 the length of the note More...
 
float __pitch
 the frequency of the note More...
 
Key __key
 the key, [0;11]==[C;B] More...
 
Octave __octave
 the octave [-3;3] More...
 
ADSR__adsr
 attack decay sustain release More...
 
float __lead_lag
 lead or lag offset of the note More...
 
float __cut_off
 filter cutoff [0;1] More...
 
float __resonance
 filter resonant frequency [0;1] More...
 
int __humanize_delay
 used in "humanize" function More...
 
std::map< int, SelectedLayerInfo * > __layers_selected
 
float __bpfb_l
 left band pass filter buffer More...
 
float __bpfb_r
 right band pass filter buffer More...
 
float __lpfb_l
 left low pass filter buffer More...
 
float __lpfb_r
 right low pass filter buffer More...
 
int __pattern_idx
 index of the pattern holding this note for undo actions More...
 
int __midi_msg
 TODO. More...
 
bool __note_off
 note type on|off More...
 
bool __just_recorded
 used in record+delete More...
 
float __probability
 note probability More...
 

Static Private Attributes

static const char * __key_str [] = { "C", "Cs", "D", "Ef", "E", "F", "Fs", "G", "Af", "A", "Bf", "B" }
 used to build QString from __key an __octave More...
 

Additional Inherited Members

- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

A note plays an associated instrument with a velocity left and right pan.

Member Enumeration Documentation

◆ Key

enum Key

possible keys

Enumerator
Cs 
Ef 
Fs 
Af 
Bf 

◆ Octave

enum Octave

possible octaves

Enumerator
P8Z 
P8Y 
P8X 
P8 
P8A 
P8B 
P8C 

Constructor & Destructor Documentation

◆ Note() [1/2]

Note ( Instrument instrument,
int  position,
float  velocity,
float  pan_l,
float  pan_r,
int  length,
float  pitch 
)

constructor

Parameters
instrumentthe instrument played by this note
positionthe position of the note within the pattern
velocityit's velocity
pan_lleft pan
pan_rright pan
lengthit's length
pitchit's pitch

◆ Note() [2/2]

Note ( Note other,
Instrument instrument = nullptr 
)

copy constructor with an optional parameter

Parameters
other
instrumentif set will be used as note instrument

◆ ~Note()

~Note ( )

destructor

Member Function Documentation

◆ compute_lr_values()

void compute_lr_values ( float *  val_l,
float *  val_r 
)
inline

compute left and right output based on filters

Parameters
val_lthe left channel value
val_rthe right channel value

◆ dump()

void dump ( )

output details through logger with DEBUG severity

◆ filter_sustain()

bool filter_sustain ( ) const
inline

Filter output is sustaining note.

◆ get_adsr()

ADSR * get_adsr ( ) const
inline

get the ADSR of the note

◆ get_bpfb_l()

float get_bpfb_l ( ) const
inline

__bpfb_l accessor

◆ get_bpfb_r()

float get_bpfb_r ( ) const
inline

__bpfb_r accessor

◆ get_cut_off()

float get_cut_off ( ) const
inline

__cut_off accessor

◆ get_humanize_delay()

int get_humanize_delay ( ) const
inline

__humanize_delay accessor

◆ get_instrument()

Instrument * get_instrument ( )
inline

__instrument accessor

◆ get_instrument_id()

int get_instrument_id ( ) const
inline

__instrument_id accessor

◆ get_just_recorded()

bool get_just_recorded ( ) const
inline

__just_recorded accessor

◆ get_key()

Note::Key get_key ( )
inline

__key accessor

◆ get_layer_selected()

SelectedLayerInfo * get_layer_selected ( int  CompoID)
inline

◆ get_lead_lag()

float get_lead_lag ( ) const
inline

__lead_lag accessor

◆ get_length()

int get_length ( ) const
inline

__length accessor

◆ get_lpfb_l()

float get_lpfb_l ( ) const
inline

__lpfb_l accessor

◆ get_lpfb_r()

float get_lpfb_r ( ) const
inline

__lpfb_r accessor

◆ get_midi_key()

int get_midi_key ( ) const
inline

return scaled key for midi output, !!! DO NOT CHECK IF INSTRUMENT IS SET !!!

◆ get_midi_msg()

int get_midi_msg ( ) const
inline

__midi_msg accessor

◆ get_midi_velocity()

int get_midi_velocity ( ) const
inline

midi velocity accessor

#define MIDI_FACTOR
Definition: Note.h:38
float __velocity
velocity (intensity) of the note [0;1]
Definition: Note.h:325

◆ get_note_off()

bool get_note_off ( ) const
inline

__note_off accessor

◆ get_notekey_pitch()

float get_notekey_pitch ( ) const
inline

note key pitch accessor

#define KEYS_PER_OCTAVE
Definition: Note.h:35
Key __key
the key, [0;11]==[C;B]
Definition: Note.h:330
Octave __octave
the octave [-3;3]
Definition: Note.h:331

◆ get_octave()

Note::Octave get_octave ( )
inline

__octave accessor

◆ get_pan_l()

float get_pan_l ( ) const
inline

__pan_l accessor

◆ get_pan_r()

float get_pan_r ( ) const
inline

__pan_r accessor

◆ get_pattern_idx()

int get_pattern_idx ( ) const
inline

__pattern_idx accessor

◆ get_pitch()

float get_pitch ( ) const
inline

__pitch accessor

◆ get_position()

int get_position ( ) const
inline

__position accessor

◆ get_probability()

float get_probability ( ) const
inline

◆ get_resonance()

float get_resonance ( ) const
inline

__resonance accessor

◆ get_specific_compo_id()

int get_specific_compo_id ( ) const
inline

◆ get_total_pitch()

float get_total_pitch ( ) const
inline

returns

float __pitch
the frequency of the note
Definition: Note.h:329

◆ get_velocity()

float get_velocity ( ) const
inline

__velocity accessor

◆ has_instrument()

bool has_instrument ( ) const
inline

return true if __instrument is set

◆ key_to_string()

QString key_to_string ( )

return a string representation of key-octave

◆ load_from()

Note * load_from ( XMLNode node,
InstrumentList instruments 
)
static

load a note from an XMLNode

Parameters
nodethe XMLDode to read from
instrumentsthe current instrument list to search instrument into
Returns
a new Note instance

◆ map_instrument()

void map_instrument ( InstrumentList instruments)

find the corresponding instrument and point to it, or an empty instrument

Parameters
instrumentsthe list of instrument to look into

◆ match() [1/2]

bool match ( const Note pNote) const
inline

Return true if two notes match in instrument, key and octave.

◆ match() [2/2]

bool match ( Instrument instrument,
Key  key,
Octave  octave 
) const
inline

call release on adsr

call get value on adsr return true if instrument, key and octave matches with internal

Parameters
instrumentthe instrument to match with __instrument
keythe key to match with __key
octavethe octave to match with __octave

◆ pitchToFrequency()

static double pitchToFrequency ( double  fPitch)
inlinestatic

Convert a logarithmic pitch-space value in semitones to a frequency-domain value.

◆ save_to()

void save_to ( XMLNode node)

◆ set_humanize_delay()

void set_humanize_delay ( int  value)
inline

__humanize_delay setter

Parameters
valuethe new value

◆ set_instrument_id()

void set_instrument_id ( int  value)
inline

__instrument_id setter

Parameters
valuethe new value

◆ set_just_recorded()

void set_just_recorded ( bool  value)
inline

__just_recorded setter

Parameters
valuethe new value

◆ set_key_octave() [1/2]

void set_key_octave ( const QString &  str)

parse str and set __key and __octave

Parameters
strthe string to be parsed

◆ set_key_octave() [2/2]

void set_key_octave ( Key  key,
Octave  octave 
)
inline

set __key and __octave only if within acceptable range

Parameters
keythe key to set
octavethe octave to be set

◆ set_lead_lag()

void set_lead_lag ( float  value)

__lead_lag setter

Parameters
valuethe new value

◆ set_length()

void set_length ( int  value)
inline

__length setter

Parameters
valuethe new value

◆ set_midi_info()

void set_midi_info ( Key  key,
Octave  octave,
int  msg 
)
inline

set __key, __octave and __midi_msg only if within acceptable range

Parameters
keythe key to set
octavethe octave to be set
msg

◆ set_note_off()

void set_note_off ( bool  value)
inline

__note_off setter

Parameters
valuethe new value

◆ set_pan_l()

void set_pan_l ( float  value)

__pan_l setter

Parameters
valuethe new value

◆ set_pan_r()

void set_pan_r ( float  value)

__pan_r setter

Parameters
valuethe new value

◆ set_pattern_idx()

void set_pattern_idx ( int  value)
inline

__pattern_idx setter

Parameters
valuethe new value

◆ set_pitch()

void set_pitch ( float  value)
inline

__pitch setter

Parameters
valuethe new value

◆ set_position()

void set_position ( int  value)
inline

__position setter

Parameters
valuethe new value

◆ set_probability()

void set_probability ( float  value)
inline

◆ set_specific_compo_id()

void set_specific_compo_id ( int  value)
inline

__specific_compo_id setter

Parameters
valuethe new value

◆ set_velocity()

void set_velocity ( float  value)

__velocity setter

Parameters
valuethe new value

◆ toQString()

QString toQString ( const QString &  sPrefix,
bool  bShort = true 
) const
overridevirtual

Formatted string version for debugging purposes.

Parameters
sPrefixString prefix which will be added in front of every new line
bShortInstead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks.
Returns
String presentation of current object.

Reimplemented from Object.

Field Documentation

◆ __adsr

ADSR* __adsr
private

attack decay sustain release

◆ __bpfb_l

float __bpfb_l
private

left band pass filter buffer

◆ __bpfb_r

float __bpfb_r
private

right band pass filter buffer

◆ __cut_off

float __cut_off
private

filter cutoff [0;1]

◆ __humanize_delay

int __humanize_delay
private

used in "humanize" function

◆ __instrument

Instrument* __instrument
private

the instrument to be played by this note

◆ __instrument_id

int __instrument_id
private

the id of the instrument played by this note

◆ __just_recorded

bool __just_recorded
private

used in record+delete

◆ __key

Key __key
private

the key, [0;11]==[C;B]

◆ __key_str

const char * __key_str = { "C", "Cs", "D", "Ef", "E", "F", "Fs", "G", "Af", "A", "Bf", "B" }
staticprivate

used to build QString from __key an __octave

◆ __layers_selected

std::map< int, SelectedLayerInfo* > __layers_selected
private

◆ __lead_lag

float __lead_lag
private

lead or lag offset of the note

◆ __length

int __length
private

the length of the note

◆ __lpfb_l

float __lpfb_l
private

left low pass filter buffer

◆ __lpfb_r

float __lpfb_r
private

right low pass filter buffer

◆ __midi_msg

int __midi_msg
private

TODO.

◆ __note_off

bool __note_off
private

note type on|off

◆ __octave

Octave __octave
private

the octave [-3;3]

◆ __pan_l

float __pan_l
private

pan of the note (left volume) [0;0.5]

◆ __pan_r

float __pan_r
private

pan of the note (right volume) [0;0.5]

◆ __pattern_idx

int __pattern_idx
private

index of the pattern holding this note for undo actions

◆ __pitch

float __pitch
private

the frequency of the note

◆ __position

int __position
private

note position inside the pattern

◆ __probability

float __probability
private

note probability

◆ __resonance

float __resonance
private

filter resonant frequency [0;1]

◆ __specific_compo_id

int __specific_compo_id
private

play a specific component, -1 if playing all

◆ __velocity

float __velocity
private

velocity (intensity) of the note [0;1]