2026-11-12 16:34:18 +06:00
|
|
|
#ifndef SYNTH
|
|
|
|
|
#define SYNTH
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
2026-11-14 15:15:00 +06:00
|
|
|
#include <array>
|
2026-11-13 18:31:07 +06:00
|
|
|
|
|
|
|
|
#include "../include/spsc_queue.hpp"
|
|
|
|
|
#include "../include/command.hpp"
|
2026-11-14 15:15:00 +06:00
|
|
|
#include "../include/voice.hpp"
|
2026-11-14 20:37:48 +06:00
|
|
|
#include "../include/stereo_sample.hpp"
|
2026-11-12 16:34:18 +06:00
|
|
|
|
|
|
|
|
class Synth {
|
|
|
|
|
public:
|
2026-11-14 20:37:48 +06:00
|
|
|
StereoSample generate();
|
2026-11-12 22:37:00 +06:00
|
|
|
|
2026-11-12 16:34:18 +06:00
|
|
|
void generate_buffer(double* array, int size);
|
|
|
|
|
void set_frequency(double value);
|
|
|
|
|
void set_amplitude(double value);
|
2026-11-13 23:59:25 +06:00
|
|
|
void set_midi_note(uint8_t note);
|
2026-11-12 16:34:18 +06:00
|
|
|
|
2026-11-13 23:59:25 +06:00
|
|
|
bool note_on(uint8_t note, uint8_t velocity);
|
|
|
|
|
bool note_off(uint8_t note);
|
2026-11-12 22:37:00 +06:00
|
|
|
|
2026-11-12 16:34:18 +06:00
|
|
|
private:
|
2026-11-14 20:37:48 +06:00
|
|
|
Voice* find_free_voice();
|
2026-11-13 02:02:50 +06:00
|
|
|
|
2026-11-13 18:31:07 +06:00
|
|
|
SpscQueue queue;
|
2026-11-14 15:15:00 +06:00
|
|
|
|
|
|
|
|
std::array<Voice, 8> voices;
|
2026-11-12 16:34:18 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|