hydrogen 1.2.6
DrumkitComponent.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-2025 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_DRUMKITCOMPONENT_H
24#define H2C_DRUMKITCOMPONENT_H
25
26#include <cassert>
27#include <memory>
28#include <inttypes.h>
29#include <core/Object.h>
30
31namespace H2Core
32{
33
34class XMLNode;
35class ADSR;
36class Drumkit;
37class InstrumentLayer;
38
40class DrumkitComponent : public H2Core::Object<DrumkitComponent>
41{
43 public:
44 DrumkitComponent( const int id, const QString& name );
45 DrumkitComponent( std::shared_ptr<DrumkitComponent> other );
47
48 void save_to( XMLNode* node );
49 static std::shared_ptr<DrumkitComponent> load_from(
50 XMLNode* node,
51 bool* pLegacyFormatEncountered = nullptr );
52
53 void load_from( std::shared_ptr<DrumkitComponent> component );
54
55 void set_name( const QString& name );
56 const QString& get_name() const;
57
58 void set_id( const int id );
59 int get_id() const;
60
61 void set_volume( float volume );
62 float get_volume() const;
63
64 void set_muted( bool active );
65 bool is_muted() const;
66
67 void set_soloed( bool soloed );
68 bool is_soloed() const;
69
70 void set_peak_l( float val );
71 float get_peak_l() const;
72 void set_peak_r( float val );
73 float get_peak_r() const;
74
75 void reset_outs( uint32_t nFrames );
76 void set_outs( int nBufferPos, float valL, float valR );
77 float get_out_L( int nBufferPos );
78 float get_out_R( int nBufferPos );
87 QString toQString( const QString& sPrefix = "", bool bShort = true ) const override;
88 private:
89 int __id;
92 QString __name;
93 float __volume;
94 bool __muted;
96
97 float __peak_l;
98 float __peak_r;
99
100 float * __out_L;
101 float * __out_R;
102};
103
104// DEFINITIONS
107inline void DrumkitComponent::set_name( const QString& name )
108{
109 __name = name;
110}
111
113inline const QString& DrumkitComponent::get_name() const
114{
115 return __name;
116}
117
118inline void DrumkitComponent::set_id( const int id )
119{
120 __id = id;
121}
122
123inline int DrumkitComponent::get_id() const
124{
125 return __id;
126}
127
128inline void DrumkitComponent::set_volume( float volume )
129{
130 __volume = volume;
131}
132
134{
135 return __volume;
136}
137
138inline void DrumkitComponent::set_muted( bool muted )
139{
140 __muted = muted;
141}
142
143inline bool DrumkitComponent::is_muted() const
144{
145 return __muted;
146}
147
148inline void DrumkitComponent::set_soloed( bool soloed )
149{
150 __soloed = soloed;
151}
152
154{
155 return __soloed;
156}
157
158inline void DrumkitComponent::set_peak_l( float val )
159{
160 __peak_l = val;
161}
162
164{
165 return __peak_l;
166}
167
168inline void DrumkitComponent::set_peak_r( float val )
169{
170 __peak_r = val;
171}
172
174{
175 return __peak_r;
176}
177
178inline void DrumkitComponent::set_outs( int nBufferPos, float valL, float valR )
179{
180 __out_L[nBufferPos] += valL;
181 __out_R[nBufferPos] += valR;
182}
183
184};
185
186#endif
#define H2_OBJECT(name)
Definition Object.h:227
Attack Decay Sustain Release envelope.
Definition Adsr.h:38
QString __name
Name of the DrumkitComponent.
DrumkitComponent(const int id, const QString &name)
void set_name(const QString &name)
Sets the name of the DrumkitComponent __name.
const QString & get_name() const
Access the name of the DrumkitComponent.
static std::shared_ptr< DrumkitComponent > load_from(XMLNode *node, bool *pLegacyFormatEncountered=nullptr)
void set_soloed(bool soloed)
void set_volume(float volume)
void save_to(XMLNode *node)
void set_outs(int nBufferPos, float valL, float valR)
void set_id(const int id)
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
float get_out_L(int nBufferPos)
void reset_outs(uint32_t nFrames)
void set_muted(bool active)
float get_out_R(int nBufferPos)
Drumkit info.
Definition Drumkit.h:45
InstrumentLayer is part of an instrument each layer has it's own : gain which is the ration between...
XMLNode is a subclass of QDomNode with read and write values methods.
Definition Xml.h:39