summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/main.cc b/src/main.cc
index c0f6770..f63c803 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -2,10 +2,10 @@
// It serves as the application entry point.
// Orchestrates platform initialization, main loop, and subsystem coordination.
-#include "generated/assets.h" // Include generated asset header
#include "audio/audio.h"
#include "audio/gen.h"
#include "audio/synth.h"
+#include "generated/assets.h" // Include generated asset header
#include "gpu/gpu.h"
#include "platform.h"
#include "util/math.h"
@@ -29,8 +29,7 @@ struct SpecHeader {
int register_spec_asset(AssetId id) {
size_t size;
const uint8_t *data = GetAsset(id, &size);
- if (!data || size < sizeof(SpecHeader))
- return -1;
+ if (!data || size < sizeof(SpecHeader)) return -1;
const SpecHeader *header = (const SpecHeader *)data;
const float *spectral_data = (const float *)(data + sizeof(SpecHeader));
@@ -62,13 +61,11 @@ int generate_melody() {
srand(12345); // Fixed seed for reproducibility
for (int i = 0; i < 128; ++i) {
- if (i % 4 == 0)
- continue; // Rest on beat 1 of every bar
+ if (i % 4 == 0) continue; // Rest on beat 1 of every bar
NoteParams params = {};
params.base_freq = notes[rand() % num_notes];
- if (rand() % 4 == 0)
- params.base_freq *= 2.0f; // Occasional octave up
+ if (rand() % 4 == 0) params.base_freq *= 2.0f; // Occasional octave up
params.duration_sec = (rand() % 2 == 0) ? 0.2f : 0.4f;
params.amplitude = 0.4f;
@@ -121,9 +118,7 @@ float *generate_tone(float *buffer, float freq) {
float amplitude = 1000. * powf(1.0f - (float)frame / SPEC_FRAMES, 2.0f);
int bin = (int)(freq / (32000.0f / 2.0f) * DCT_SIZE);
- if (bin > 0 && bin < DCT_SIZE) {
- spec_frame[bin] = amplitude;
- }
+ if (bin > 0 && bin < DCT_SIZE) { spec_frame[bin] = amplitude; }
}
return buffer;
}
@@ -188,9 +183,7 @@ int main(int argc, char **argv) {
}
// Hihat on every offbeat
- if (step % 2 == 1) {
- synth_trigger_voice(hihat_id, 0.5f, 0.3f);
- }
+ if (step % 2 == 1) { synth_trigger_voice(hihat_id, 0.5f, 0.3f); }
// Bass pattern
if (step % 4 == 0) {