hydrogen 1.1.1
Instrument Class Reference

Instrument class. More...

#include <Instrument.h>

Inheritance diagram for Instrument:
Object

Public Types

enum  SampleSelectionAlgo { VELOCITY , ROUND_ROBIN , RANDOM }
 

Public Member Functions

 Instrument (const int id=EMPTY_INSTR_ID, const QString &name="Empty Instrument", ADSR *adsr=nullptr)
 constructor More...
 
 Instrument (Instrument *other)
 copy constructor More...
 
 ~Instrument ()
 destructor More...
 
void load_from (const QString &drumkit_name, const QString &instrument_name, bool is_live=true, Filesystem::Lookup lookup=Filesystem::Lookup::stacked)
 loads instrument from a given instrument within a given drumkit into a live Instrument object. More...
 
void load_from (Drumkit *drumkit, Instrument *instrument, bool is_live=true)
 loads instrument from a given instrument into a live Instrument object. More...
 
void load_samples ()
 Calls the InstrumentLayer::load_sample() member function of all layers of each component of the Instrument. More...
 
void unload_samples ()
 Calls the InstrumentLayer::unload_sample() member function of all layers of each component of the Instrument. More...
 
void save_to (XMLNode *node, int component_id)
 save the instrument within the given XMLNode More...
 
void set_name (const QString &name)
 get the name of the instrument More...
 
const QString & get_name () const
 set the id of the instrument More...
 
void set_id (const int id)
 get the id of the instrument More...
 
int get_id () const
 Returns __id. More...
 
void set_adsr (ADSR *adsr)
 set the ADSR of the instrument More...
 
ADSRget_adsr () const
 get the ADSR of the instrument More...
 
ADSRcopy_adsr () const
 get a copy of the ADSR of the instrument More...
 
void set_mute_group (int group)
 set the mute group of the instrument More...
 
int get_mute_group () const
 get the mute group of the instrument More...
 
void set_midi_out_channel (int channel)
 set the midi out channel of the instrument More...
 
int get_midi_out_channel () const
 get the midi out channel of the instrument More...
 
void set_midi_out_note (int note)
 set the midi out note of the instrument More...
 
int get_midi_out_note () const
 get the midi out note of the instrument More...
 
void set_muted (bool muted)
 set muted status of the instrument More...
 
bool is_muted () const
 get muted status of the instrument More...
 
void set_pan_l (float val)
 set left pan of the instrument More...
 
float get_pan_l () const
 get left pan of the instrument More...
 
void set_pan_r (float val)
 set right pan of the instrument More...
 
float get_pan_r () const
 get right pan of the instrument More...
 
void set_gain (float gain)
 set gain of the instrument More...
 
float get_gain () const
 get gain of the instrument More...
 
void set_volume (float volume)
 set the volume of the instrument More...
 
float get_volume () const
 get the volume of the instrument More...
 
void set_filter_active (bool active)
 activate the filter of the instrument More...
 
bool is_filter_active () const
 get the status of the filter of the instrument More...
 
void set_filter_resonance (float val)
 set the filter resonance of the instrument More...
 
float get_filter_resonance () const
 get the filter resonance of the instrument More...
 
void set_filter_cutoff (float val)
 set the filter cutoff of the instrument More...
 
float get_filter_cutoff () const
 get the filter cutoff of the instrument More...
 
void set_peak_l (float val)
 set the left peak of the instrument More...
 
float get_peak_l () const
 get the left peak of the instrument More...
 
void set_peak_r (float val)
 set the right peak of the instrument More...
 
float get_peak_r () const
 get the right peak of the instrument More...
 
void set_fx_level (float level, int index)
 set the fx level of the instrument More...
 
float get_fx_level (int index) const
 get the fx level of the instrument More...
 
void set_random_pitch_factor (float val)
 set the random pitch factor of the instrument More...
 
float get_random_pitch_factor () const
 get the random pitch factor of the instrument More...
 
void set_pitch_offset (float val)
 set the pitch offset of the instrument More...
 
float get_pitch_offset () const
 get the pitch offset of the instrument More...
 
void set_active (bool active)
 set the active status of the instrument More...
 
bool is_active () const
 get the active status of the instrument More...
 
void set_soloed (bool soloed)
 set the soloed status of the instrument More...
 
bool is_soloed () const
 get the soloed status of the instrument More...
 
void enqueue ()
 enqueue the instrument More...
 
void dequeue ()
 dequeue the instrument More...
 
bool is_queued () const
 get the queued status of the instrument More...
 
void set_stop_notes (bool stopnotes)
 set the stop notes status of the instrument More...
 
bool is_stop_notes () const
 get the stop notes of the instrument More...
 
void set_sample_selection_alg (SampleSelectionAlgo selected_algo)
 
SampleSelectionAlgo sample_selection_alg () const
 
void set_hihat_grp (int hihat_grp)
 
int get_hihat_grp () const
 
void set_lower_cc (int message)
 
int get_lower_cc () const
 
void set_higher_cc (int message)
 
int get_higher_cc () const
 set the name of the related drumkit More...
 
void set_drumkit_name (const QString &name)
 get the name of the related drumkits More...
 
const QString & get_drumkit_name () const
 
void set_is_preview_instrument (bool isPreview)
 Mark the instrument as hydrogen's preview instrument. More...
 
bool is_preview_instrument () const
 
void set_is_metronome_instrument (bool isMetronome)
 Mark the instrument as metronome instrument. More...
 
bool is_metronome_instrument () const
 
std::vector< InstrumentComponent * > * get_components ()
 
InstrumentComponentget_component (int DrumkitComponentID)
 
void set_apply_velocity (bool apply_velocity)
 
bool get_apply_velocity () const
 
bool is_currently_exported () const
 
void set_currently_exported (bool isCurrentlyExported)
 
bool has_missing_samples () const
 
void set_missing_samples (bool bHasMissingSamples)
 
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 Instrumentload_instrument (const QString &drumkit_name, const QString &instrument_name, Filesystem::Lookup lookup=Filesystem::Lookup::stacked)
 creates a new Instrument, loads samples from a given instrument within a given drumkit More...
 
static Instrumentload_from (XMLNode *node, const QString &dk_path, const QString &dk_name)
 load an instrument from an XMLNode 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

int __id
 Identifier of an instrument, which should be unique. More...
 
QString __name
 Name of the Instrument. More...
 
QString __drumkit_name
 the name of the drumkit this instrument belongs to More...
 
float __gain
 gain of the instrument More...
 
float __volume
 volume of the instrument More...
 
float __pan_l
 left pan of the instrument More...
 
float __pan_r
 right pan of the instrument More...
 
float __peak_l
 left current peak value More...
 
float __peak_r
 right current peak value More...
 
ADSR__adsr
 attack delay sustain release instance More...
 
bool __filter_active
 is filter active? More...
 
float __filter_cutoff
 filter cutoff (0..1) More...
 
float __filter_resonance
 filter resonant frequency (0..1) More...
 
float __random_pitch_factor
 random pitch factor More...
 
float __pitch_offset
 instrument main pitch offset More...
 
int __midi_out_note
 midi out note More...
 
int __midi_out_channel
 midi out channel More...
 
bool __stop_notes
 will the note automatically generate a note off after being on More...
 
SampleSelectionAlgo __sample_selection_alg
 how Hydrogen will chose the sample to use More...
 
bool __active
 is the instrument active? More...
 
bool __soloed
 is the instrument in solo mode? More...
 
bool __muted
 is the instrument muted? More...
 
int __mute_group
 mute group of the instrument More...
 
int __queued
 count the number of notes queued within Sampler::__playing_notes_queue or std::priority_queue m_songNoteQueue More...
 
float __fx_level [MAX_FX]
 Ladspa FX level array. More...
 
int __hihat_grp
 the instrument is part of a hihat More...
 
int __lower_cc
 lower cc level More...
 
int __higher_cc
 higher cc level More...
 
bool __is_preview_instrument
 is the instrument an hydrogen preview instrument? More...
 
bool __is_metronome_instrument
 is the instrument an metronome instrument? More...
 
std::vector< InstrumentComponent * > * __components
 InstrumentLayer array. More...
 
bool __apply_velocity
 change the sample gain based on velocity More...
 
bool __current_instr_for_export
 is the instrument currently being exported? More...
 
bool m_bHasMissingSamples
 does the instrument have missing sample files? 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

Instrument class.

Member Enumeration Documentation

◆ SampleSelectionAlgo

Enumerator
VELOCITY 
ROUND_ROBIN 
RANDOM 

Constructor & Destructor Documentation

◆ Instrument() [1/2]

Instrument ( const int  id = EMPTY_INSTR_ID,
const QString &  name = "Empty Instrument",
ADSR adsr = nullptr 
)

constructor

Parameters
idthe id of this instrument
namethe name of the instrument
adsrattack decay sustain release instance

◆ Instrument() [2/2]

Instrument ( Instrument other)

copy constructor

◆ ~Instrument()

~Instrument ( )

destructor

Member Function Documentation

◆ copy_adsr()

ADSR * copy_adsr ( ) const
inline

get a copy of the ADSR of the instrument

◆ dequeue()

void dequeue ( )
inline

dequeue the instrument

◆ enqueue()

void enqueue ( )
inline

enqueue the instrument

◆ get_adsr()

ADSR * get_adsr ( ) const
inline

get the ADSR of the instrument

◆ get_apply_velocity()

bool get_apply_velocity ( ) const
inline

◆ get_component()

InstrumentComponent * get_component ( int  DrumkitComponentID)

◆ get_components()

std::vector< InstrumentComponent * > * get_components ( )
inline

◆ get_drumkit_name()

const QString & get_drumkit_name ( ) const
inline

◆ get_filter_cutoff()

float get_filter_cutoff ( ) const
inline

get the filter cutoff of the instrument

◆ get_filter_resonance()

float get_filter_resonance ( ) const
inline

get the filter resonance of the instrument

◆ get_fx_level()

float get_fx_level ( int  index) const
inline

get the fx level of the instrument

◆ get_gain()

float get_gain ( ) const
inline

get gain of the instrument

◆ get_higher_cc()

int get_higher_cc ( ) const
inline

set the name of the related drumkit

◆ get_hihat_grp()

int get_hihat_grp ( ) const
inline

◆ get_id()

int get_id ( ) const
inline

Returns __id.

Returns
__id.

◆ get_lower_cc()

int get_lower_cc ( ) const
inline

◆ get_midi_out_channel()

int get_midi_out_channel ( ) const
inline

get the midi out channel of the instrument

◆ get_midi_out_note()

int get_midi_out_note ( ) const
inline

get the midi out note of the instrument

◆ get_mute_group()

int get_mute_group ( ) const
inline

get the mute group of the instrument

◆ get_name()

const QString & get_name ( ) const
inline

set the id of the instrument

Access the name of the Instrument.

Returns
__name

◆ get_pan_l()

float get_pan_l ( ) const
inline

get left pan of the instrument

◆ get_pan_r()

float get_pan_r ( ) const
inline

get right pan of the instrument

◆ get_peak_l()

float get_peak_l ( ) const
inline

get the left peak of the instrument

◆ get_peak_r()

float get_peak_r ( ) const
inline

get the right peak of the instrument

◆ get_pitch_offset()

float get_pitch_offset ( ) const
inline

get the pitch offset of the instrument

◆ get_random_pitch_factor()

float get_random_pitch_factor ( ) const
inline

get the random pitch factor of the instrument

◆ get_volume()

float get_volume ( ) const
inline

get the volume of the instrument

◆ has_missing_samples()

bool has_missing_samples ( ) const
inline

◆ is_active()

bool is_active ( ) const
inline

get the active status of the instrument

◆ is_currently_exported()

bool is_currently_exported ( ) const
inline

◆ is_filter_active()

bool is_filter_active ( ) const
inline

get the status of the filter of the instrument

◆ is_metronome_instrument()

bool is_metronome_instrument ( ) const
inline

◆ is_muted()

bool is_muted ( ) const
inline

get muted status of the instrument

◆ is_preview_instrument()

bool is_preview_instrument ( ) const
inline

◆ is_queued()

bool is_queued ( ) const
inline

get the queued status of the instrument

◆ is_soloed()

bool is_soloed ( ) const
inline

get the soloed status of the instrument

◆ is_stop_notes()

bool is_stop_notes ( ) const
inline

get the stop notes of the instrument

◆ load_from() [1/3]

void load_from ( const QString &  drumkit_name,
const QString &  instrument_name,
bool  is_live = true,
Filesystem::Lookup  lookup = Filesystem::Lookup::stacked 
)

loads instrument from a given instrument within a given drumkit into a live Instrument object.

Parameters
drumkit_namethe drumkit to search the instrument in
instrument_namethe instrument within the drumkit to load samples from
is_liveis it performed while playing
lookupWhere to search (system/user folder or both) for the drumkit.

◆ load_from() [2/3]

void load_from ( Drumkit drumkit,
Instrument instrument,
bool  is_live = true 
)

loads instrument from a given instrument into a live Instrument object.

Parameters
drumkitthe drumkit the instrument belongs to
instrumentto load samples and members from
is_liveis it performed while playing

◆ load_from() [3/3]

Instrument * load_from ( XMLNode node,
const QString &  dk_path,
const QString &  dk_name 
)
static

load an instrument from an XMLNode

Parameters
nodethe XMLDode to read from
dk_paththe directory holding the drumkit data
dk_namethe name of the drumkit
Returns
a new Instrument instance set the name of the instrument

◆ load_instrument()

Instrument * load_instrument ( const QString &  drumkit_name,
const QString &  instrument_name,
Filesystem::Lookup  lookup = Filesystem::Lookup::stacked 
)
static

creates a new Instrument, loads samples from a given instrument within a given drumkit

Parameters
drumkit_namethe drumkit to search the instrument in
instrument_namethe instrument within the drumkit to load samples from
lookupWhere to search (system/user folder or both) for the drumkit.
Returns
a new Instrument instance

◆ load_samples()

void load_samples ( )

Calls the InstrumentLayer::load_sample() member function of all layers of each component of the Instrument.

◆ sample_selection_alg()

Instrument::SampleSelectionAlgo sample_selection_alg ( ) const
inline

◆ save_to()

void save_to ( XMLNode node,
int  component_id 
)

save the instrument within the given XMLNode

Parameters
nodethe XMLNode to feed
component_idIdentifier of the corresponding component.

◆ set_active()

void set_active ( bool  active)
inline

set the active status of the instrument

◆ set_adsr()

void set_adsr ( ADSR adsr)

set the ADSR of the instrument

◆ set_apply_velocity()

void set_apply_velocity ( bool  apply_velocity)
inline

◆ set_currently_exported()

void set_currently_exported ( bool  isCurrentlyExported)
inline

◆ set_drumkit_name()

void set_drumkit_name ( const QString &  name)
inline

get the name of the related drumkits

◆ set_filter_active()

void set_filter_active ( bool  active)
inline

activate the filter of the instrument

◆ set_filter_cutoff()

void set_filter_cutoff ( float  val)
inline

set the filter cutoff of the instrument

◆ set_filter_resonance()

void set_filter_resonance ( float  val)
inline

set the filter resonance of the instrument

◆ set_fx_level()

void set_fx_level ( float  level,
int  index 
)
inline

set the fx level of the instrument

◆ set_gain()

void set_gain ( float  gain)
inline

set gain of the instrument

◆ set_higher_cc()

void set_higher_cc ( int  message)
inline

◆ set_hihat_grp()

void set_hihat_grp ( int  hihat_grp)
inline

◆ set_id()

void set_id ( const int  id)
inline

get the id of the instrument

Sets __id to id.

Parameters
idUnique identifier of the instrument.

◆ set_is_metronome_instrument()

void set_is_metronome_instrument ( bool  isMetronome)
inline

Mark the instrument as metronome instrument.

◆ set_is_preview_instrument()

void set_is_preview_instrument ( bool  isPreview)
inline

Mark the instrument as hydrogen's preview instrument.

◆ set_lower_cc()

void set_lower_cc ( int  message)
inline

◆ set_midi_out_channel()

void set_midi_out_channel ( int  channel)
inline

set the midi out channel of the instrument

◆ set_midi_out_note()

void set_midi_out_note ( int  note)
inline

set the midi out note of the instrument

◆ set_missing_samples()

void set_missing_samples ( bool  bHasMissingSamples)
inline

◆ set_mute_group()

void set_mute_group ( int  group)
inline

set the mute group of the instrument

◆ set_muted()

void set_muted ( bool  muted)
inline

set muted status of the instrument

◆ set_name()

void set_name ( const QString &  name)
inline

get the name of the instrument

Sets the name of the Instrument __name.

Parameters
nameNew name.

◆ set_pan_l()

void set_pan_l ( float  val)
inline

set left pan of the instrument

◆ set_pan_r()

void set_pan_r ( float  val)
inline

set right pan of the instrument

◆ set_peak_l()

void set_peak_l ( float  val)
inline

set the left peak of the instrument

◆ set_peak_r()

void set_peak_r ( float  val)
inline

set the right peak of the instrument

◆ set_pitch_offset()

void set_pitch_offset ( float  val)
inline

set the pitch offset of the instrument

◆ set_random_pitch_factor()

void set_random_pitch_factor ( float  val)
inline

set the random pitch factor of the instrument

◆ set_sample_selection_alg()

void set_sample_selection_alg ( SampleSelectionAlgo  selected_algo)
inline

◆ set_soloed()

void set_soloed ( bool  soloed)
inline

set the soloed status of the instrument

◆ set_stop_notes()

void set_stop_notes ( bool  stopnotes)
inline

set the stop notes status of the instrument

◆ set_volume()

void set_volume ( float  volume)
inline

set the volume of the instrument

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

◆ unload_samples()

void unload_samples ( )

Calls the InstrumentLayer::unload_sample() member function of all layers of each component of the Instrument.

Field Documentation

◆ __active

bool __active
private

is the instrument active?

◆ __adsr

ADSR* __adsr
private

attack delay sustain release instance

◆ __apply_velocity

bool __apply_velocity
private

change the sample gain based on velocity

◆ __components

std::vector<InstrumentComponent*>* __components
private

◆ __current_instr_for_export

bool __current_instr_for_export
private

is the instrument currently being exported?

◆ __drumkit_name

QString __drumkit_name
private

the name of the drumkit this instrument belongs to

◆ __filter_active

bool __filter_active
private

is filter active?

◆ __filter_cutoff

float __filter_cutoff
private

filter cutoff (0..1)

◆ __filter_resonance

float __filter_resonance
private

filter resonant frequency (0..1)

◆ __fx_level

float __fx_level[MAX_FX]
private

Ladspa FX level array.

◆ __gain

float __gain
private

gain of the instrument

◆ __higher_cc

int __higher_cc
private

higher cc level

◆ __hihat_grp

int __hihat_grp
private

the instrument is part of a hihat

◆ __id

int __id
private

Identifier of an instrument, which should be unique.

It is set by set_id() and accessed via get_id().

◆ __is_metronome_instrument

bool __is_metronome_instrument
private

is the instrument an metronome instrument?

◆ __is_preview_instrument

bool __is_preview_instrument
private

is the instrument an hydrogen preview instrument?

◆ __lower_cc

int __lower_cc
private

lower cc level

◆ __midi_out_channel

int __midi_out_channel
private

midi out channel

◆ __midi_out_note

int __midi_out_note
private

midi out note

◆ __mute_group

int __mute_group
private

mute group of the instrument

◆ __muted

bool __muted
private

is the instrument muted?

◆ __name

QString __name
private

Name of the Instrument.

It is set by set_name() and accessed via get_name().

◆ __pan_l

float __pan_l
private

left pan of the instrument

◆ __pan_r

float __pan_r
private

right pan of the instrument

◆ __peak_l

float __peak_l
private

left current peak value

◆ __peak_r

float __peak_r
private

right current peak value

◆ __pitch_offset

float __pitch_offset
private

instrument main pitch offset

◆ __queued

int __queued
private

count the number of notes queued within Sampler::__playing_notes_queue or std::priority_queue m_songNoteQueue

◆ __random_pitch_factor

float __random_pitch_factor
private

random pitch factor

◆ __sample_selection_alg

SampleSelectionAlgo __sample_selection_alg
private

how Hydrogen will chose the sample to use

◆ __soloed

bool __soloed
private

is the instrument in solo mode?

◆ __stop_notes

bool __stop_notes
private

will the note automatically generate a note off after being on

◆ __volume

float __volume
private

volume of the instrument

◆ m_bHasMissingSamples

bool m_bHasMissingSamples
private

does the instrument have missing sample files?