hydrogen 1.1.1
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

Public Member Functions

 InstrumentLayer (std::shared_ptr< Sample > sample)
 constructor More...
 
 InstrumentLayer (InstrumentLayer *other)
 copy constructor, will be initialized with an empty sample More...
 
 InstrumentLayer (InstrumentLayer *other, std::shared_ptr< Sample > sample)
 copy constructor More...
 
 ~InstrumentLayer ()
 destructor More...
 
void set_gain (float gain)
 set the gain of the layer More...
 
float get_gain () const
 get the gain of the layer More...
 
void set_pitch (float pitch)
 set the pitch of the layer More...
 
float get_pitch () const
 get the pitch of the layer More...
 
void set_start_velocity (float start)
 set the start ivelocity of the layer More...
 
float get_start_velocity () const
 get the start velocity of the layer More...
 
void set_end_velocity (float end)
 set the end velocity of the layer More...
 
float get_end_velocity () const
 get the end velocity of the layer More...
 
void set_sample (std::shared_ptr< Sample > sample)
 set the sample of the layer More...
 
std::shared_ptr< Sampleget_sample () const
 get the sample of the layer More...
 
void load_sample ()
 Calls the H2Core::Sample::load() member function of __sample. More...
 
void unload_sample ()
 
void save_to (XMLNode *node)
 save the instrument layer 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 InstrumentLayerload_from (XMLNode *node, const QString &dk_path)
 load an instrument layer from an XMLNode 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 Attributes

float __gain
 ratio between the input sample and the output signal, 1.0 by default More...
 
float __pitch
 the frequency of the sample, 0.0 by default which means output pitch is the same as input pitch More...
 
float __start_velocity
 the start velocity of the sample, 0.0 by default More...
 
float __end_velocity
 the end velocity of the sample, 1.0 by default More...
 
std::shared_ptr< Sample__sample
 the underlaying sample 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

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.

Constructor & Destructor Documentation

◆ InstrumentLayer() [1/3]

InstrumentLayer ( std::shared_ptr< Sample sample)

constructor

Parameters
samplethe sample to use

◆ InstrumentLayer() [2/3]

copy constructor, will be initialized with an empty sample

Parameters
otherthe instrument layer to copy from

◆ InstrumentLayer() [3/3]

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

copy constructor

Parameters
otherthe instrument layer to copy from
samplethe sample to use

◆ ~InstrumentLayer()

destructor

Member Function Documentation

◆ get_end_velocity()

float get_end_velocity ( ) const
inline

get the end velocity of the layer

◆ get_gain()

float get_gain ( ) const
inline

get the gain of the layer

◆ get_pitch()

float get_pitch ( ) const
inline

get the pitch of the layer

◆ get_sample()

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

get the sample of the layer

◆ get_start_velocity()

float get_start_velocity ( ) const
inline

get the start velocity of the layer

◆ load_from()

InstrumentLayer * load_from ( XMLNode node,
const QString &  dk_path 
)
static

load an instrument layer from an XMLNode

Parameters
nodethe XMLDode to read from
dk_paththe directory holding the drumkit data
Returns
a new InstrumentLayer instance

◆ load_sample()

void load_sample ( )

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

◆ save_to()

void save_to ( XMLNode node)

save the instrument layer within the given XMLNode

Parameters
nodethe XMLNode to feed

◆ set_end_velocity()

void set_end_velocity ( float  end)
inline

set the end velocity of the layer

◆ set_gain()

void set_gain ( float  gain)
inline

set the gain of the layer

◆ set_pitch()

void set_pitch ( float  pitch)
inline

set the pitch of the layer

◆ set_sample()

void set_sample ( std::shared_ptr< Sample sample)

set the sample of the layer

◆ set_start_velocity()

void set_start_velocity ( float  start)
inline

set the start ivelocity of the layer

◆ 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_sample()

void unload_sample ( )

Field Documentation

◆ __end_velocity

float __end_velocity
private

the end velocity of the sample, 1.0 by default

◆ __gain

float __gain
private

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

◆ __pitch

float __pitch
private

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

◆ __sample

std::shared_ptr<Sample> __sample
private

the underlaying sample

◆ __start_velocity

float __start_velocity
private

the start velocity of the sample, 0.0 by default