Files
osc/include/voice.hpp
T

49 lines
776 B
C++
Raw Normal View History

2026-11-14 15:15:00 +06:00
#ifndef VOICE
#define VOICE
#include <cstdint>
#include <numbers>
#include <cmath>
2026-11-14 20:37:48 +06:00
#include <algorithm>
#include <random>
2026-11-14 15:15:00 +06:00
#include "../include/envelope.hpp"
#include "../include/oscillator.hpp"
2026-11-14 20:37:48 +06:00
#include "../include/stereo_sample.hpp"
2026-11-14 15:15:00 +06:00
class Voice{
public:
Voice(){
note = 0;
2026-11-14 20:37:48 +06:00
pan = 0.0;
2026-11-14 15:15:00 +06:00
active = false;
}
void note_on(uint8_t note, uint8_t velocity);
void note_off();
2026-11-14 20:37:48 +06:00
void set_pan(double value);
2026-11-14 15:15:00 +06:00
2026-11-14 20:37:48 +06:00
StereoSample generate();
2026-11-14 15:15:00 +06:00
bool is_active() const;
2026-11-14 20:37:48 +06:00
bool is_playing(uint8_t note_) const;
2026-11-14 15:15:00 +06:00
private:
Envelope envelope;
Oscillator oscillator;
uint8_t note;
2026-11-14 20:37:48 +06:00
double envelope_value;
double pan;
2026-11-14 15:15:00 +06:00
bool active;
2026-11-14 20:37:48 +06:00
2026-11-14 15:15:00 +06:00
};
#endif