2cff003e4b
на данном этапе: 1. 8 полифонических голосов 2. ADSR огибающая для каждого голоса 3. MIDI Note On/Note Off 4. стереовыход 5. Equal-Power Panning 6. случайное распределение голосов по стереополю
49 lines
776 B
C++
49 lines
776 B
C++
#ifndef VOICE
|
|
#define VOICE
|
|
|
|
#include <cstdint>
|
|
#include <numbers>
|
|
#include <cmath>
|
|
#include <algorithm>
|
|
#include <random>
|
|
|
|
#include "../include/envelope.hpp"
|
|
#include "../include/oscillator.hpp"
|
|
#include "../include/stereo_sample.hpp"
|
|
|
|
|
|
class Voice{
|
|
public:
|
|
Voice(){
|
|
note = 0;
|
|
pan = 0.0;
|
|
|
|
active = false;
|
|
}
|
|
|
|
void note_on(uint8_t note, uint8_t velocity);
|
|
void note_off();
|
|
void set_pan(double value);
|
|
|
|
StereoSample generate();
|
|
|
|
bool is_active() const;
|
|
bool is_playing(uint8_t note_) const;
|
|
|
|
private:
|
|
Envelope envelope;
|
|
Oscillator oscillator;
|
|
|
|
uint8_t note;
|
|
|
|
double envelope_value;
|
|
double pan;
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|