1 /*
2  * Hydrogen
3  * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4  *
5  * http://www.hydrogen-music.org
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY, without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22 
23 #ifndef H2C_DRUMKITCOMPONENT_H
24 #define H2C_DRUMKITCOMPONENT_H
25 
26 #include <cassert>
27 #include <inttypes.h>
28 
29 #include <hydrogen/object.h>
30 
31 namespace H2Core
32 {
33 
34 class XMLNode;
35 class ADSR;
36 class Drumkit;
37 class InstrumentLayer;
38 
39 class DrumkitComponent : public H2Core::Object
40 {
41 		H2_OBJECT
42 	public:
43 		DrumkitComponent( const int id, const QString& name );
44 		DrumkitComponent( DrumkitComponent* other );
45 		~DrumkitComponent();
46 
47 		void						save_to( XMLNode* node );
48 		static DrumkitComponent*	load_from( XMLNode* node, const QString& dk_path );
49 
50 		void						load_from( DrumkitComponent* component, bool is_live = true );
51 
52 		void						set_name( const QString& name );
53 		const QString&				get_name() const;
54 
55 		void						set_id( const int id );
56 		int							get_id() const;
57 
58 		void						set_volume( float volume );
59 		float						get_volume() const;
60 
61 		void						set_muted( bool active );
62 		bool						is_muted() const;
63 
64 		void						set_soloed( bool soloed );
65 		bool						is_soloed() const;
66 
67 		void						set_peak_l( float val );
68 		float						get_peak_l() const;
69 		void						set_peak_r( float val );
70 		float						get_peak_r() const;
71 
72 		void						reset_outs( uint32_t nFrames );
73 		void						set_outs( int nBufferPos, float valL, float valR );
74 		float						get_out_L( int nBufferPos );
75 		float						get_out_R( int nBufferPos );
76 
77 	private:
78 		int		__id;
79 	        /** Name of the DrumkitComponent. It is set by
80 		    set_name() and accessed via get_name().*/
81 		QString		__name;
82 		float		__volume;
83 		bool		__muted;
84 		bool		__soloed;
85 
86 		float		__peak_l;
87 		float		__peak_r;
88 
89 		float *		__out_L;
90 		float *		__out_R;
91 };
92 
93 // DEFINITIONS
94 /** Sets the name of the DrumkitComponent #__name.
95  * \param name New name. */
set_name(const QString & name)96 inline void DrumkitComponent::set_name( const QString& name )
97 {
98 	__name = name;
99 }
100 /** Access the name of the DrumkitComponent.
101  * \return #__name */
get_name()102 inline const QString& DrumkitComponent::get_name() const
103 {
104 	return __name;
105 }
106 
set_id(const int id)107 inline void DrumkitComponent::set_id( const int id )
108 {
109 	__id = id;
110 }
111 
get_id()112 inline int DrumkitComponent::get_id() const
113 {
114 	return __id;
115 }
116 
set_volume(float volume)117 inline void DrumkitComponent::set_volume( float volume )
118 {
119 	__volume = volume;
120 }
121 
get_volume()122 inline float DrumkitComponent::get_volume() const
123 {
124 	return __volume;
125 }
126 
set_muted(bool muted)127 inline void DrumkitComponent::set_muted( bool muted )
128 {
129 	__muted = muted;
130 }
131 
is_muted()132 inline bool DrumkitComponent::is_muted() const
133 {
134 	return __muted;
135 }
136 
set_soloed(bool soloed)137 inline void DrumkitComponent::set_soloed( bool soloed )
138 {
139 	__soloed = soloed;
140 }
141 
is_soloed()142 inline bool DrumkitComponent::is_soloed() const
143 {
144 	return __soloed;
145 }
146 
set_peak_l(float val)147 inline void DrumkitComponent::set_peak_l( float val )
148 {
149 	__peak_l = val;
150 }
151 
get_peak_l()152 inline float DrumkitComponent::get_peak_l() const
153 {
154 	return __peak_l;
155 }
156 
set_peak_r(float val)157 inline void DrumkitComponent::set_peak_r( float val )
158 {
159 	__peak_r = val;
160 }
161 
get_peak_r()162 inline float DrumkitComponent::get_peak_r() const
163 {
164 	return __peak_r;
165 }
166 
167 };
168 
169 
170 #endif
171