62 std::shared_ptr<InstrumentLayer> other_layer = other->get_layer( i );
64 __layers[i] = std::make_shared<InstrumentLayer>( other_layer );
103 auto pInstrumentComponent = std::make_shared<InstrumentComponent>( nId );
104 pInstrumentComponent->set_gain( pNode->
read_float(
"gain", 1.0f,
105 true,
false, bSilent ) );
106 XMLNode layer_node = pNode->firstChildElement(
"layer" );
108 while ( ! layer_node.isNull() ) {
110 ERRORLOG( QString(
"Layer #%1 >= m_nMaxLayers (%2). This as well as all further layers will be omitted." )
116 drumkitLicense, bSilent );
117 if ( pLayer !=
nullptr ) {
118 pInstrumentComponent->set_layer( pLayer, nLayer );
121 layer_node = layer_node.nextSiblingElement(
"layer" );
124 return pInstrumentComponent;
130 if ( bRecentVersion ) {
131 component_node = node->
createNode(
"instrumentComponent" );
137 if( pLayer !=
nullptr ) {
138 if( bRecentVersion ) {
139 pLayer->save_to( &component_node, bFull );
141 pLayer->save_to( node, bFull );
151 sOutput = QString(
"%1[InstrumentComponent]\n" ).arg( sPrefix )
153 .append( QString(
"%1%2gain: %3\n" ).arg( sPrefix ).arg( s ).arg(
__gain ) )
154 .append( QString(
"%1%2m_nMaxLayers: %3\n" ).arg( sPrefix ).arg( s ).arg(
m_nMaxLayers ) )
155 .append( QString(
"%1%2layers:\n" ).arg( sPrefix ).arg( s ) );
158 if ( ll !=
nullptr ) {
159 sOutput.append( QString(
"%1" ).arg( ll->toQString( sPrefix + s + s, bShort ) ) );
163 sOutput = QString(
"[InstrumentComponent]" )
165 .append( QString(
", gain: %1" ).arg(
__gain ) )
166 .append( QString(
", m_nMaxLayers: %1" ).arg(
m_nMaxLayers ) )
167 .append( QString(
", [layers:" ) );
170 if ( ll !=
nullptr ) {
171 sOutput.append( QString(
" [%1" ).arg( ll->toQString( sPrefix + s + s, bShort ).replace(
"\n",
"]" ) ) );
175 sOutput.append(
"]\n" );
static QString sPrintIndention
String used to format the debugging string output of some core classes.
static std::shared_ptr< InstrumentComponent > load_from(XMLNode *pNode, const QString &sDrumkitPath, const License &drumkitLicense=License(), bool bSilent=false)
std::vector< std::shared_ptr< InstrumentLayer > > __layers
std::vector< std::shared_ptr< InstrumentLayer > >::iterator begin()
Iteration.
static int m_nMaxLayers
Maximum number of layers to be used in the Instrument editor.
InstrumentComponent(int related_drumkit_componentID)
static void setMaxLayers(int layers)
int __related_drumkit_componentID
Component ID of the drumkit.
std::vector< std::shared_ptr< InstrumentLayer > >::iterator end()
void set_layer(std::shared_ptr< InstrumentLayer > layer, int idx)
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
std::shared_ptr< InstrumentLayer > get_layer(int idx)
void save_to(XMLNode *node, int component_id, bool bRecentVersion=true, bool bFull=false)
static int getMaxLayers()
static std::shared_ptr< InstrumentLayer > load_from(XMLNode *pNode, const QString &sDrumkitPath, const License &drumkitLicense=License(), bool bSilent=false)
load an instrument layer from an XMLNode
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.
int read_int(const QString &node, int default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
reads an integer stored into a child node
float read_float(const QString &node, float default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
reads a float stored into a child node
void write_float(const QString &node, const float value)
write a float into a child node
XMLNode createNode(const QString &name)
create a new XMLNode that has to be appended into de XMLDoc
void write_int(const QString &node, const int value)
write an integer into a child node