]> git.treefish.org Git - seamulator.git/blob - include/synthesizer.h
Fix compilation
[seamulator.git] / include / synthesizer.h
1 /**
2  * Copyright (C) 2021  Alexander Schmidt
3  *
4  * This file is part of Seamulator.
5  *
6  * Seamulator is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Seamulator is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Seamulator.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #pragma once
21
22 #include "watersurfacefwd.h"
23
24 #include <chrono>
25 #include <mutex>
26 #include <thread>
27
28 #include "SineWave.h"
29 #include "RtWvOut.h"
30 #include "BlowBotl.h"
31 #include "Plucked.h"
32
33 #include "dot.h"
34 #include "posdot.h"
35
36 class Synthesizer {
37
38 public:
39     Synthesizer(ConstWaterSurfacePtr surface);
40     ~Synthesizer();
41
42     void tick();
43
44 private:
45     const ConstWaterSurfacePtr m_surface;
46
47     bool m_stop = false;
48     
49     std::chrono::time_point<std::chrono::system_clock> m_startTime;
50     double m_lastRuntime;
51     double m_pos = 0.0;
52     double m_vel = 0.0;
53
54
55     double m_pos2 = 0.0;
56     double m_vel2 = 0.0;
57
58     double m_velMax1 = 0.0;
59     double m_velMax2 = 0.0;
60
61     double getRuntime() const;
62
63     // int audioTick(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
64     //                double streamTime, RtAudioStreamStatus status, void *dataPointer );
65
66     void audioLoop();
67
68     std::vector<PosDot> m_posDots;
69     
70     stk::Plucked m_sine1;
71     stk::Plucked m_sine2;
72     //RtAudio m_dac;
73     std::unique_ptr<stk::RtWvOut> m_dac;
74
75     std::thread m_audioThread;
76
77 };