начал работу над envelope
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#ifndef ENVELOPE
|
||||
#define ENVELOPE
|
||||
|
||||
#include "../include/synth.hpp"
|
||||
|
||||
enum class Condition{
|
||||
Idle,
|
||||
Attack,
|
||||
Decay,
|
||||
Sustain,
|
||||
Release
|
||||
};
|
||||
|
||||
class Envelope{
|
||||
|
||||
public:
|
||||
Envelope(Synth& synth) : synth_(synth){
|
||||
condition = Condition::Idle;
|
||||
attack = 0.0;
|
||||
decay = 0.0;
|
||||
sustain = 0.0;
|
||||
release = 0.0;
|
||||
amplitude = 0.0;
|
||||
phase = 0.0;
|
||||
};
|
||||
void note_on();
|
||||
void note_off();
|
||||
double process();
|
||||
|
||||
private:
|
||||
Condition condition;
|
||||
Synth& synth_;
|
||||
|
||||
double attack;
|
||||
double decay;
|
||||
double sustain;
|
||||
double release;
|
||||
double amplitude;
|
||||
double phase;
|
||||
};
|
||||
|
||||
#endif
|
||||
+8
-6
@@ -6,7 +6,6 @@
|
||||
#include <cmath>
|
||||
|
||||
class Synth {
|
||||
// методы
|
||||
public:
|
||||
Synth(){
|
||||
frequency = 440;
|
||||
@@ -16,19 +15,22 @@ class Synth {
|
||||
};
|
||||
|
||||
double generate();
|
||||
|
||||
void generate_buffer(double* array, int size);
|
||||
void set_frequency(double value);
|
||||
void set_amplitude(double value);
|
||||
|
||||
// поля
|
||||
const double get_amplitude();
|
||||
const double get_phase();
|
||||
|
||||
private:
|
||||
// частота звука в Герцах
|
||||
/* 1. частота звука в Герцах
|
||||
2. громкость звука, от 0 до 1
|
||||
3. частота дискретизации
|
||||
4. фаза. от 0 до 2 пи*/
|
||||
double frequency;
|
||||
// громкость звука, от 0 до 1
|
||||
double amplitude;
|
||||
// частота дискретизации
|
||||
uint32_t sample_rate;
|
||||
// фаза. от 0 до 2 пи
|
||||
double phase;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user