hydrogen 1.2.3
InstrumentLayer.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef H2C_INSTRUMENT_LAYER_H
24#define H2C_INSTRUMENT_LAYER_H
25
26#include <memory>
27#include <core/Object.h>
28#include <core/License.h>
29
30namespace H2Core
31{
32
33 class XMLNode;
34 class Sample;
35
45 class InstrumentLayer : public H2Core::Object<InstrumentLayer>
46 {
48 public:
52 InstrumentLayer( std::shared_ptr<Sample> sample );
56 InstrumentLayer( std::shared_ptr<InstrumentLayer> other );
61 InstrumentLayer( std::shared_ptr<InstrumentLayer> other, std::shared_ptr<Sample> sample );
64
66 void set_gain( float gain );
68 float get_gain() const;
70 void set_pitch( float pitch );
72 float get_pitch() const;
73
75 void set_start_velocity( float start );
77 float get_start_velocity() const;
79 void set_end_velocity( float end );
81 float get_end_velocity() const;
83 void set_sample( std::shared_ptr<Sample> sample );
85 std::shared_ptr<Sample> get_sample() const;
86
91 void load_sample( float fBpm = 120 );
92 /*
93 * unload sample and replace it with an empty one
94 */
95 void unload_sample();
96
105 void save_to( XMLNode* node, bool bFull = false );
117 static std::shared_ptr<InstrumentLayer> load_from( XMLNode* pNode,
118 const QString& sDrumkitPath,
119 const License& drumkitLicense = License(),
120 bool bSilent = false );
129 QString toQString( const QString& sPrefix = "", bool bShort = true ) const override;
130
131 private:
132 float __gain;
133 float __pitch;
136 std::shared_ptr<Sample> __sample;
137 };
138
139 // DEFINITIONS
140
141 inline void InstrumentLayer::set_gain( float gain )
142 {
143 __gain = gain;
144 }
145
146 inline float InstrumentLayer::get_gain() const
147 {
148 return __gain;
149 }
150
151 inline void InstrumentLayer::set_pitch( float pitch )
152 {
153 __pitch = pitch;
154 }
155
156 inline float InstrumentLayer::get_pitch() const
157 {
158 return __pitch;
159 }
160
161 inline void InstrumentLayer::set_start_velocity( float start )
162 {
163 __start_velocity = start;
164 }
165
167 {
168 return __start_velocity;
169 }
170
171 inline void InstrumentLayer::set_end_velocity( float end )
172 {
173 __end_velocity = end;
174 }
175
177 {
178 return __end_velocity;
179 }
180
181 inline std::shared_ptr<Sample> InstrumentLayer::get_sample() const
182 {
183 return __sample;
184 }
185
186};
187
188#endif // H2C_INSTRUMENT_LAYER_H
189
190/* vim: set softtabstop=4 noexpandtab: */
#define H2_OBJECT(name)
Definition Object.h:224
InstrumentLayer is part of an instrument each layer has it's own : gain which is the ration between...
float get_gain() const
get the gain of the layer
void set_pitch(float pitch)
set the pitch of the layer
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
void set_end_velocity(float end)
set the end velocity of the layer
float __start_velocity
the start velocity of the sample, 0.0 by default
float get_pitch() const
get the pitch of the layer
void set_start_velocity(float start)
set the start ivelocity of the layer
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
void set_gain(float gain)
set the gain of the layer
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
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
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.
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
float get_end_velocity() const
get the end velocity of the layer
Wrapper class to help Hydrogen deal with the license information specified in a drumkit.
Definition License.h:48
XMLNode is a subclass of QDomNode with read and write values methods.
Definition Xml.h:39