blob: a8f15a92de0203b871cb04d22fac4b934e80af1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// This file is part of the 64k demo project.
// It defines the public interface and data structures for the synth.
// Supports spectrogram registration, voice triggering, and real-time rendering.
#pragma once
#include "dct.h"
#include <cstdint>
// Based on tracker score analysis (see generated/music_data.cc)
// Max simultaneous patterns: 5, recommended: 10 each
// Using 16 for comfortable headroom
#define MAX_VOICES 16
#define MAX_SPECTROGRAMS 16
struct Spectrogram {
const float* spectral_data_a; // Front buffer
const float* spectral_data_b; // Back buffer (for double-buffering)
int num_frames;
};
void synth_init();
void synth_shutdown();
// Register a spectrogram for playback. Returns an ID or -1.
int synth_register_spectrogram(const Spectrogram* spec);
void synth_unregister_spectrogram(int spectrogram_id);
// Double-buffering API for thread-safe updates
float* synth_begin_update(int spectrogram_id);
void synth_commit_update(int spectrogram_id);
void synth_trigger_voice(int spectrogram_id, float volume, float pan);
void synth_render(float* output_buffer, int num_frames);
int synth_get_active_voice_count();
float synth_get_output_peak();
|