2cff003e4b
на данном этапе: 1. 8 полифонических голосов 2. ADSR огибающая для каждого голоса 3. MIDI Note On/Note Off 4. стереовыход 5. Equal-Power Panning 6. случайное распределение голосов по стереополю
33 lines
666 B
C++
33 lines
666 B
C++
#ifndef SYNTH
|
|
#define SYNTH
|
|
|
|
#include <cstdint>
|
|
#include <array>
|
|
|
|
#include "../include/spsc_queue.hpp"
|
|
#include "../include/command.hpp"
|
|
#include "../include/voice.hpp"
|
|
#include "../include/stereo_sample.hpp"
|
|
|
|
class Synth {
|
|
public:
|
|
StereoSample generate();
|
|
|
|
void generate_buffer(double* array, int size);
|
|
void set_frequency(double value);
|
|
void set_amplitude(double value);
|
|
void set_midi_note(uint8_t note);
|
|
|
|
bool note_on(uint8_t note, uint8_t velocity);
|
|
bool note_off(uint8_t note);
|
|
|
|
private:
|
|
Voice* find_free_voice();
|
|
|
|
SpscQueue queue;
|
|
|
|
std::array<Voice, 8> voices;
|
|
};
|
|
|
|
#endif
|