hydrogen 1.1.1
Pattern Class Reference

Pattern class is a Note container. More...

#include <Pattern.h>

Inheritance diagram for Pattern:
Object

Public Types

typedef std::multimap< int, Note * > notes_t
 < multimap note type More...
 
typedef notes_t::iterator notes_it_t
 multimap note const iterator type More...
 
typedef notes_t::const_iterator notes_cst_it_t
 note set type; More...
 
typedef std::set< Pattern * > virtual_patterns_t
 note set iterator type; More...
 
typedef virtual_patterns_t::iterator virtual_patterns_it_t
 note set const iterator type; More...
 
typedef virtual_patterns_t::const_iterator virtual_patterns_cst_it_t
 

Public Member Functions

 Pattern (const QString &name="Pattern", const QString &info="", const QString &category="not_categorized", int length=MAX_NOTES, int denominator=4)
 constructor More...
 
 Pattern (Pattern *other)
 copy constructor More...
 
 ~Pattern ()
 destructor More...
 
bool save_file (const QString &drumkit_name, const QString &author, const QString &license, const QString &pattern_path, bool overwrite=false) const
 save a pattern into an xml file More...
 
void set_name (const QString &name)
 get the name of the pattern More...
 
const QString & get_name () const
 set the category of the pattern More...
 
void set_category (const QString &category)
 set the info of the pattern More...
 
void set_info (const QString &info)
 get the info of the pattern More...
 
const QString & get_info () const
 get the category of the pattern More...
 
const QString & get_category () const
 set the length of the pattern More...
 
void set_length (int length)
 get the length of the pattern More...
 
int get_length () const
 set the denominator of the pattern More...
 
void set_denominator (int denominator)
 get the denominator of the pattern More...
 
int get_denominator () const
 get the note multimap More...
 
const notes_tget_notes () const
 get the virtual pattern set More...
 
const virtual_patterns_tget_virtual_patterns () const
 get the flattened virtual pattern set More...
 
const virtual_patterns_tget_flattened_virtual_patterns () const
 
void insert_note (Note *note)
 insert a new note within __notes More...
 
Notefind_note (int idx_a, int idx_b, Instrument *instrument, bool strict=true) const
 search for a note at a given index within __notes which correspond to the given arguments More...
 
Notefind_note (int idx_a, int idx_b, 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 More...
 
void remove_note (Note *note)
 removes a given note from __notes, it's not deleted More...
 
bool references (Instrument *instr)
 check if this pattern contains a note referencing the given instrument More...
 
void purge_instrument (Instrument *instr)
 delete the notes referencing the given instrument The function is thread safe (it locks the audio data while deleting notes) More...
 
void set_to_old ()
 mark all notes as old More...
 
bool virtual_patterns_empty () const
 clear __virtual_patterns More...
 
void virtual_patterns_clear ()
 
void virtual_patterns_add (Pattern *pattern)
 add a pattern to __virtual_patterns More...
 
void virtual_patterns_del (Pattern *pattern)
 remove a pattern from virtual_pattern set, flattened virtual patterns have to be rebuilt More...
 
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 More...
 
void extand_with_flattened_virtual_patterns (PatternList *patterns)
 add content of __flatteened_virtual_patterns into patterns More...
 
void save_to (XMLNode *node, const Instrument *instrumentOnly=nullptr) const
 save the pattern within the given XMLNode 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 Patternload_file (const QString &pattern_path, InstrumentList *instruments)
 load a pattern from a file 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...
 

Static Private Member Functions

static Patternload_from (XMLNode *node, InstrumentList *instruments)
 load a pattern from an XMLNode More...
 

Private Attributes

int __length
 the length of the pattern More...
 
int __denominator
 the meter denominator of the pattern used in meter (eg 4/4) More...
 
QString __name
 the name of thepattern More...
 
QString __category
 the category of the pattern More...
 
QString __info
 a description of the pattern More...
 
notes_t __notes
 a multimap (hash with possible multiple values for one key) of note More...
 
virtual_patterns_t __virtual_patterns
 a list of patterns directly referenced by this one More...
 
virtual_patterns_t __flattened_virtual_patterns
 the complete list of virtual patterns 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

Pattern class is a Note container.

Member Typedef Documentation

◆ notes_cst_it_t

typedef notes_t::const_iterator notes_cst_it_t

note set type;

◆ notes_it_t

typedef notes_t::iterator notes_it_t

multimap note const iterator type

◆ notes_t

typedef std::multimap<int, Note*> notes_t

< multimap note type

multimap note iterator type

◆ virtual_patterns_cst_it_t

typedef virtual_patterns_t::const_iterator virtual_patterns_cst_it_t

◆ virtual_patterns_it_t

typedef virtual_patterns_t::iterator virtual_patterns_it_t

note set const iterator type;

◆ virtual_patterns_t

typedef std::set<Pattern*> virtual_patterns_t

note set iterator type;

Constructor & Destructor Documentation

◆ Pattern() [1/2]

Pattern ( const QString &  name = "Pattern",
const QString &  info = "",
const QString &  category = "not_categorized",
int  length = MAX_NOTES,
int  denominator = 4 
)

constructor

Parameters
namethe name of the pattern
infoInitialized with an empty string.
categorythe category of the pattern
lengththe length of the pattern
denominatorthe denominator for meter representation (eg 4/4)

◆ Pattern() [2/2]

Pattern ( Pattern other)

copy constructor

◆ ~Pattern()

~Pattern ( )

destructor

Member Function Documentation

◆ extand_with_flattened_virtual_patterns()

void extand_with_flattened_virtual_patterns ( PatternList patterns)

add content of __flatteened_virtual_patterns into patterns

Parameters
patternsthe pattern list to feed

◆ find_note() [1/2]

Note * find_note ( int  idx_a,
int  idx_b,
Instrument instrument,
bool  strict = true 
) const

search for a note at a given index within __notes which correspond to the given arguments

Parameters
idx_athe first __notes index to search in
idx_bthe second __notes index to search in, will be omitted if is -1
instrumentthe instrument the note should be playing
strictif set to false, will search for a note around the given idx
Returns
the note if found, 0 otherwise

◆ find_note() [2/2]

Note * find_note ( int  idx_a,
int  idx_b,
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

Parameters
idx_athe first __notes index to search in
idx_bthe second __notes index to search in, will be omitted if is -1
instrumentthe instrument the note should be playing
keythe key that should be set to the note
octavethe octave that should be set to the note
strictif set to false, will search for a note around the given idx
Returns
the note if found, 0 otherwise

◆ flattened_virtual_patterns_clear()

void flattened_virtual_patterns_clear ( )
inline

◆ flattened_virtual_patterns_compute()

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

◆ get_category()

const QString & get_category ( ) const
inline

set the length of the pattern

◆ get_denominator()

int get_denominator ( ) const
inline

get the note multimap

◆ get_flattened_virtual_patterns()

const Pattern::virtual_patterns_t * get_flattened_virtual_patterns ( ) const
inline

◆ get_info()

const QString & get_info ( ) const
inline

get the category of the pattern

◆ get_length()

int get_length ( ) const
inline

set the denominator of the pattern

◆ get_name()

const QString & get_name ( ) const
inline

set the category of the pattern

◆ get_notes()

const Pattern::notes_t * get_notes ( ) const
inline

get the virtual pattern set

◆ get_virtual_patterns()

const Pattern::virtual_patterns_t * get_virtual_patterns ( ) const
inline

get the flattened virtual pattern set

◆ insert_note()

void insert_note ( Note note)
inline

insert a new note within __notes

Parameters
notethe note to be inserted

◆ load_file()

Pattern * load_file ( const QString &  pattern_path,
InstrumentList instruments 
)
static

load a pattern from a file

Parameters
pattern_paththe path to the file to load the pattern from
instrumentsthe current instrument list to search instrument into

◆ load_from()

Pattern * load_from ( XMLNode node,
InstrumentList instruments 
)
staticprivate

load a pattern from an XMLNode

Parameters
nodethe XMLDode to read from
instrumentsthe current instrument list to search instrument into
Returns
a new Pattern instance

◆ purge_instrument()

void purge_instrument ( Instrument instr)

delete the notes referencing the given instrument The function is thread safe (it locks the audio data while deleting notes)

Parameters
instrthe instrument

◆ references()

bool references ( Instrument instr)

check if this pattern contains a note referencing the given instrument

Parameters
instrthe instrument

◆ remove_note()

void remove_note ( Note note)

removes a given note from __notes, it's not deleted

Parameters
notethe note to be removed

◆ save_file()

bool save_file ( const QString &  drumkit_name,
const QString &  author,
const QString &  license,
const QString &  pattern_path,
bool  overwrite = false 
) const

save a pattern into an xml file

Parameters
drumkit_namethe name of the drumkit it is supposed to play with
authorthe name of the author
licensethe license that applies to it
pattern_paththe path to save the pattern into
overwriteallows to write over existing pattern file
Returns
true on success set the name of the pattern

◆ save_to()

void save_to ( XMLNode node,
const Instrument instrumentOnly = nullptr 
) const

save the pattern within the given XMLNode

Parameters
nodethe XMLNode to feed
instrumentOnlyexport only the notes of that instrument if given

◆ set_category()

void set_category ( const QString &  category)
inline

set the info of the pattern

◆ set_denominator()

void set_denominator ( int  denominator)
inline

get the denominator of the pattern

◆ set_info()

void set_info ( const QString &  info)
inline

get the info of the pattern

◆ set_length()

void set_length ( int  length)
inline

get the length of the pattern

◆ set_name()

void set_name ( const QString &  name)
inline

get the name of the pattern

◆ set_to_old()

void set_to_old ( )

mark all notes as old

return true if __virtual_patterns is empty

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

◆ virtual_patterns_add()

void virtual_patterns_add ( Pattern pattern)
inline

add a pattern to __virtual_patterns

Parameters
patternthe pattern to add

◆ virtual_patterns_clear()

void virtual_patterns_clear ( )
inline

◆ virtual_patterns_del()

void virtual_patterns_del ( Pattern pattern)
inline

remove a pattern from virtual_pattern set, flattened virtual patterns have to be rebuilt

clear flattened_virtual_patterns

◆ virtual_patterns_empty()

bool virtual_patterns_empty ( ) const
inline

clear __virtual_patterns

Field Documentation

◆ __category

QString __category
private

the category of the pattern

◆ __denominator

int __denominator
private

the meter denominator of the pattern used in meter (eg 4/4)

◆ __flattened_virtual_patterns

virtual_patterns_t __flattened_virtual_patterns
private

the complete list of virtual patterns

◆ __info

QString __info
private

a description of the pattern

◆ __length

int __length
private

the length of the pattern

◆ __name

QString __name
private

the name of thepattern

◆ __notes

notes_t __notes
private

a multimap (hash with possible multiple values for one key) of note

◆ __virtual_patterns

virtual_patterns_t __virtual_patterns
private

a list of patterns directly referenced by this one