37 __start_velocity( 0.0 ),
38 __end_velocity( 1.0 ),
46 __start_velocity( other->get_start_velocity() ),
47 __end_velocity( other->get_end_velocity() ),
48 __pitch( other->get_pitch() ),
49 __gain( other->get_gain() ),
50 __sample( other->get_sample() )
55 __start_velocity( other->get_start_velocity() ),
56 __end_velocity( other->get_end_velocity() ),
57 __pitch( other->get_pitch() ),
58 __gain( other->get_gain() ),
90 QString sFilename = pNode->
read_string(
"filename",
"",
false,
false, bSilent );
91 QString sAbsoluteFilename = sFilename;
94 ! sFilename.startsWith(
"/" ) ) {
97 if ( pHydrogen->isUnderSessionManagement() ) {
108 if ( sFilename.left( 2 ) ==
"./" ||
109 sFilename.left( 2 ) ==
".\\" ) {
114 sFilename.right( sFilename.size() - 1 );
117 sFilename = sDrumkitPath +
"/" + sFilename;
118 sAbsoluteFilename = sFilename;
122 sFilename = sDrumkitPath +
"/" + sFilename;
123 sAbsoluteFilename = sFilename;
126 sFilename = sDrumkitPath +
"/" + sFilename;
127 sAbsoluteFilename = sFilename;
131 std::shared_ptr<Sample> pSample =
nullptr;
133 pSample = std::make_shared<Sample>( sFilename, drumkitLicense );
139 bool bIsModified = pNode->
read_bool(
"ismodified",
false,
true,
false,
true );
140 pSample->set_is_modified( bIsModified );
148 loops.
count = pNode->
read_int(
"loops", 0,
false,
false, bSilent );
150 pSample->set_loops( loops );
153 rubberband.
use = pNode->
read_int(
"userubber", 0,
false,
false, bSilent );
154 rubberband.
divider = pNode->
read_float(
"rubberdivider", 0.0,
false,
false, bSilent );
155 rubberband.
c_settings = pNode->
read_int(
"rubberCsettings", 1,
false,
false, bSilent );
156 rubberband.
pitch = pNode->
read_float(
"rubberPitch", 0.0,
false,
false, bSilent );
160 m_rubberBandCLIexecutable ) ) {
161 rubberband.
use =
false;
163 pSample->set_rubberband( rubberband );
169 XMLNode volumeNode = pNode->firstChildElement(
"volume" );
170 while ( ! volumeNode.isNull() ) {
171 pt.
frame = volumeNode.
read_int(
"volume-position", 0,
false,
false, bSilent );
172 pt.
value = volumeNode.
read_int(
"volume-value", 0,
false,
false , bSilent);
173 velocityEnvelope.push_back( pt );
174 volumeNode = volumeNode.nextSiblingElement(
"volume" );
176 pSample->set_velocity_envelope( velocityEnvelope );
179 XMLNode panNode = pNode->firstChildElement(
"pan" );
180 while ( ! panNode.isNull() ) {
181 pt.
frame = panNode.
read_int(
"pan-position", 0,
false,
false, bSilent );
182 pt.
value = panNode.
read_int(
"pan-value", 0,
false,
false, bSilent );
183 panEnvelope.push_back( pt );
184 panNode = panNode.nextSiblingElement(
"pan" );
186 pSample->set_pan_envelope( panEnvelope );
190 auto pLayer = std::make_shared<InstrumentLayer>( pSample );
191 pLayer->set_start_velocity( pNode->
read_float(
"min", 0.0,
192 true,
true, bSilent ) );
193 pLayer->set_end_velocity( pNode->
read_float(
"max", 1.0,
194 true,
true, bSilent ) );
195 pLayer->set_gain( pNode->
read_float(
"gain", 1.0,
196 true,
false, bSilent ) );
197 pLayer->set_pitch( pNode->
read_float(
"pitch", 0.0,
198 true,
false, bSilent ) );
206 if ( pSample ==
nullptr ) {
207 ERRORLOG(
"No sample associated with layer. Skipping it" );
216 if ( pHydrogen->isUnderSessionManagement() ) {
222 if ( pSample->get_raw_filepath().startsWith(
'.' ) ) {
223 sFilename = pSample->get_raw_filepath();
234 sFilename = pSample->get_filename();
244 layer_node.
write_bool(
"ismodified", pSample->get_is_modified() );
245 layer_node.
write_string(
"smode", pSample->get_loop_mode_string() );
254 layer_node.
write_int(
"userubber",
static_cast<int>(rubberband.
use) );
259 for (
const auto& velocity : *pSample->get_velocity_envelope() ) {
261 volumeNode.
write_int(
"volume-position", velocity.frame );
262 volumeNode.
write_int(
"volume-value", velocity.value );
265 for (
const auto& pan : *pSample->get_pan_envelope() ) {
267 panNode.
write_int(
"pan-position", pan.frame );
268 panNode.
write_int(
"pan-value", pan.value );
277 sOutput = QString(
"%1[InstrumentLayer]\n" ).arg( sPrefix )
278 .append( QString(
"%1%2gain: %3\n" ).arg( sPrefix ).arg( s ).arg(
__gain ) )
279 .append( QString(
"%1%2pitch: %3\n" ).arg( sPrefix ).arg( s ).arg(
__pitch ) )
280 .append( QString(
"%1%2start_velocity: %3\n" ).arg( sPrefix ).arg( s ).arg(
__start_velocity ) )
281 .append( QString(
"%1%2end_velocity: %3\n" ).arg( sPrefix ).arg( s ).arg(
__end_velocity ) );
283 sOutput.append( QString(
"%1" )
284 .arg(
__sample->toQString( sPrefix + s, bShort ) ) );
286 sOutput.append( QString(
"%1%2sample: nullptr\n" ).arg( sPrefix ).arg( s ) );
290 sOutput = QString(
"[InstrumentLayer]" )
291 .append( QString(
" gain: %1" ).arg(
__gain ) )
292 .append( QString(
", pitch: %1" ).arg(
__pitch ) )
296 sOutput.append( QString(
", sample: %1\n" ).arg(
__sample->get_filepath() ) );
298 sOutput.append( QString(
", sample: nullptr\n" ) );
static QString sPrintIndention
String used to format the debugging string output of some core classes.
A container for a sample, being able to apply modifications on it.
static QString prepare_sample_path(const QString &fname)
Returns the basename if the given path is under an existing user or system drumkit path,...
static bool file_exists(const QString &path, bool silent=false)
returns true if the given path is an existing regular file
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
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
float __start_velocity
the start velocity of the sample, 0.0 by default
float __gain
ratio between the input sample and the output signal, 1.0 by default
float __pitch
the frequency of the sample, 0.0 by default which means output pitch is the same as input pitch
std::shared_ptr< Sample > __sample
the underlaying sample
void save_to(XMLNode *node, bool bFull=false)
save the instrument layer within the given XMLNode
InstrumentLayer(std::shared_ptr< Sample > sample)
constructor
~InstrumentLayer()
destructor
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
std::shared_ptr< Sample > get_sample() const
get the sample of the layer
void load_sample(float fBpm=120)
Calls the H2Core::Sample::load() member function of __sample.
float __end_velocity
the end velocity of the sample, 1.0 by default
void set_sample(std::shared_ptr< Sample > sample)
set the sample of the layer
Wrapper class to help Hydrogen deal with the license information specified in a drumkit.
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
set of loop configuration flags
int end_frame
the frame index where to end the new sample to
int start_frame
the frame index where to start the new sample from
LoopMode mode
one of the possible loop modes
int count
the counts of loops to apply
int loop_frame
the frame index where to start the loop from
set of rubberband configuration flags
int c_settings
TODO should be crispness, see rubberband -h.
float divider
TODO should be ratio : desired time ratio.
bool use
is rubberband enabled
static Loops::LoopMode parse_loop_mode(const QString &string)
parse the given string and rturn the corresponding loop_mode
std::vector< EnvelopePoint > VelocityEnvelope
define the type used to store velocity envelope points
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
bool read_bool(const QString &node, bool default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
reads a boolean stored into a child node
QString read_string(const QString &node, const QString &default_value, bool inexistent_ok=true, bool empty_ok=true, bool bSilent=false)
reads a string 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_string(const QString &node, const QString &value)
write a string into a child node
void write_bool(const QString &node, const bool value)
write a boolean into a child node
void write_int(const QString &node, const int value)
write an integer into a child node
static NsmClient * get_instance()
QString getSessionFolderPath() const