Files
osc/include/synth.hpp
T

43 lines
883 B
C++
Raw Normal View History

#ifndef SYNTH
#define SYNTH
#include <cstdint>
#include <numbers>
#include <cmath>
#include "../include/envelope.hpp"
class Synth {
public:
Synth(){
frequency = 440;
amplitude = 0.5;
sample_rate = 48000;
phase = 0.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);
void note_on();
void note_off();
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;
double frequency;
double amplitude;
double phase;
uint32_t sample_rate;
};
#endif