hydrogen 1.2.3
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-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_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( XMLNode* node );
50
51 void load_from( std::shared_ptr<DrumkitComponent> component );
52
53 void set_name( const QString& name );
54 const QString& get_name() const;
55
56 void set_id( const int id );
57 int get_id() const;
58
59 void set_volume( float volume );
60 float get_volume() const;
61
62 void set_muted( bool active );
63 bool is_muted() const;
64
65 void set_soloed( bool soloed );
66 bool is_soloed() const;
67
68 void set_peak_l( float val );
69 float get_peak_l() const;
70 void set_peak_r( float val );
71 float get_peak_r() const;
72
73 void reset_outs( uint32_t nFrames );
74 void set_outs( int nBufferPos, float valL, float valR );
75 float get_out_L( int nBufferPos );
76 float get_out_R( int nBufferPos );
85 QString toQString( const QString& sPrefix = "", bool bShort = true ) const override;
86 private:
87 int __id;
90 QString __name;
91 float __volume;
92 bool __muted;
94
95 float __peak_l;
96 float __peak_r;
97
98 float * __out_L;
99 float * __out_R;
100};
101
102// DEFINITIONS
105inline void DrumkitComponent::set_name( const QString& name )
106{
107 __name = name;
108}
111inline const QString& DrumkitComponent::get_name() const
112{
113 return __name;
114}
115
116inline void DrumkitComponent::set_id( const int id )
117{
118 __id = id;
119}
120
121inline int DrumkitComponent::get_id() const
122{
123 return __id;
124}
125
126inline void DrumkitComponent::set_volume( float volume )
127{
128 __volume = volume;
129}
130
132{
133 return __volume;
134}
135
136inline void DrumkitComponent::set_muted( bool muted )
137{
138 __muted = muted;
139}
140
141inline bool DrumkitComponent::is_muted() const
142{
143 return __muted;
144}
145
146inline void DrumkitComponent::set_soloed( bool soloed )
147{
148 __soloed = soloed;
149}
150
152{
153 return __soloed;
154}
155
156inline void DrumkitComponent::set_peak_l( float val )
157{
158 __peak_l = val;
159}
160
162{
163 return __peak_l;
164}
165
166inline void DrumkitComponent::set_peak_r( float val )
167{
168 __peak_r = val;
169}
170
172{
173 return __peak_r;
174}
175
176inline void DrumkitComponent::set_outs( int nBufferPos, float valL, float valR )
177{
178 __out_L[nBufferPos] += valL;
179 __out_R[nBufferPos] += valR;
180}
181
182};
183
184#endif
#define H2_OBJECT(name)
Definition Object.h:224
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)
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)
XMLNode is a subclass of QDomNode with read and write values methods.
Definition Xml.h:39