|
hydrogen 1.2.3
|
Instrument class. More...
#include <Instrument.h>
Public Types | |
| enum | SampleSelectionAlgo { VELOCITY , ROUND_ROBIN , RANDOM } |
Public Member Functions | |
| Instrument (const int id=EMPTY_INSTR_ID, const QString &name="Empty Instrument", std::shared_ptr< ADSR > adsr=nullptr) | |
| constructor | |
| Instrument (std::shared_ptr< Instrument > other) | |
| copy constructor | |
| ~Instrument () | |
| destructor | |
| std::shared_ptr< ADSR > | copy_adsr () const |
| get a copy of the ADSR of the instrument | |
| void | dequeue () |
| dequeue the instrument | |
| void | enqueue () |
| enqueue the instrument | |
| std::shared_ptr< ADSR > | get_adsr () const |
| get the ADSR of the instrument | |
| bool | get_apply_velocity () const |
| std::shared_ptr< InstrumentComponent > | get_component (int DrumkitComponentID) |
| std::vector< std::shared_ptr< InstrumentComponent > > * | get_components () |
| const QString & | get_drumkit_name () const |
| QString | get_drumkit_path () const |
| set the name of the related drumkit | |
| float | get_filter_cutoff () const |
| get the filter cutoff of the instrument | |
| float | get_filter_resonance () const |
| get the filter resonance of the instrument | |
| float | get_fx_level (int index) const |
| get the fx level of the instrument | |
| float | get_gain () const |
| get gain of the instrument | |
| int | get_higher_cc () const |
| set the path of the related drumkit | |
| int | get_hihat_grp () const |
| int | get_id () const |
| Returns __id. | |
| int | get_lower_cc () const |
| int | get_midi_out_channel () const |
| get the midi out channel of the instrument | |
| int | get_midi_out_note () const |
| get the midi out note of the instrument | |
| int | get_mute_group () const |
| get the mute group of the instrument | |
| const QString & | get_name () const |
| set the id of the instrument | |
| float | get_peak_l () const |
| get the left peak of the instrument | |
| float | get_peak_r () const |
| get the right peak of the instrument | |
| float | get_pitch_offset () const |
| get the pitch offset of the instrument | |
| float | get_random_pitch_factor () const |
| get the random pitch factor of the instrument | |
| float | get_volume () const |
| get the volume of the instrument | |
| float | getPan () const |
| get pan of the instrument | |
| float | getPanWithRangeFrom0To1 () const |
| get pan of the instrument scaling and translating the range from [-1;1] to [0;1] | |
| bool | has_missing_samples () const |
| bool | hasSamples () const |
| Whether the instrument contains at least one non-missing sample. | |
| bool | is_active () const |
| get the active status of the instrument | |
| bool | is_currently_exported () const |
| bool | is_filter_active () const |
| get the status of the filter of the instrument | |
| bool | is_metronome_instrument () const |
| bool | is_muted () const |
| get muted status of the instrument | |
| bool | is_preview_instrument () const |
| bool | is_queued () const |
| get the queued status of the instrument | |
| bool | is_soloed () const |
| get the soloed status of the instrument | |
| bool | is_stop_notes () const |
| get the stop notes of the instrument | |
| void | load_from (const QString &drumkit_path, const QString &instrument_name) |
loads instrument from a given instrument within a given drumkit into a live Instrument object. | |
| void | load_from (std::shared_ptr< Drumkit > drumkit, std::shared_ptr< Instrument > instrument) |
loads instrument from a given instrument into a live Instrument object. | |
| void | load_samples (float fBpm=120) |
| Calls the InstrumentLayer::load_sample() member function of all layers of each component of the Instrument. | |
| SampleSelectionAlgo | sample_selection_alg () const |
| void | save_to (XMLNode *node, int component_id, bool bRecentVersion=true, bool bFull=false) |
| save the instrument within the given XMLNode | |
| void | set_active (bool active) |
| set the active status of the instrument | |
| void | set_adsr (std::shared_ptr< ADSR > adsr) |
| set the ADSR of the instrument | |
| void | set_apply_velocity (bool apply_velocity) |
| void | set_currently_exported (bool isCurrentlyExported) |
| void | set_drumkit_name (const QString &sName) |
| get the name of the related drumkits | |
| void | set_drumkit_path (const QString &sPath) |
| get the path of the related drumkits | |
| void | set_filter_active (bool active) |
| activate the filter of the instrument | |
| void | set_filter_cutoff (float val) |
| set the filter cutoff of the instrument | |
| void | set_filter_resonance (float val) |
| set the filter resonance of the instrument | |
| void | set_fx_level (float level, int index) |
| set the fx level of the instrument | |
| void | set_gain (float gain) |
| set gain of the instrument | |
| void | set_higher_cc (int message) |
| void | set_hihat_grp (int hihat_grp) |
| void | set_id (const int id) |
| get the id of the instrument | |
| void | set_is_metronome_instrument (bool isMetronome) |
| Mark the instrument as metronome instrument. | |
| void | set_is_preview_instrument (bool isPreview) |
| Mark the instrument as hydrogen's preview instrument. | |
| void | set_lower_cc (int message) |
| void | set_midi_out_channel (int channel) |
| set the midi out channel of the instrument | |
| void | set_midi_out_note (int note) |
| set the midi out note of the instrument | |
| void | set_missing_samples (bool bHasMissingSamples) |
| void | set_mute_group (int group) |
| set the mute group of the instrument | |
| void | set_muted (bool muted) |
| set muted status of the instrument | |
| void | set_name (const QString &name) |
| get the name of the instrument | |
| void | set_peak_l (float val) |
| set the left peak of the instrument | |
| void | set_peak_r (float val) |
| set the right peak of the instrument | |
| void | set_pitch_offset (float val) |
| set the pitch offset of the instrument | |
| void | set_random_pitch_factor (float val) |
| set the random pitch factor of the instrument | |
| void | set_sample_selection_alg (SampleSelectionAlgo selected_algo) |
| void | set_soloed (bool soloed) |
| set the soloed status of the instrument | |
| void | set_stop_notes (bool stopnotes) |
| set the stop notes status of the instrument | |
| void | set_volume (float volume) |
| set the volume of the instrument | |
| void | setPan (float val) |
| set pan of the instrument | |
| void | setPanWithRangeFrom0To1 (float fVal) |
| set pan of the instrument, assuming the input range in [0;1] | |
| QString | toQString (const QString &sPrefix="", bool bShort=true) const override |
| Formatted string version for debugging purposes. | |
| void | unload_samples () |
| Calls the InstrumentLayer::unload_sample() member function of all layers of each component of the Instrument. | |
Public Member Functions inherited from Object< Instrument > | |
| Object () | |
| Object (const Object< Instrument > &other) | |
Public Member Functions inherited from Base | |
| Base () | |
| Base (const Base &other) | |
| virtual const char * | class_name () const |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. | |
Static Public Member Functions | |
| static std::shared_ptr< Instrument > | load_from (XMLNode *pNode, const QString &sDrumkitPath="", const QString &sDrumkitName="", const License &license=License(), bool bSilent=false) |
| load an instrument from an XMLNode | |
| static std::shared_ptr< Instrument > | load_instrument (const QString &drumkit_path, const QString &instrument_name) |
| creates a new Instrument, loads samples from a given instrument within a given drumkit | |
Static Public Member Functions inherited from Base | |
| static const char * | _class_name () |
| return the class name | |
| static QString | base_clock (const QString &sMsg) |
| Measures the current time and stores it in __last_clock. | |
| static QString | base_clock_in (const QString &sMsg) |
| static int | bootstrap (Logger *logger, bool count=false) |
| must be called before any Object instantiation ! | |
| static bool | count_active () |
| static int | getAliveObjectCount () |
| static object_map_t | getObjectMap () |
| static Logger * | logger () |
| return the logger instance | |
| static int | objects_count () |
| static void | printObjectMapDiff (object_map_t map) |
| Creates the difference between a snapshot of the object map and its current state and prints it to std::cout. | |
| static void | set_count (bool flag) |
| enable/disable class instances counting | |
| static void | write_objects_map_to (std::ostream &out, object_map_t *map=nullptr) |
| output the full objects map to a given ostream | |
| static void | write_objects_map_to_cerr () |
| output objects map to stderr | |
Private Attributes | |
| bool | __active |
| is the instrument active? | |
| std::shared_ptr< ADSR > | __adsr |
| attack delay sustain release instance | |
| bool | __apply_velocity |
| change the sample gain based on velocity | |
| std::vector< std::shared_ptr< InstrumentComponent > > * | __components |
| InstrumentLayer array. | |
| bool | __current_instr_for_export |
| is the instrument currently being exported? | |
| QString | __drumkit_name |
| Name of the #Drumkit found at __drumkit_path. | |
| QString | __drumkit_path |
| Path of the #Drumkit this Instrument belongs to. | |
| bool | __filter_active |
| is filter active? | |
| float | __filter_cutoff |
| filter cutoff (0..1) | |
| float | __filter_resonance |
| filter resonant frequency (0..1) | |
| float | __fx_level [MAX_FX] |
| Ladspa FX level array. | |
| float | __gain |
| gain of the instrument | |
| int | __higher_cc |
| higher cc level | |
| int | __hihat_grp |
| the instrument is part of a hihat | |
| int | __id |
| Identifier of an instrument, which should be unique. | |
| bool | __is_metronome_instrument |
| is the instrument an metronome instrument? | |
| bool | __is_preview_instrument |
| is the instrument an hydrogen preview instrument? | |
| int | __lower_cc |
| lower cc level | |
| int | __midi_out_channel |
| midi out channel | |
| int | __midi_out_note |
| midi out note | |
| int | __mute_group |
| mute group of the instrument | |
| bool | __muted |
| is the instrument muted? | |
| QString | __name |
| Name of the Instrument. | |
| float | __peak_l |
| left current peak value | |
| float | __peak_r |
| right current peak value | |
| float | __pitch_offset |
| instrument main pitch offset | |
| int | __queued |
| count the number of notes queued within Sampler::__playing_notes_queue or std::priority_queue m_songNoteQueue | |
| float | __random_pitch_factor |
| Factor to scale the random contribution when humanizing pitch between 0 and AudioEngine::fHumanizePitchSD. | |
| SampleSelectionAlgo | __sample_selection_alg |
| how Hydrogen will chose the sample to use | |
| bool | __soloed |
| is the instrument in solo mode? | |
| bool | __stop_notes |
| will the note automatically generate a note off after being on | |
| float | __volume |
| volume of the instrument | |
| bool | m_bHasMissingSamples |
| does the instrument have missing sample files? | |
| float | m_fPan |
| pan of the instrument, [-1;1] from left to right, as requested by Sampler PanLaws | |
Additional Inherited Members | |
Static Public Attributes inherited from Base | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. | |
Protected Member Functions inherited from Object< Instrument > | |
| ~Object () | |
Protected Member Functions inherited from Base | |
| ~Base () | |
Static Protected Member Functions inherited from Base | |
| static void | registerClass (const char *name, const atomic_obj_cpt_t *counters) |
Static Protected Attributes inherited from Base | |
| static bool | __count = false |
| should we count class instances | |
| static timeval | __last_clock = { 0, 0 } |
| static Logger * | __logger = nullptr |
Instrument class.
Definition at line 54 of file Instrument.h.
| enum SampleSelectionAlgo |
| Enumerator | |
|---|---|
| VELOCITY | |
| ROUND_ROBIN | |
| RANDOM | |
Definition at line 58 of file Instrument.h.
| Instrument | ( | const int | id = EMPTY_INSTR_ID, |
| const QString & | name = "Empty Instrument", | ||
| std::shared_ptr< ADSR > | adsr = nullptr ) |
constructor
| id | the id of this instrument |
| name | the name of the instrument |
| adsr | attack decay sustain release instance |
Definition at line 45 of file Instrument.cpp.
| Instrument | ( | std::shared_ptr< Instrument > | other | ) |
copy constructor
Definition at line 96 of file Instrument.cpp.
| ~Instrument | ( | ) |
destructor
Definition at line 141 of file Instrument.cpp.
|
inline |
get a copy of the ADSR of the instrument
Definition at line 417 of file Instrument.h.
|
inline |
dequeue the instrument
Definition at line 615 of file Instrument.h.
|
inline |
enqueue the instrument
Definition at line 610 of file Instrument.h.
|
inline |
get the ADSR of the instrument
Definition at line 412 of file Instrument.h.
|
inline |
Definition at line 721 of file Instrument.h.
| std::shared_ptr< InstrumentComponent > get_component | ( | int | DrumkitComponentID | ) |
Definition at line 653 of file Instrument.cpp.
|
inline |
Definition at line 711 of file Instrument.h.
|
inline |
Definition at line 686 of file Instrument.h.
| QString get_drumkit_path | ( | ) | const |
set the name of the related drumkit
Definition at line 664 of file Instrument.cpp.
|
inline |
get the filter cutoff of the instrument
Definition at line 535 of file Instrument.h.
|
inline |
get the filter resonance of the instrument
Definition at line 525 of file Instrument.h.
|
inline |
get the fx level of the instrument
Definition at line 565 of file Instrument.h.
|
inline |
get gain of the instrument
Definition at line 495 of file Instrument.h.
|
inline |
set the path of the related drumkit
Definition at line 671 of file Instrument.h.
|
inline |
Definition at line 651 of file Instrument.h.
|
inline |
|
inline |
Definition at line 661 of file Instrument.h.
|
inline |
get the midi out channel of the instrument
Definition at line 432 of file Instrument.h.
|
inline |
get the midi out note of the instrument
Definition at line 450 of file Instrument.h.
|
inline |
get the mute group of the instrument
Definition at line 427 of file Instrument.h.
|
inline |
set the id of the instrument
Access the name of the Instrument.
Definition at line 395 of file Instrument.h.
|
inline |
get the left peak of the instrument
Definition at line 545 of file Instrument.h.
|
inline |
get the right peak of the instrument
Definition at line 555 of file Instrument.h.
|
inline |
get the pitch offset of the instrument
Definition at line 585 of file Instrument.h.
|
inline |
get the random pitch factor of the instrument
Definition at line 580 of file Instrument.h.
|
inline |
get the volume of the instrument
Definition at line 505 of file Instrument.h.
|
inline |
get pan of the instrument
Definition at line 485 of file Instrument.h.
|
inline |
get pan of the instrument scaling and translating the range from [-1;1] to [0;1]
Definition at line 195 of file Instrument.h.
|
inline |
Definition at line 308 of file Instrument.h.
| bool hasSamples | ( | ) | const |
Whether the instrument contains at least one non-missing sample.
Definition at line 669 of file Instrument.cpp.
|
inline |
get the active status of the instrument
Definition at line 595 of file Instrument.h.
|
inline |
Definition at line 726 of file Instrument.h.
|
inline |
get the status of the filter of the instrument
Definition at line 515 of file Instrument.h.
|
inline |
Definition at line 701 of file Instrument.h.
|
inline |
get muted status of the instrument
Definition at line 469 of file Instrument.h.
|
inline |
Definition at line 691 of file Instrument.h.
|
inline |
get the queued status of the instrument
Definition at line 621 of file Instrument.h.
|
inline |
get the soloed status of the instrument
Definition at line 605 of file Instrument.h.
|
inline |
get the stop notes of the instrument
Definition at line 631 of file Instrument.h.
| void load_from | ( | const QString & | drumkit_path, |
| const QString & | instrument_name ) |
loads instrument from a given instrument within a given drumkit into a live Instrument object.
| drumkit_path | the drumkit to search the instrument in |
| instrument_name | the instrument within the drumkit to load samples from for the drumkit. |
Definition at line 234 of file Instrument.cpp.
| void load_from | ( | std::shared_ptr< Drumkit > | drumkit, |
| std::shared_ptr< Instrument > | instrument ) |
loads instrument from a given instrument into a live Instrument object.
| drumkit | the drumkit the instrument belongs to |
| instrument | to load samples and members from |
| lookup | Where to search (system/user folder or both) for the drumkit. |
Definition at line 153 of file Instrument.cpp.
|
static |
load an instrument from an XMLNode
| pNode | the XMLDode to read from |
| sDrumkitPath | the directory holding the drumkit data. If empty, it will be read from pNode. |
| sDrumkitName | Name of the drumkit found in sDrumkitPath. |
| license | License assigned to all Samples that will be loaded. If empty, the license will be read from sDrumkitPath. |
| bSilent | if set to true, all log messages except of errors and warnings are suppressed. |
Definition at line 261 of file Instrument.cpp.
|
static |
creates a new Instrument, loads samples from a given instrument within a given drumkit
| drumkit_name | the drumkit to search the instrument in |
| instrument_name | the instrument within the drumkit to load samples from |
Definition at line 146 of file Instrument.cpp.
| void load_samples | ( | float | fBpm = 120 | ) |
Calls the InstrumentLayer::load_sample() member function of all layers of each component of the Instrument.
Definition at line 551 of file Instrument.cpp.
|
inline |
Definition at line 641 of file Instrument.h.
| void save_to | ( | XMLNode * | node, |
| int | component_id, | ||
| bool | bRecentVersion = true, | ||
| bool | bFull = false ) |
save the instrument within the given XMLNode
| node | the XMLNode to feed |
| component_id | Identifier of the corresponding component. |
| bRecentVersion | Whether the drumkit format should be supported by Hydrogen 0.9.7 or higher (whether it should be composed of DrumkitComponents). |
| bFull | Whether to write all parameters of the contained #Sample as well. This will be done when storing an Instrument as part of a #Song but not when storing as part of a #Drumkit. |
Definition at line 575 of file Instrument.cpp.
|
inline |
set the active status of the instrument
Definition at line 590 of file Instrument.h.
| void set_adsr | ( | std::shared_ptr< ADSR > | adsr | ) |
set the ADSR of the instrument
Definition at line 648 of file Instrument.cpp.
|
inline |
Definition at line 716 of file Instrument.h.
|
inline |
Definition at line 731 of file Instrument.h.
|
inline |
get the name of the related drumkits
Definition at line 681 of file Instrument.h.
|
inline |
get the path of the related drumkits
Definition at line 676 of file Instrument.h.
|
inline |
activate the filter of the instrument
Definition at line 510 of file Instrument.h.
|
inline |
set the filter cutoff of the instrument
Definition at line 530 of file Instrument.h.
|
inline |
set the filter resonance of the instrument
Definition at line 520 of file Instrument.h.
|
inline |
set the fx level of the instrument
Definition at line 560 of file Instrument.h.
|
inline |
set gain of the instrument
Definition at line 490 of file Instrument.h.
|
inline |
Definition at line 666 of file Instrument.h.
|
inline |
Definition at line 646 of file Instrument.h.
|
inline |
get the id of the instrument
Sets __id to id.
| id | Unique identifier of the instrument. |
Definition at line 401 of file Instrument.h.
|
inline |
Mark the instrument as metronome instrument.
Definition at line 706 of file Instrument.h.
|
inline |
Mark the instrument as hydrogen's preview instrument.
Definition at line 696 of file Instrument.h.
|
inline |
Definition at line 656 of file Instrument.h.
|
inline |
set the midi out channel of the instrument
Definition at line 437 of file Instrument.h.
|
inline |
set the midi out note of the instrument
Definition at line 455 of file Instrument.h.
|
inline |
Definition at line 309 of file Instrument.h.
|
inline |
set the mute group of the instrument
Definition at line 422 of file Instrument.h.
|
inline |
set muted status of the instrument
Definition at line 464 of file Instrument.h.
|
inline |
get the name of the instrument
Sets the name of the Instrument __name.
| name | New name. |
Definition at line 389 of file Instrument.h.
|
inline |
set the left peak of the instrument
Definition at line 540 of file Instrument.h.
|
inline |
set the right peak of the instrument
Definition at line 550 of file Instrument.h.
|
inline |
set the pitch offset of the instrument
Definition at line 575 of file Instrument.h.
|
inline |
set the random pitch factor of the instrument
Definition at line 570 of file Instrument.h.
|
inline |
Definition at line 636 of file Instrument.h.
|
inline |
set the soloed status of the instrument
Definition at line 600 of file Instrument.h.
|
inline |
set the stop notes status of the instrument
Definition at line 626 of file Instrument.h.
|
inline |
set the volume of the instrument
Definition at line 500 of file Instrument.h.
|
inline |
set pan of the instrument
Definition at line 474 of file Instrument.h.
|
inline |
set pan of the instrument, assuming the input range in [0;1]
Definition at line 189 of file Instrument.h.
|
overridevirtual |
Formatted string version for debugging purposes.
| sPrefix | String prefix which will be added in front of every new line |
| bShort | Instead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks. |
Reimplemented from Base.
Definition at line 685 of file Instrument.cpp.
| void unload_samples | ( | ) |
Calls the InstrumentLayer::unload_sample() member function of all layers of each component of the Instrument.
Definition at line 563 of file Instrument.cpp.
|
private |
is the instrument active?
Definition at line 369 of file Instrument.h.
|
private |
attack delay sustain release instance
Definition at line 353 of file Instrument.h.
|
private |
change the sample gain based on velocity
Definition at line 381 of file Instrument.h.
|
private |
InstrumentLayer array.
Definition at line 380 of file Instrument.h.
|
private |
is the instrument currently being exported?
Definition at line 382 of file Instrument.h.
|
private |
Name of the #Drumkit found at __drumkit_path.
This helper variable should only be used during Instrument loading. It ensures portability of songs as absolute paths only serve for unique identifiers locally and also ensures backward compatibility.
Definition at line 347 of file Instrument.h.
|
private |
Path of the #Drumkit this Instrument belongs to.
An instrument belonging to a #Drumkit uses relative paths for its #Sample. Therefore we have to take care of mapping them to absolute paths ourselves in case instruments of several drumkits are mixed in one #Song.
Definition at line 339 of file Instrument.h.
|
private |
is filter active?
Definition at line 354 of file Instrument.h.
|
private |
filter cutoff (0..1)
Definition at line 355 of file Instrument.h.
|
private |
filter resonant frequency (0..1)
Definition at line 356 of file Instrument.h.
|
private |
Ladspa FX level array.
Definition at line 374 of file Instrument.h.
|
private |
gain of the instrument
Definition at line 348 of file Instrument.h.
|
private |
higher cc level
Definition at line 377 of file Instrument.h.
|
private |
the instrument is part of a hihat
Definition at line 375 of file Instrument.h.
|
private |
Identifier of an instrument, which should be unique.
It is set by set_id() and accessed via get_id().
Definition at line 328 of file Instrument.h.
|
private |
is the instrument an metronome instrument?
Definition at line 379 of file Instrument.h.
|
private |
is the instrument an hydrogen preview instrument?
Definition at line 378 of file Instrument.h.
|
private |
lower cc level
Definition at line 376 of file Instrument.h.
|
private |
midi out channel
Definition at line 366 of file Instrument.h.
|
private |
midi out note
Definition at line 365 of file Instrument.h.
|
private |
mute group of the instrument
Definition at line 372 of file Instrument.h.
|
private |
is the instrument muted?
Definition at line 371 of file Instrument.h.
|
private |
Name of the Instrument.
It is set by set_name() and accessed via get_name().
Definition at line 331 of file Instrument.h.
|
private |
left current peak value
Definition at line 351 of file Instrument.h.
|
private |
right current peak value
Definition at line 352 of file Instrument.h.
|
private |
instrument main pitch offset
Definition at line 364 of file Instrument.h.
|
private |
count the number of notes queued within Sampler::__playing_notes_queue or std::priority_queue m_songNoteQueue
Definition at line 373 of file Instrument.h.
|
private |
Factor to scale the random contribution when humanizing pitch between 0 and AudioEngine::fHumanizePitchSD.
Supported range [0,1].
Definition at line 363 of file Instrument.h.
|
private |
how Hydrogen will chose the sample to use
Definition at line 368 of file Instrument.h.
|
private |
is the instrument in solo mode?
Definition at line 370 of file Instrument.h.
|
private |
will the note automatically generate a note off after being on
Definition at line 367 of file Instrument.h.
|
private |
volume of the instrument
Definition at line 349 of file Instrument.h.
|
private |
does the instrument have missing sample files?
Definition at line 383 of file Instrument.h.
|
private |
pan of the instrument, [-1;1] from left to right, as requested by Sampler PanLaws
Definition at line 350 of file Instrument.h.