Files
osc/include/synth.hpp
T

49 lines
1.1 KiB
C++
Raw Normal View History

#ifndef SYNTH
#define SYNTH
#include <cstdint>
#include <numbers>
#include <cmath>
2026-11-13 18:31:07 +06:00
#include <atomic>
2026-11-14 15:15:00 +06:00
#include <array>
2026-11-13 18:31:07 +06:00
#include "../include/envelope.hpp"
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/oscillator.hpp"
#include "../include/voice.hpp"
class Synth {
public:
Synth(){
2026-11-14 10:23:02 +06:00
current_note = 0;
};
double generate();
2026-11-12 22:37:00 +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-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
private:
2026-11-12 22:37:00 +06:00
/* 1. частота звука в Герцах
2. громкость звука, от 0 до 1
3. частота дискретизации
4. фаза. от 0 до 2 пи*/
Envelope envelope;
2026-11-13 18:31:07 +06:00
SpscQueue queue;
2026-11-14 15:15:00 +06:00
Oscillator oscillator;
std::array<Voice, 8> voices;
2026-11-14 10:23:02 +06:00
uint8_t current_note;
};
#endif