summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/main.cc b/src/main.cc
index 56d755c..315fa10 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -26,15 +26,23 @@ void generate_tone(float *buffer, float freq) {
}
}
-int main() {
- platform_init();
+int main(int argc, char **argv) {
+ bool fullscreen_enabled = false;
+ for (int i = 1; i < argc; ++i) {
+ if (strcmp(argv[i], "--fullscreen") == 0) {
+ fullscreen_enabled = true;
+ break;
+ }
+ }
+
+ platform_init_window(fullscreen_enabled);
gpu_init(platform_get_window());
audio_init();
generate_tone(g_spec_buffer_a, 440.0f); // A4
- generate_tone(g_spec_buffer_b, 880.0f); // A5
+ generate_tone(g_spec_buffer_b, 0.0f); // A5
- Spectrogram spec = {g_spec_buffer_a, g_spec_buffer_b, SPEC_FRAMES};
+ const Spectrogram spec = {g_spec_buffer_a, g_spec_buffer_b, SPEC_FRAMES};
int tone_id = synth_register_spectrogram(&spec);
double last_beat_time = 0.0;
@@ -45,21 +53,22 @@ int main() {
double current_time = platform_get_time();
if (current_time - last_beat_time > SECONDS_PER_BEAT) {
- synth_trigger_voice(tone_id, 0.5f, 0.0f);
+ const float pan = (beat_count & 1) ? -.8 : .8;
+ synth_trigger_voice(tone_id, 0.8f, pan);
last_beat_time = current_time;
beat_count++;
- if (beat_count == 8) {
+ if (beat_count % 4 == 0) {
// Time to update the sound!
float *back_buffer = synth_begin_update(tone_id);
if (back_buffer) {
- generate_tone(back_buffer, 220.0f); // A3
+ generate_tone(back_buffer, (beat_count % 8) == 4 ? 220.0f : 480.f); // A3
synth_commit_update(tone_id);
}
- }
+ }
}
- gpu_draw();
+ gpu_draw(synth_get_output_peak());
audio_update();
}