hydrogen 1.2.6
InstrumentLayer Class Reference

InstrumentLayer is part of an instrument
each layer has it's own :
gain which is the ration between the input sample and the output signal,
pitch which allows you to play the sample at a faster or lower frequency,
start velocity and end velocity which allows you to chose between a layer or another within an instrument by changing the velocity of the played note. More...

#include <InstrumentLayer.h>

Inheritance diagram for InstrumentLayer:
Object< InstrumentLayer > Base

Public Member Functions

 InstrumentLayer (std::shared_ptr< InstrumentLayer > other)
 copy constructor, will be initialized with an empty sample
 
 InstrumentLayer (std::shared_ptr< InstrumentLayer > other, std::shared_ptr< Sample > sample)
 copy constructor
 
 InstrumentLayer (std::shared_ptr< Sample > sample)
 constructor
 
 ~InstrumentLayer ()
 destructor
 
float get_end_velocity () const
 get the end velocity of the layer
 
float get_gain () const
 get the gain of the layer
 
float get_pitch () const
 get the pitch of the layer
 
std::shared_ptr< Sampleget_sample () const
 get the sample of the layer
 
float get_start_velocity () const
 get the start velocity of the layer
 
void load_sample (float fBpm=120)
 Calls the H2Core::Sample::load() member function of __sample.
 
void save_to (XMLNode *node, bool bFull=false)
 save the instrument layer within the given XMLNode
 
void set_end_velocity (float end)
 set the end velocity of the layer
 
void set_gain (float gain)
 set the gain of the layer
 
void set_pitch (float pitch)
 set the pitch of the layer
 
void set_sample (std::shared_ptr< Sample > sample)
 set the sample of the layer
 
void set_start_velocity (float start)
 set the start ivelocity of the layer
 
QString toQString (const QString &sPrefix="", bool bShort=true) const override
 Formatted string version for debugging purposes.
 
void unload_sample ()
 
- Public Member Functions inherited from Object< InstrumentLayer >
 Object ()
 
 Object (const Object< InstrumentLayer > &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 std::shared_ptr< InstrumentLayerload_from (XMLNode *pNode, const QString &sDrumkitPath, const License &drumkitLicense=License(), bool bSilent=false)
 load an instrument layer 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 Loggerlogger ()
 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

float __end_velocity
 the end velocity of the sample, 1.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
 
float __start_velocity
 the start velocity of the sample, 0.0 by default
 

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< InstrumentLayer >
 ~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
 

Detailed Description

InstrumentLayer is part of an instrument
each layer has it's own :
gain which is the ration between the input sample and the output signal,
pitch which allows you to play the sample at a faster or lower frequency,
start velocity and end velocity which allows you to chose between a layer or another within an instrument by changing the velocity of the played note.

so the only layer of an instrument should start at 0.0 and end at 1.0.

Definition at line 45 of file InstrumentLayer.h.

Constructor & Destructor Documentation

◆ InstrumentLayer() [1/3]

InstrumentLayer ( std::shared_ptr< Sample > sample)

constructor

Parameters
samplethe sample to use

Definition at line 37 of file InstrumentLayer.cpp.

◆ InstrumentLayer() [2/3]

InstrumentLayer ( std::shared_ptr< InstrumentLayer > other)

copy constructor, will be initialized with an empty sample

Parameters
otherthe instrument layer to copy from

Definition at line 46 of file InstrumentLayer.cpp.

◆ InstrumentLayer() [3/3]

InstrumentLayer ( std::shared_ptr< InstrumentLayer > other,
std::shared_ptr< Sample > sample )

copy constructor

Parameters
otherthe instrument layer to copy from
samplethe sample to use

Definition at line 55 of file InstrumentLayer.cpp.

◆ ~InstrumentLayer()

destructor

Definition at line 64 of file InstrumentLayer.cpp.

Member Function Documentation

◆ get_end_velocity()

float get_end_velocity ( ) const
inline

get the end velocity of the layer

Definition at line 171 of file InstrumentLayer.h.

◆ get_gain()

float get_gain ( ) const
inline

get the gain of the layer

Definition at line 146 of file InstrumentLayer.h.

◆ get_pitch()

float get_pitch ( ) const
inline

get the pitch of the layer

Definition at line 151 of file InstrumentLayer.h.

◆ get_sample()

std::shared_ptr< Sample > get_sample ( ) const
inline

get the sample of the layer

Definition at line 176 of file InstrumentLayer.h.

◆ get_start_velocity()

float get_start_velocity ( ) const
inline

get the start velocity of the layer

Definition at line 161 of file InstrumentLayer.h.

◆ load_from()

std::shared_ptr< InstrumentLayer > load_from ( XMLNode * pNode,
const QString & sDrumkitPath,
const License & drumkitLicense = License(),
bool bSilent = false )
static

load an instrument layer from an XMLNode

Parameters
pNodethe XMLDode to read from
sDrumkitPaththe directory holding the drumkit data
drumkitLicenseLicense assigned to all Sample contain in the loaded InstrumentLayer.
bSilentif set to true, all log messages except of errors and warnings are suppressed.
Returns
a new InstrumentLayer instance

Definition at line 96 of file InstrumentLayer.cpp.

◆ load_sample()

void load_sample ( float fBpm = 120)

Calls the H2Core::Sample::load() member function of __sample.

Definition at line 82 of file InstrumentLayer.cpp.

◆ save_to()

void save_to ( XMLNode * node,
bool bFull = false )

save the instrument layer within the given XMLNode

Parameters
nodethe XMLNode to feed
bFullWhether to write all parameters of the contained Sample as well. This will be done when storing an Instrument as part of a Song but not when storing as part of a Drumkit.

Definition at line 252 of file InstrumentLayer.cpp.

◆ set_end_velocity()

void set_end_velocity ( float end)
inline

set the end velocity of the layer

Definition at line 166 of file InstrumentLayer.h.

◆ set_gain()

void set_gain ( float gain)
inline

set the gain of the layer

Definition at line 141 of file InstrumentLayer.h.

◆ set_pitch()

void set_pitch ( float pitch)

set the pitch of the layer

Definition at line 73 of file InstrumentLayer.cpp.

◆ set_sample()

void set_sample ( std::shared_ptr< Sample > sample)

set the sample of the layer

Definition at line 68 of file InstrumentLayer.cpp.

◆ set_start_velocity()

void set_start_velocity ( float start)
inline

set the start ivelocity of the layer

Definition at line 156 of file InstrumentLayer.h.

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

Definition at line 323 of file InstrumentLayer.cpp.

◆ unload_sample()

void unload_sample ( )

Definition at line 89 of file InstrumentLayer.cpp.

Field Documentation

◆ __end_velocity

float __end_velocity
private

the end velocity of the sample, 1.0 by default

Definition at line 135 of file InstrumentLayer.h.

◆ __gain

float __gain
private

ratio between the input sample and the output signal, 1.0 by default

Definition at line 132 of file InstrumentLayer.h.

◆ __pitch

float __pitch
private

the frequency of the sample, 0.0 by default which means output pitch is the same as input pitch

Definition at line 133 of file InstrumentLayer.h.

◆ __sample

std::shared_ptr<Sample> __sample
private

the underlaying sample

Definition at line 136 of file InstrumentLayer.h.

◆ __start_velocity

float __start_velocity
private

the start velocity of the sample, 0.0 by default

Definition at line 134 of file InstrumentLayer.h.