From 91f557d8777d6185ed47927318973d515f8dcbee Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 31 Jan 2026 00:47:55 +0100 Subject: Implement procedural audio generation, spectral effects, and WebGPU particle system --- src/main.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index 0bc28d6..9d7c41b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -62,11 +62,13 @@ 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; @@ -80,12 +82,14 @@ int generate_melody() { params.amp_randomness = 0.05f; int note_frames = 0; - std::vector note_data = generate_note_spectrogram(params, ¬e_frames); + std::vector note_data = + generate_note_spectrogram(params, ¬e_frames); // Apply some post-processing for texture apply_spectral_noise(note_data, note_frames, 0.2f); // Add grit if (i % 2 == 0) { - apply_spectral_comb(note_data, note_frames, 10.0f, 0.8f); // Phaser-like effect + apply_spectral_comb(note_data, note_frames, 10.0f, + 0.8f); // Phaser-like effect } // Calculate offset in frames @@ -94,7 +98,8 @@ int generate_melody() { float beat_time = i * SECONDS_PER_BEAT; int frame_offset = (int)(beat_time * 32000.0f / DCT_SIZE); - paste_spectrogram(g_melody_data, &melody_frames, note_data, note_frames, frame_offset); + paste_spectrogram(g_melody_data, &melody_frames, note_data, note_frames, + frame_offset); } Spectrogram spec; -- cgit v1.2.3