hydrogen 1.1.1
Drumkit Class Reference

Drumkit info. More...

#include <Drumkit.h>

Inheritance diagram for Drumkit:
Object

Public Member Functions

 Drumkit ()
 drumkit constructor, does nothing More...
 
 Drumkit (Drumkit *other)
 copy constructor More...
 
 ~Drumkit ()
 drumkit destructor, delete __instruments More...
 
void load_samples ()
 Calls the InstrumentList::load_samples() member function of __instruments. More...
 
void unload_samples ()
 Calls the InstrumentList::unload_samples() member function of __instruments. More...
 
bool save (bool overwrite=false)
 save a drumkit, xml file and samples More...
 
bool save (const QString &dk_dir, bool overwrite=false)
 save a drumkit, xml file and samples neither __path nor __name are updated More...
 
bool save_file (const QString &dk_path, bool overwrite=false, int component_id=-1)
 save a drumkit into an xml file More...
 
bool save_samples (const QString &dk_dir, bool overwrite=false)
 save a drumkit instruments samples into a directory More...
 
bool save_image (const QString &dk_dir, bool overwrite=false)
 save the drumkit image into the new directory More...
 
void set_instruments (InstrumentList *instruments)
 set __instruments, delete existing one More...
 
InstrumentListget_instruments () const
 returns __instruments More...
 
void set_path (const QString &path)
 __path setter More...
 
const QString & get_path () const
 __path accessor More...
 
void set_name (const QString &name)
 __name setter More...
 
const QString & get_name () const
 __name accessor More...
 
void set_author (const QString &author)
 __author setter More...
 
const QString & get_author () const
 __author accessor More...
 
void set_info (const QString &info)
 __info setter More...
 
const QString & get_info () const
 __info accessor More...
 
void set_license (const QString &license)
 __license setter More...
 
const QString & get_license () const
 __license accessor More...
 
void set_image (const QString &image)
 __image setter More...
 
const QString & get_image () const
 __image accessor More...
 
void set_image_license (const QString &imageLicense)
 __imageLicense setter More...
 
const QString & get_image_license () const
 __imageLicense accessor More...
 
const bool samples_loaded () const
 return true if the samples are loaded More...
 
void dump ()
 
bool isUserDrumkit () const
 
std::vector< DrumkitComponent * > * get_components ()
 
void set_components (std::vector< DrumkitComponent * > *components)
 
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 Drumkitload (const QString &dk_dir, const bool load_samples=false)
 Load drumkit information from a directory. More...
 
static Drumkitload_by_name (const QString &dk_name, const bool load_samples=false, Filesystem::Lookup lookup=Filesystem::Lookup::stacked)
 Simple wrapper for load() used with the drumkit's name instead of its directory. More...
 
static Drumkitload_file (const QString &dk_path, const bool load_samples=false)
 Load a Drumkit from a file. More...
 
static void upgrade_drumkit (Drumkit *pDrumkit, const QString &dk_path)
 Saves the current drumkit to dk_path, but makes a backup. More...
 
static bool user_drumkit_exists (const QString &dk_path)
 check if a user drumkit with the given name already exists More...
 
static bool save (const QString &sName, const QString &sAuthor, const QString &sInfo, const QString &sLicense, const QString &sImage, const QString &sImageLicense, InstrumentList *pInstruments, std::vector< DrumkitComponent * > *pComponents, bool bOverwrite=false)
 save a drumkit using given parameters and an instrument list More...
 
static bool install (const QString &path)
 install a drumkit from a filename More...
 
static bool remove (const QString &dk_name, Filesystem::Lookup lookup)
 remove a drumkit from the disk 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 Member Functions

void save_to (XMLNode *node, int component_id=-1)
 

Static Private Member Functions

static Drumkitload_from (XMLNode *node, const QString &dk_path)
 load a drumkit from an XMLNode More...
 

Private Attributes

QString __path
 absolute drumkit path More...
 
QString __name
 drumkit name More...
 
QString __author
 drumkit author More...
 
QString __info
 drumkit free text More...
 
QString __license
 drumkit license description More...
 
QString __image
 drumkit image filename More...
 
QString __imageLicense
 drumkit image license More...
 
bool __samples_loaded
 true if the instrument samples are loaded More...
 
InstrumentList__instruments
 the list of instruments More...
 
std::vector< DrumkitComponent * > * __components
 list of drumkit component 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

Drumkit info.

Constructor & Destructor Documentation

◆ Drumkit() [1/2]

Drumkit ( )

drumkit constructor, does nothing

◆ Drumkit() [2/2]

Drumkit ( Drumkit other)

copy constructor

◆ ~Drumkit()

~Drumkit ( )

drumkit destructor, delete __instruments

Member Function Documentation

◆ dump()

void dump ( )

◆ get_author()

const QString & get_author ( ) const
inline

__author accessor

◆ get_components()

std::vector< DrumkitComponent * > * get_components ( )
inline

◆ get_image()

const QString & get_image ( ) const
inline

__image accessor

◆ get_image_license()

const QString & get_image_license ( ) const
inline

__imageLicense accessor

◆ get_info()

const QString & get_info ( ) const
inline

__info accessor

◆ get_instruments()

InstrumentList * get_instruments ( ) const
inline

returns __instruments

◆ get_license()

const QString & get_license ( ) const
inline

__license accessor

◆ get_name()

const QString & get_name ( ) const
inline

__name accessor

◆ get_path()

const QString & get_path ( ) const
inline

__path accessor

◆ install()

bool install ( const QString &  path)
static

install a drumkit from a filename

Parameters
paththe path to the new drumkit archive
Returns
true on success

◆ isUserDrumkit()

bool isUserDrumkit ( ) const
Returns
Whether the associated files are located in the user or the systems drumkit folder.

◆ load()

Drumkit * load ( const QString &  dk_dir,
const bool  load_samples = false 
)
static

Load drumkit information from a directory.

This function is a wrapper around load_file(). The provided drumkit directory dk_dir is converted by Filesystem::drumkit_file() internally.

Parameters
dk_dirA directory containing a drumkit, like those returned by Filesystem::drumkit_dir_search().
load_samplesAutomatically load sample data if set to true.
Returns
A Drumkit on success, nullptr otherwise.

◆ load_by_name()

Drumkit * load_by_name ( const QString &  dk_name,
const bool  load_samples = false,
Filesystem::Lookup  lookup = Filesystem::Lookup::stacked 
)
static

Simple wrapper for load() used with the drumkit's name instead of its directory.

Uses Filesystem::drumkit_path_search() to determine the directory of the Drumkit from dk_name.

Parameters
dk_nameName of the Drumkit.
load_samplesAutomatically load sample data if set to true.
lookupWhere to search (system/user folder or both) for the drumkit.
Returns
A Drumkit on success, nullptr otherwise.

◆ load_file()

Drumkit * load_file ( const QString &  dk_path,
const bool  load_samples = false 
)
static

Load a Drumkit from a file.

If the drumkit in dk_name can not be validated against the current XML Schema definition in Filesystem::drumkit_xsd_path(), it will be loaded using Legacy::load_drumkit() and, if successful, saved again using save_file() to update the drumkit file to the newest version. If, instead, the Drumkit is valid, it is loaded using load_from() and load_samples() is triggered if load_samples is true.

Parameters
dk_pathis a path to an xml file
load_samplesautomatically load sample data if set to true
Returns
A Drumkit on success, nullptr otherwise.

◆ load_from()

Drumkit * load_from ( XMLNode node,
const QString &  dk_path 
)
staticprivate

load a drumkit from an XMLNode

Parameters
nodethe XMLDode to read from
dk_paththe directory holding the drumkit data

◆ load_samples()

void load_samples ( )

Calls the InstrumentList::load_samples() member function of __instruments.

◆ remove()

bool remove ( const QString &  dk_name,
Filesystem::Lookup  lookup 
)
static

remove a drumkit from the disk

Parameters
dk_namethe drumkit name
lookupWhere to search (system/user folder or both) for the drumkit.
Returns
true on success

◆ samples_loaded()

const bool samples_loaded ( ) const
inline

return true if the samples are loaded

◆ save() [1/3]

bool save ( bool  overwrite = false)

save a drumkit, xml file and samples

Parameters
overwriteallows to write over existing drumkit files
Returns
true on success

◆ save() [2/3]

bool save ( const QString &  dk_dir,
bool  overwrite = false 
)

save a drumkit, xml file and samples neither __path nor __name are updated

Parameters
dk_dirthe directory to save the drumkit into
overwriteallows to write over existing drumkit files
Returns
true on success

◆ save() [3/3]

bool save ( const QString &  sName,
const QString &  sAuthor,
const QString &  sInfo,
const QString &  sLicense,
const QString &  sImage,
const QString &  sImageLicense,
InstrumentList pInstruments,
std::vector< DrumkitComponent * > *  pComponents,
bool  bOverwrite = false 
)
static

save a drumkit using given parameters and an instrument list

Parameters
sNamethe name of the drumkit
sAuthorthe author of the drumkit
sInfothe info of the drumkit
sLicensethe license of the drumkit
sImagethe image filename (with full path) of the drumkit
sImageLicenselicense of the supplied image
pInstrumentsthe instruments to be saved within the drumkit
pComponents
bOverwriteallows to write over existing drumkit files
Returns
true on success

◆ save_file()

bool save_file ( const QString &  dk_path,
bool  overwrite = false,
int  component_id = -1 
)

save a drumkit into an xml file

Parameters
dk_paththe path to save the drumkit into
overwriteallows to write over existing drumkit file
component_idto chose the component to save or -1 for all
Returns
true on success

◆ save_image()

bool save_image ( const QString &  dk_dir,
bool  overwrite = false 
)

save the drumkit image into the new directory

Parameters
dk_dirthe directory to save the image into
overwriteallows to write over existing drumkit image file
Returns
true on success

◆ save_samples()

bool save_samples ( const QString &  dk_dir,
bool  overwrite = false 
)

save a drumkit instruments samples into a directory

Parameters
dk_dirthe directory to save the samples into
overwriteallows to write over existing drumkit samples files
Returns
true on success

◆ save_to()

void save_to ( XMLNode node,
int  component_id = -1 
)
private

◆ set_author()

void set_author ( const QString &  author)
inline

__author setter

◆ set_components()

void set_components ( std::vector< DrumkitComponent * > *  components)

◆ set_image()

void set_image ( const QString &  image)
inline

__image setter

◆ set_image_license()

void set_image_license ( const QString &  imageLicense)
inline

◆ set_info()

void set_info ( const QString &  info)
inline

__info setter

◆ set_instruments()

void set_instruments ( InstrumentList instruments)

set __instruments, delete existing one

◆ set_license()

void set_license ( const QString &  license)
inline

__license setter

◆ set_name()

void set_name ( const QString &  name)
inline

__name setter

◆ set_path()

void set_path ( const QString &  path)
inline

__path setter

◆ 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 InstrumentList::unload_samples() member function of __instruments.

◆ upgrade_drumkit()

void upgrade_drumkit ( Drumkit pDrumkit,
const QString &  dk_path 
)
static

Saves the current drumkit to dk_path, but makes a backup.

This is used when the drumkit did not comply to our xml schema.

◆ user_drumkit_exists()

bool user_drumkit_exists ( const QString &  dk_path)
static

check if a user drumkit with the given name already exists

Parameters
dk_pathDrumkit path
Returns
true on success

Field Documentation

◆ __author

QString __author
private

drumkit author

◆ __components

std::vector<DrumkitComponent*>* __components
private

list of drumkit component

◆ __image

QString __image
private

drumkit image filename

◆ __imageLicense

QString __imageLicense
private

drumkit image license

◆ __info

QString __info
private

drumkit free text

◆ __instruments

InstrumentList* __instruments
private

the list of instruments

◆ __license

QString __license
private

drumkit license description

◆ __name

QString __name
private

drumkit name

◆ __path

QString __path
private

absolute drumkit path

◆ __samples_loaded

bool __samples_loaded
private

true if the instrument samples are loaded