|
hydrogen 1.2.6
|
Pattern class is a Note container. More...
#include <Pattern.h>
Public Types | |
| typedef notes_t::const_iterator | notes_cst_it_t |
| note set type; | |
| typedef notes_t::iterator | notes_it_t |
| multimap note const iterator type | |
| typedef std::multimap< int, Note * > | notes_t |
| < multimap note type | |
| typedef virtual_patterns_t::const_iterator | virtual_patterns_cst_it_t |
| typedef virtual_patterns_t::iterator | virtual_patterns_it_t |
| note set const iterator type; | |
| typedef std::set< Pattern * > | virtual_patterns_t |
| note set iterator type; | |
Public Member Functions | |
| Pattern (const QString &name="Pattern", const QString &info="", const QString &category="not_categorized", int length=MAX_NOTES, int denominator=4) | |
| constructor | |
| Pattern (Pattern *other) | |
| copy constructor | |
| ~Pattern () | |
| destructor | |
| void | addFlattenedVirtualPatterns (PatternList *pPatternList) |
| Add content of __flattened_virtual_patterns into pPatternList. | |
| std::set< Pattern * >::iterator | begin () |
| allow iteration of all contained virtual patterns. | |
| void | clear (bool bRequiredLock=true) |
| Erase all notes. | |
| std::set< Pattern * >::iterator | end () |
| Note * | find_note (int idx_a, int idx_b, std::shared_ptr< Instrument > instrument, bool strict=true) const |
| search for a note at a given index within __notes which correspond to the given arguments | |
| Note * | find_note (int idx_a, int idx_b, std::shared_ptr< Instrument > instrument, Note::Key key, Note::Octave octave, bool strict=true) const |
| search for a note at a given index within __notes which correspond to the given arguments | |
| void | flattened_virtual_patterns_clear () |
| void | flattened_virtual_patterns_compute () |
| compute virtual_pattern_transitive_closure_set based on virtual_pattern_transitive_closure_set virtual_pattern_transitive_closure_set must have been cleared before which is the case is called from PatternList::compute_flattened_virtual_patterns | |
| const QString & | get_category () const |
| set the length of the pattern | |
| int | get_denominator () const |
| get the note multimap | |
| const virtual_patterns_t * | get_flattened_virtual_patterns () const |
| const QString & | get_info () const |
| get the category of the pattern | |
| int | get_length () const |
| set the denominator of the pattern | |
| const QString & | get_name () const |
| set the category of the pattern | |
| const notes_t * | get_notes () const |
| get the virtual pattern set | |
| const virtual_patterns_t * | get_virtual_patterns () const |
| get the flattened virtual pattern set | |
| void | insert_note (Note *note) |
| insert a new note within __notes | |
| bool | isVirtual () const |
| Whether the pattern holds at least one virtual pattern. | |
| int | longestVirtualPatternLength () const |
| void | purge_instrument (std::shared_ptr< Instrument > instr, bool bRequiredLock=true) |
| delete the notes referencing the given instrument The function is thread safe (it locks the audio data while deleting notes) | |
| bool | references (std::shared_ptr< Instrument > instr) |
| check if this pattern contains a note referencing the given instrument | |
| void | remove_note (Note *note) |
| removes a given note from __notes, it's not deleted | |
| void | removeFlattenedVirtualPatterns (PatternList *pPatternList) |
| Add content of __flattened_virtual_patterns into pPatternList. | |
| bool | save_file (const QString &drumkit_name, const QString &author, const License &license, const QString &pattern_path, bool overwrite=false) const |
| save a pattern into an xml file | |
| void | save_to (XMLNode *node, const std::shared_ptr< Instrument > instrumentOnly=nullptr) const |
| save the pattern within the given XMLNode | |
| void | set_category (const QString &category) |
| set the info of the pattern | |
| void | set_denominator (int denominator) |
| get the denominator of the pattern | |
| void | set_info (const QString &info) |
| get the info of the pattern | |
| void | set_length (int length) |
| get the length of the pattern | |
| void | set_name (const QString &name) |
| get the name of the pattern | |
| void | set_to_old () |
| mark all notes as old | |
| QString | toQString (const QString &sPrefix="", bool bShort=true) const override |
| Formatted string version for debugging purposes. | |
| void | virtual_patterns_add (Pattern *pattern) |
| add a pattern to __virtual_patterns | |
| void | virtual_patterns_clear () |
| void | virtual_patterns_del (Pattern *pattern) |
| remove a pattern from virtual_pattern set, flattened virtual patterns have to be rebuilt | |
| bool | virtual_patterns_empty () const |
| clear __virtual_patterns | |
Public Member Functions inherited from Object< Pattern > | |
| Object () | |
| Object (const Object< Pattern > &other) | |
Public Member Functions inherited from Base | |
| Base () | |
| Base (const Base &other) | |
| virtual const char * | class_name () const |
| void | logBacktrace () const |
| Print the current stack at point into the debug log. | |
| void | Print (bool bShort=true) const |
| Prints content of toQString() via DEBUGLOG. | |
Static Public Member Functions | |
| static Pattern * | load_file (const QString &sPpatternPath, std::shared_ptr< InstrumentList > pInstruments, bool bSilent=false) |
| load a pattern from a file | |
| static Pattern * | load_from (XMLNode *node, std::shared_ptr< InstrumentList > instruments, bool bSilent=false) |
| load a pattern from an XMLNode | |
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 | |
| QString | __category |
| the category of the pattern | |
| int | __denominator |
| the meter denominator of the pattern used in meter (eg 4/4) | |
| virtual_patterns_t | __flattened_virtual_patterns |
| the complete list of virtual patterns | |
| QString | __info |
| a description of the pattern | |
| int | __length |
| Determines the accessible range or notes within the pattern. | |
| QString | __name |
| the name of thepattern | |
| notes_t | __notes |
| a multimap (hash with possible multiple values for one key) of note | |
| virtual_patterns_t | __virtual_patterns |
| a list of patterns directly referenced by this one | |
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< Pattern > | |
| ~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 |
| static bool | bLogColors = true |
| typedef notes_t::const_iterator notes_cst_it_t |
| typedef notes_t::iterator notes_it_t |
| typedef virtual_patterns_t::const_iterator virtual_patterns_cst_it_t |
| typedef virtual_patterns_t::iterator virtual_patterns_it_t |
| typedef std::set<Pattern*> virtual_patterns_t |
| Pattern | ( | const QString & | name = "Pattern", |
| const QString & | info = "", | ||
| const QString & | category = "not_categorized", | ||
| int | length = MAX_NOTES, | ||
| int | denominator = 4 ) |
constructor
| name | the name of the pattern |
| info | Initialized with an empty string. |
| category | the category of the pattern |
| length | the length of the pattern |
| denominator | the denominator for meter representation (eg 4/4) |
Definition at line 38 of file Pattern.cpp.
copy constructor
Definition at line 47 of file Pattern.cpp.
| ~Pattern | ( | ) |
destructor
Definition at line 59 of file Pattern.cpp.
| void addFlattenedVirtualPatterns | ( | PatternList * | pPatternList | ) |
Add content of __flattened_virtual_patterns into pPatternList.
Companion function of removeFlattenedVirtualPatterns();
Definition at line 337 of file Pattern.cpp.
| std::set< Pattern * >::iterator begin | ( | ) |
allow iteration of all contained virtual patterns.
Definition at line 367 of file Pattern.cpp.
| void clear | ( | bool | bRequiredLock = true | ) |
Erase all notes.
Definition at line 289 of file Pattern.cpp.
| std::set< Pattern * >::iterator end | ( | ) |
Definition at line 371 of file Pattern.cpp.
| Note * find_note | ( | int | idx_a, |
| int | idx_b, | ||
| std::shared_ptr< Instrument > | instrument, | ||
| bool | strict = true ) const |
search for a note at a given index within __notes which correspond to the given arguments
| idx_a | the first __notes index to search in |
| idx_b | the second __notes index to search in, will be omitted if is -1 |
| instrument | the instrument the note should be playing |
| strict | if set to false, will search for a note around the given idx |
Definition at line 212 of file Pattern.cpp.
| Note * find_note | ( | int | idx_a, |
| int | idx_b, | ||
| std::shared_ptr< Instrument > | instrument, | ||
| Note::Key | key, | ||
| Note::Octave | octave, | ||
| bool | strict = true ) const |
search for a note at a given index within __notes which correspond to the given arguments
| idx_a | the first __notes index to search in |
| idx_b | the second __notes index to search in, will be omitted if is -1 |
| instrument | the instrument the note should be playing |
| key | the key that should be set to the note |
| octave | the octave that should be set to the note |
| strict | if set to false, will search for a note around the given idx |
Definition at line 187 of file Pattern.cpp.
| void flattened_virtual_patterns_compute | ( | ) |
compute virtual_pattern_transitive_closure_set based on virtual_pattern_transitive_closure_set virtual_pattern_transitive_closure_set must have been cleared before which is the case is called from PatternList::compute_flattened_virtual_patterns
Definition at line 321 of file Pattern.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| bool isVirtual | ( | ) | const |
Whether the pattern holds at least one virtual pattern.
Definition at line 363 of file Pattern.cpp.
|
static |
load a pattern from a file
| sPatternPath | the path to the file to load the pattern from |
| pInstruments | the current instrument list to search instrument into |
| bSilent | Whether infos, warnings, and errors should be logged. |
Definition at line 66 of file Pattern.cpp.
|
static |
load a pattern from an XMLNode
| node | the XMLDode to read from |
| instruments | the current instrument list to search instrument into |
| bSilent | Whether infos, warnings, and errors should be logged. |
Definition at line 116 of file Pattern.cpp.
| int longestVirtualPatternLength | ( | ) | const |
Definition at line 351 of file Pattern.cpp.
| void purge_instrument | ( | std::shared_ptr< Instrument > | instr, |
| bool | bRequiredLock = true ) |
delete the notes referencing the given instrument The function is thread safe (it locks the audio data while deleting notes)
| instr | the instrument |
Definition at line 262 of file Pattern.cpp.
| bool references | ( | std::shared_ptr< Instrument > | instr | ) |
check if this pattern contains a note referencing the given instrument
| instr | the instrument |
Definition at line 250 of file Pattern.cpp.
| void remove_note | ( | Note * | note | ) |
removes a given note from __notes, it's not deleted
| note | the note to be removed |
Definition at line 239 of file Pattern.cpp.
| void removeFlattenedVirtualPatterns | ( | PatternList * | pPatternList | ) |
Add content of __flattened_virtual_patterns into pPatternList.
Companion function of addFlattenedVirtualPatterns();
Definition at line 344 of file Pattern.cpp.
| bool save_file | ( | const QString & | drumkit_name, |
| const QString & | author, | ||
| const License & | license, | ||
| const QString & | pattern_path, | ||
| bool | overwrite = false ) const |
save a pattern into an xml file
| drumkit_name | the name of the drumkit it is supposed to play with |
| author | the name of the author |
| license | the license that applies to it |
| pattern_path | the path to save the pattern into |
| overwrite | allows to write over existing pattern file |
Definition at line 147 of file Pattern.cpp.
| void save_to | ( | XMLNode * | node, |
| const std::shared_ptr< Instrument > | instrumentOnly = nullptr ) const |
save the pattern within the given XMLNode
| node | the XMLNode to feed |
| instrumentOnly | export only the notes of that instrument if given |
Definition at line 164 of file Pattern.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void set_to_old | ( | ) |
mark all notes as old
return true if __virtual_patterns is empty
Definition at line 312 of file Pattern.cpp.
|
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 375 of file Pattern.cpp.
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
Determines the accessible range or notes within the pattern.
Notes are allow to be located at positions larger than __length. This can happen when programming a pattern and decreasing its length later on. Those notes will be stored in the associated .h2pattern and .h2song but won't be played back or exported into a MIDI file.
|
private |
|
private |