23#ifndef H2C_INSTRUMENT_H
24#define H2C_INSTRUMENT_H
34#define EMPTY_INSTR_ID -1
36#define METRONOME_INSTR_ID -2
37#define PLAYBACK_INSTR_ID -3
45class DrumkitComponent;
47class InstrumentComponent;
70 Instrument(
const int id=
EMPTY_INSTR_ID,
const QString& name=
"Empty Instrument", std::shared_ptr<ADSR> adsr=
nullptr );
72 Instrument( std::shared_ptr<Instrument> other );
82 static std::shared_ptr<Instrument>
load_instrument(
const QString& drumkit_path,
const QString& instrument_name );
90 void load_from(
const QString& drumkit_path,
const QString& instrument_name );
99 void load_from( std::shared_ptr<Drumkit> drumkit, std::shared_ptr<Instrument> instrument );
127 void save_to(
XMLNode* node,
int component_id,
bool bRecentVersion =
true,
bool bFull =
false );
144 const QString& sDrumkitPath =
"",
145 const QString& sDrumkitName =
"",
147 bool bSilent =
false );
150 void set_name(
const QString& name );
155 void set_id(
const int id );
160 void set_adsr( std::shared_ptr<ADSR> adsr );
162 std::shared_ptr<ADSR>
get_adsr()
const;
190 this->
setPan( -1.f + 2.f * fVal );
196 return 0.5f * ( 1.f +
m_fPan );
299 std::vector<std::shared_ptr<InstrumentComponent>>*
get_components();
300 std::shared_ptr<InstrumentComponent>
get_component(
int DrumkitComponentID );
322 QString
toQString(
const QString& sPrefix =
"",
bool bShort =
true )
const override;
419 return std::make_shared<ADSR>(
__adsr );
443 ERRORLOG( QString(
"midi out channel [%1] out of bounds [%2,%3]" )
460 ERRORLOG( QString(
"midi out note %1 out of bounds" ).arg( note ) );
478 }
else if ( val < -1.0 ) {
bool has_missing_samples() const
QString __name
Name of the Instrument.
float __peak_r
right current peak value
float get_filter_resonance() const
get the filter resonance of the instrument
void set_is_metronome_instrument(bool isMetronome)
Mark the instrument as metronome instrument.
float __pitch_offset
instrument main pitch offset
float get_filter_cutoff() const
get the filter cutoff of the instrument
int get_mute_group() const
get the mute group of the instrument
void set_name(const QString &name)
get the name of the instrument
int __hihat_grp
the instrument is part of a hihat
float get_peak_r() const
get the right peak of the instrument
void set_pitch_offset(float val)
set the pitch offset of the instrument
float getPanWithRangeFrom0To1() const
get pan of the instrument scaling and translating the range from [-1;1] to [0;1]
bool __active
is the instrument active?
const QString & get_name() const
set the id of the instrument
float get_gain() const
get gain of the instrument
void set_drumkit_name(const QString &sName)
get the name of the related drumkits
bool __is_preview_instrument
is the instrument an hydrogen preview instrument?
float get_pitch_offset() const
get the pitch offset of the instrument
bool get_apply_velocity() const
void set_sample_selection_alg(SampleSelectionAlgo selected_algo)
void enqueue()
enqueue the instrument
bool is_stop_notes() const
get the stop notes of the instrument
bool __is_metronome_instrument
is the instrument an metronome instrument?
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
void set_fx_level(float level, int index)
set the fx level of the instrument
bool __stop_notes
will the note automatically generate a note off after being on
void set_filter_resonance(float val)
set the filter resonance of the instrument
void set_is_preview_instrument(bool isPreview)
Mark the instrument as hydrogen's preview instrument.
float m_fPan
pan of the instrument, [-1;1] from left to right, as requested by Sampler PanLaws
bool __soloed
is the instrument in solo mode?
int __midi_out_channel
midi out channel
float __random_pitch_factor
Factor to scale the random contribution when humanizing pitch between 0 and AudioEngine::fHumanizePit...
void set_drumkit_path(const QString &sPath)
get the path of the related drumkits
int __mute_group
mute group of the instrument
int __id
Identifier of an instrument, which should be unique.
void set_soloed(bool soloed)
set the soloed status of the instrument
void set_adsr(std::shared_ptr< ADSR > adsr)
set the ADSR of the instrument
int get_higher_cc() const
set the path of the related drumkit
void set_volume(float volume)
set the volume of the instrument
float __filter_resonance
filter resonant frequency (0..1)
float __filter_cutoff
filter cutoff (0..1)
void set_random_pitch_factor(float val)
set the random pitch factor of the instrument
QString __drumkit_name
Name of the #Drumkit found at __drumkit_path.
float __fx_level[MAX_FX]
Ladspa FX level array.
void set_filter_active(bool active)
activate the filter of the instrument
SampleSelectionAlgo __sample_selection_alg
how Hydrogen will chose the sample to use
void load_samples(float fBpm=120)
Calls the InstrumentLayer::load_sample() member function of all layers of each component of the Instr...
bool __muted
is the instrument muted?
bool is_currently_exported() const
int get_hihat_grp() const
bool is_muted() const
get muted status of the instrument
std::shared_ptr< ADSR > copy_adsr() const
get a copy of the ADSR of the instrument
bool __filter_active
is filter active?
void dequeue()
dequeue the instrument
bool is_queued() const
get the queued status of the instrument
float __gain
gain of the instrument
QString __drumkit_path
Path of the #Drumkit this Instrument belongs to.
std::shared_ptr< InstrumentComponent > get_component(int DrumkitComponentID)
float get_fx_level(int index) const
get the fx level of the instrument
void set_midi_out_channel(int channel)
set the midi out channel of the instrument
void set_apply_velocity(bool apply_velocity)
bool m_bHasMissingSamples
does the instrument have missing sample files?
bool is_soloed() const
get the soloed status of the instrument
int get_midi_out_note() const
get the midi out note of the instrument
void set_stop_notes(bool stopnotes)
set the stop notes status of the instrument
void set_gain(float gain)
set gain of the instrument
const QString & get_drumkit_name() const
void set_midi_out_note(int note)
set the midi out note of the instrument
bool is_preview_instrument() const
void set_peak_r(float val)
set the right peak of the instrument
int __higher_cc
higher cc level
void set_hihat_grp(int hihat_grp)
void set_id(const int id)
get the id of the instrument
float get_peak_l() const
get the left peak of the instrument
void setPanWithRangeFrom0To1(float fVal)
set pan of the instrument, assuming the input range in [0;1]
float __peak_l
left current peak value
float get_random_pitch_factor() const
get the random pitch factor of the instrument
void setPan(float val)
set pan of the instrument
void set_mute_group(int group)
set the mute group of the instrument
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
std::shared_ptr< ADSR > get_adsr() const
get the ADSR of the instrument
bool __current_instr_for_export
is the instrument currently being exported?
void set_active(bool active)
set the active status of the instrument
int __lower_cc
lower cc level
std::vector< std::shared_ptr< InstrumentComponent > > * __components
InstrumentLayer array.
std::shared_ptr< ADSR > __adsr
attack delay sustain release instance
void set_currently_exported(bool isCurrentlyExported)
void set_filter_cutoff(float val)
set the filter cutoff of the instrument
void unload_samples()
Calls the InstrumentLayer::unload_sample() member function of all layers of each component of the Ins...
float __volume
volume of the instrument
Instrument(const int id=EMPTY_INSTR_ID, const QString &name="Empty Instrument", std::shared_ptr< ADSR > adsr=nullptr)
constructor
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 set_peak_l(float val)
set the left peak of the instrument
bool is_filter_active() const
get the status of the filter of the instrument
int __queued
count the number of notes queued within Sampler::__playing_notes_queue or std::priority_queue m_songN...
void set_missing_samples(bool bHasMissingSamples)
void set_higher_cc(int message)
void save_to(XMLNode *node, int component_id, bool bRecentVersion=true, bool bFull=false)
save the instrument within the given XMLNode
bool __apply_velocity
change the sample gain based on velocity
SampleSelectionAlgo sample_selection_alg() const
void set_lower_cc(int message)
std::vector< std::shared_ptr< InstrumentComponent > > * get_components()
bool is_metronome_instrument() const
int get_id() const
Returns __id.
bool is_active() const
get the active status of the instrument
float getPan() const
get pan of the instrument
QString get_drumkit_path() const
set the name of the related drumkit
int get_midi_out_channel() const
get the midi out channel of the instrument
void set_muted(bool muted)
set muted status of the instrument
int __midi_out_note
midi out note
float get_volume() const
get the volume of the instrument
bool hasSamples() const
Whether the instrument contains at least one non-missing sample.
Wrapper class to help Hydrogen deal with the license information specified in a drumkit.
XMLNode is a subclass of QDomNode with read and write values methods.
#define MAX_FX
Maximum number of effects.
#define MIDI_OUT_NOTE_MIN
#define MIDI_OUT_CHANNEL_MAX
#define MIDI_OUT_CHANNEL_MIN
#define MIDI_OUT_NOTE_MAX