hydrogen 1.1.1
InstrumentList Class Reference

InstrumentList is a collection of instruments used within a song, a drumkit, ... More...

#include <InstrumentList.h>

Inheritance diagram for InstrumentList:
Object

Public Member Functions

 InstrumentList ()
 constructor More...
 
 ~InstrumentList ()
 destructor More...
 
 InstrumentList (InstrumentList *other)
 copy constructor More...
 
int size () const
 returns the numbers of instruments More...
 
void operator<< (Instrument *instrument)
 add an instrument to the list More...
 
Instrumentoperator[] (int idx)
 get an instrument from the list More...
 
void add (Instrument *instrument)
 add an instrument to the list More...
 
void insert (int idx, Instrument *instrument)
 insert an instrument into the list More...
 
bool is_valid_index (int idx) const
 check if there is a idx is a valid index for this list without throwing an error messaage More...
 
Instrumentget (int idx)
 get an instrument from the list More...
 
Instrumentdel (int idx)
 remove the instrument at a given index, does not delete it More...
 
Instrumentdel (Instrument *instrument)
 remove an instrument from the list, does not delete it More...
 
int index (Instrument *instrument)
 get the index of an instrument within the instruments More...
 
Instrumentfind (const int i)
 find an instrument within the instruments More...
 
Instrumentfind (const QString &name)
 find an instrument within the instruments More...
 
InstrumentfindMidiNote (const int note)
 find an instrument which play the given midi note More...
 
void swap (int idx_a, int idx_b)
 swap the instruments of two different indexes More...
 
void move (int idx_a, int idx_b)
 move an instrument from a position to another More...
 
void load_samples ()
 Calls the Instrument::load_samples() member function of all Instruments in __instruments. More...
 
void unload_samples ()
 Calls the Instrument::unload_samples() member function of all Instruments in __instruments. More...
 
void save_to (XMLNode *node, int component_id)
 save the instrument list within the given XMLNode More...
 
void fix_issue_307 ()
 Fix GitHub issue #307, so called "Hi Bongo fiasco". More...
 
bool has_all_midi_notes_same () const
 Check if all instruments have assigned the same MIDI out note. More...
 
void set_default_midi_out_notes ()
 Set each instrument consecuteve MIDI out notes, starting from 36. 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 InstrumentListload_from (XMLNode *node, const QString &dk_path, const QString &dk_name)
 load an instrument list 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

std::vector< Instrument * > __instruments
 the list of instruments 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

InstrumentList is a collection of instruments used within a song, a drumkit, ...

Constructor & Destructor Documentation

◆ InstrumentList() [1/2]

constructor

◆ ~InstrumentList()

destructor

◆ InstrumentList() [2/2]

copy constructor

Parameters
other

Member Function Documentation

◆ add()

void add ( Instrument instrument)

add an instrument to the list

Parameters
instrumenta pointer to the instrument to add

◆ del() [1/2]

Instrument * del ( Instrument instrument)

remove an instrument from the list, does not delete it

Parameters
instrumentthe instrument to be removed
Returns
a pointer to the removed instrument, 0 if not found

◆ del() [2/2]

Instrument * del ( int  idx)

remove the instrument at a given index, does not delete it

Parameters
idxthe index
Returns
a pointer to the removed instrument

◆ find() [1/2]

Instrument * find ( const int  i)

find an instrument within the instruments

Parameters
ithe id of the instrument to find
Returns
0 if not found

◆ find() [2/2]

Instrument * find ( const QString &  name)

find an instrument within the instruments

Parameters
namethe name of the instrument to find
Returns
0 if not found

◆ findMidiNote()

Instrument * findMidiNote ( const int  note)

find an instrument which play the given midi note

Parameters
notethe Midi note of the instrument to find
Returns
0 if not found

◆ fix_issue_307()

void fix_issue_307 ( )

Fix GitHub issue #307, so called "Hi Bongo fiasco".

Check whether the same MIDI note is assignedto every instrument - that condition makes MIDI export unusable. When so, assign each instrument consecutive MIDI note starting from 36.

◆ get()

Instrument * get ( int  idx)

get an instrument from the list

Parameters
idxthe index to get the instrument from

◆ has_all_midi_notes_same()

bool has_all_midi_notes_same ( ) const

Check if all instruments have assigned the same MIDI out note.

◆ index()

int index ( Instrument instrument)

get the index of an instrument within the instruments

Parameters
instrumenta pointer to the instrument to find
Returns
-1 if not found

◆ insert()

void insert ( int  idx,
Instrument instrument 
)

insert an instrument into the list

Parameters
idxthe index to insert the instrument at
instrumenta pointer to the instrument to add

◆ is_valid_index()

bool is_valid_index ( int  idx) const

check if there is a idx is a valid index for this list without throwing an error messaage

Parameters
idxthe index of the instrument

◆ load_from()

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

load an instrument list from an XMLNode

Parameters
nodethe XMLDode to read from
dk_paththe directory holding the drumkit data
dk_name
Returns
a new InstrumentList instance

◆ load_samples()

void load_samples ( )

Calls the Instrument::load_samples() member function of all Instruments in __instruments.

◆ move()

void move ( int  idx_a,
int  idx_b 
)

move an instrument from a position to another

Parameters
idx_athe start index
idx_bthe finish index

◆ operator<<()

void operator<< ( Instrument instrument)

add an instrument to the list

Parameters
instrumenta pointer to the instrument to add

◆ operator[]()

Instrument * operator[] ( int  idx)

get an instrument from the list

Parameters
idxthe index to get the instrument from

◆ save_to()

void save_to ( XMLNode node,
int  component_id 
)

save the instrument list within the given XMLNode

Parameters
nodethe XMLNode to feed
component_idIdentifier of the corresponding component.

◆ set_default_midi_out_notes()

void set_default_midi_out_notes ( )

Set each instrument consecuteve MIDI out notes, starting from 36.

◆ size()

int size ( ) const
inline

returns the numbers of instruments

◆ swap()

void swap ( int  idx_a,
int  idx_b 
)

swap the instruments of two different indexes

Parameters
idx_athe first index
idx_bthe second index

◆ 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 Instrument::unload_samples() member function of all Instruments in __instruments.

Field Documentation

◆ __instruments

std::vector<Instrument*> __instruments
private

the list of instruments