работа над envelope закончена
envelope работает. без щелчков
This commit is contained in:
@@ -33,11 +33,14 @@ class AudioEngine{
|
||||
int stop();
|
||||
|
||||
private:
|
||||
Synth& synth_;
|
||||
|
||||
bool device_is_init = false;
|
||||
bool device_is_started = false;
|
||||
Synth& synth_;
|
||||
|
||||
ma_device_config config = {};
|
||||
ma_device device = {};
|
||||
|
||||
ma_result result_init;
|
||||
ma_result result_start;
|
||||
ma_result result_stop;
|
||||
|
||||
+38
-16
@@ -1,7 +1,7 @@
|
||||
#ifndef ENVELOPE
|
||||
#define ENVELOPE
|
||||
|
||||
#include "../include/synth.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
enum class Condition{
|
||||
Idle,
|
||||
@@ -14,29 +14,51 @@ enum class Condition{
|
||||
class Envelope{
|
||||
|
||||
public:
|
||||
Envelope(Synth& synth) : synth_(synth){
|
||||
Envelope(){
|
||||
condition = Condition::Idle;
|
||||
attack = 0.0;
|
||||
decay = 0.0;
|
||||
sustain = 0.0;
|
||||
release = 0.0;
|
||||
amplitude = 0.0;
|
||||
phase = 0.0;
|
||||
};
|
||||
attack_time = 0.8;
|
||||
decay_time = 1.0;
|
||||
sustain_level = 0.7;
|
||||
release_time = 0.2;
|
||||
currnet_amplitude = 0.0;
|
||||
rate = 0.0;
|
||||
sample_rate = 48000;
|
||||
note_is_pressed = false;
|
||||
}
|
||||
|
||||
Envelope(double attack, double decay, double sustain, double release){
|
||||
condition = Condition::Idle;
|
||||
attack_time = attack;
|
||||
decay_time = decay;
|
||||
sustain_level = sustain;
|
||||
release_time = release;
|
||||
currnet_amplitude = 0.0;
|
||||
rate = 0.0;
|
||||
sample_rate = 48000;
|
||||
note_is_pressed = false;
|
||||
}
|
||||
|
||||
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;
|
||||
double attack_time;
|
||||
|
||||
double decay_time;
|
||||
|
||||
double sustain_level;
|
||||
|
||||
double release_time;
|
||||
|
||||
double currnet_amplitude;
|
||||
double rate;
|
||||
|
||||
uint32_t sample_rate;
|
||||
|
||||
bool note_is_pressed;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+8
-3
@@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <numbers>
|
||||
#include <cmath>
|
||||
#include "../include/envelope.hpp"
|
||||
|
||||
class Synth {
|
||||
public:
|
||||
@@ -20,18 +21,22 @@ class Synth {
|
||||
void set_frequency(double value);
|
||||
void set_amplitude(double value);
|
||||
|
||||
const double get_amplitude();
|
||||
const double get_phase();
|
||||
void note_on();
|
||||
void note_off();
|
||||
|
||||
private:
|
||||
/* 1. частота звука в Герцах
|
||||
2. громкость звука, от 0 до 1
|
||||
3. частота дискретизации
|
||||
4. фаза. от 0 до 2 пи*/
|
||||
|
||||
Envelope envelope;
|
||||
|
||||
double frequency;
|
||||
double amplitude;
|
||||
uint32_t sample_rate;
|
||||
double phase;
|
||||
|
||||
uint32_t sample_rate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user