полифония!

на данном этапе:
1. 8 полифонических голосов
2. ADSR огибающая для каждого голоса
3. MIDI Note On/Note Off
4. стереовыход
5. Equal-Power Panning
6. случайное распределение голосов по стереополю
This commit is contained in:
2026-11-14 20:37:48 +06:00
parent b4629fe2d3
commit 2cff003e4b
12 changed files with 127 additions and 75 deletions
+3 -19
View File
@@ -2,24 +2,16 @@
#define SYNTH
#include <cstdint>
#include <numbers>
#include <cmath>
#include <atomic>
#include <array>
#include "../include/envelope.hpp"
#include "../include/spsc_queue.hpp"
#include "../include/command.hpp"
#include "../include/oscillator.hpp"
#include "../include/voice.hpp"
#include "../include/stereo_sample.hpp"
class Synth {
public:
Synth(){
current_note = 0;
};
double generate();
StereoSample generate();
void generate_buffer(double* array, int size);
void set_frequency(double value);
@@ -30,19 +22,11 @@ class Synth {
bool note_off(uint8_t note);
private:
/* 1. частота звука в Герцах
2. громкость звука, от 0 до 1
3. частота дискретизации
4. фаза. от 0 до 2 пи*/
Voice* find_free_voice();
Envelope envelope;
SpscQueue queue;
Oscillator oscillator;
std::array<Voice, 8> voices;
uint8_t current_note;
};
#endif