49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#ifndef SYNTH
|
|
#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"
|
|
|
|
class Synth {
|
|
public:
|
|
Synth(){
|
|
current_note = 0;
|
|
};
|
|
|
|
double 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:
|
|
/* 1. частота звука в Герцах
|
|
2. громкость звука, от 0 до 1
|
|
3. частота дискретизации
|
|
4. фаза. от 0 до 2 пи*/
|
|
|
|
Envelope envelope;
|
|
SpscQueue queue;
|
|
Oscillator oscillator;
|
|
|
|
std::array<Voice, 8> voices;
|
|
|
|
|
|
uint8_t current_note;
|
|
};
|
|
|
|
#endif
|