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 
24 #ifndef SYNTH_H
25 #define SYNTH_H
26 
27 #include <stdint.h> // For uint32_t et al
28 
29 #include <hydrogen/object.h>
30 #include <hydrogen/basics/note.h>
31 #include <hydrogen/basics/song.h>
32 #include <hydrogen/IO/AudioOutput.h>
33 #include <hydrogen/globals.h>
34 
35 
36 namespace H2Core
37 {
38 
39 
40 
41 
42 ///
43 /// A simple synthetizer...
44 ///
45 class Synth : public H2Core::Object
46 {
47 	H2_OBJECT
48 public:
49 	float *m_pOut_L;
50 	float *m_pOut_R;
51 
52 	/**
53 	 * Constructor of the Synth.
54 	 *
55 	 * It is called by AudioEngine::AudioEngine() and stored in
56 	 * AudioEngine::__synth.
57 	 */
58 	Synth();
59 	~Synth();
60 
61 	/// Start playing a note
62 	void noteOn( Note* pNote );
63 
64 	/// Stop playing a note.
65 	void noteOff( Note* pNote );
66 
67 	void process( uint32_t nFrames );
68 	void setAudioOutput( AudioOutput* pAudioOutput );
69 
getPlayingNotesNumber()70 	int getPlayingNotesNumber() {
71 		return m_playingNotesQueue.size();
72 	}
73 
74 
75 private:
76 	std::vector<Note*> m_playingNotesQueue;
77 
78 	float m_fTheta;
79 	AudioOutput *m_pAudioOutput;
80 
81 
82 };
83 
84 } // namespace H2Core
85 
86 #endif
87 
88 
89