MCPcopy Create free account
hub / github.com/HackerPoet/FractalSoundExplorer / Synth

Class Synth

Main.cpp:129–266  ·  view source on GitHub ↗

Synthesizer class to inherit Windows Audio.

Source from the content-addressed store, hash-verified

127
128//Synthesizer class to inherit Windows Audio.
129class Synth : public WinAudio {
130public:
131 bool audio_reset;
132 bool audio_pause;
133 double volume;
134 double play_x, play_y;
135 double play_cx, play_cy;
136 double play_nx, play_ny;
137 double play_px, play_py;
138
139 Synth(HWND hwnd) : WinAudio(hwnd, sample_rate) {
140 audio_reset = true;
141 audio_pause = false;
142 volume = 8000.0;
143 play_x = 0.0;
144 play_y = 0.0;
145 play_cx = 0.0;
146 play_cy = 0.0;
147 play_nx = 0.0;
148 play_ny = 0.0;
149 play_px = 0.0;
150 play_py = 0.0;
151 }
152
153 void SetPoint(double x, double y) {
154 play_nx = x;
155 play_ny = y;
156 audio_reset = true;
157 audio_pause = false;
158 }
159
160 virtual bool onGetData(Chunk& data) override {
161 //Setup the chunk info
162 data.samples = m_samples;
163 data.sampleCount = AUDIO_BUFF_SIZE;
164 memset(m_samples, 0, sizeof(m_samples));
165
166 //Check if audio needs to reset
167 if (audio_reset) {
168 m_audio_time = 0;
169 play_cx = (jx < 1e8 ? jx : play_nx);
170 play_cy = (jy < 1e8 ? jy : play_ny);
171 play_x = play_nx;
172 play_y = play_ny;
173 play_px = play_nx;
174 play_py = play_ny;
175 mean_x = play_nx;
176 mean_y = play_ny;
177 volume = 8000.0;
178 audio_reset = false;
179 }
180
181 //Check if paused
182 if (audio_pause) {
183 return true;
184 }
185
186 //Generate the tones

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected