адаптация s13bby/osc под vst и gui. (вайбкод)
вайбкод потому что мне в моменте стало понятно. что проще было сразу писать на фреймворке JUCE, чем адаптировать консольное приложение на MiniAudio. обновляться данный репозиторий не будет. СmakeLists адаптирован онли под linux.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
#ifndef VOICE
|
||||
#define VOICE
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <numbers>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include "../include/envelope.hpp"
|
||||
#include "../include/oscillator.hpp"
|
||||
#include "../include/stereo_sample.hpp"
|
||||
#include "../include/filter.hpp"
|
||||
|
||||
class Voice{
|
||||
public:
|
||||
Voice(){
|
||||
|
||||
oscillators[1].base_detune = -10.0;
|
||||
oscillators[1].base_pan = -1.0;
|
||||
|
||||
oscillators[2].base_detune = 10.0;
|
||||
oscillators[2].base_pan = 1.0;
|
||||
|
||||
oscillators[3].base_detune = -20.0;
|
||||
oscillators[3].base_pan = -0.6;
|
||||
|
||||
oscillators[4].base_detune = 20.0;
|
||||
oscillators[4].base_pan = 0.6;
|
||||
|
||||
oscillators[5].base_detune = -30.0;
|
||||
oscillators[5].base_pan = -0.3;
|
||||
|
||||
oscillators[6].base_detune = 30.0;
|
||||
oscillators[6].base_pan = 0.3;
|
||||
|
||||
note = 0;
|
||||
unison_voices = 7;
|
||||
|
||||
envelope_value = 0.0;
|
||||
base_frequency = 440.0;
|
||||
pitch_bend = 1.0;
|
||||
vibrato = 1.0;
|
||||
stereo_spread = 1.0;
|
||||
detune_amount = 1.0;
|
||||
unison_gain = 1.0;
|
||||
|
||||
active = false;
|
||||
}
|
||||
|
||||
void set_sample_rate(double sample_rate_);
|
||||
void set_attack(double value);
|
||||
void set_decay(double value);
|
||||
void set_sustain(double value);
|
||||
void set_release(double value);
|
||||
void note_on(uint8_t note, uint8_t velocity);
|
||||
void note_off();
|
||||
void set_pitch_bend(double multiplier);
|
||||
void set_vibrato(double multiplier);
|
||||
void set_unison_voices(uint8_t value);
|
||||
void set_stereo_spread(double value);
|
||||
void set_detune_amount(double value);
|
||||
void set_unison_gain(double value);
|
||||
void set_wavetable(Wavetable* Wavetable);
|
||||
void set_wavetable2(Wavetable* Wavetable);
|
||||
void set_osc1_enabled(bool enabled);
|
||||
void set_osc2_enabled(bool enabled);
|
||||
void set_osc1_level(double value);
|
||||
void set_osc2_level(double value);
|
||||
void set_filter_cutoff(double value);
|
||||
void set_filter_resonance(double value);
|
||||
void set_filter_off();
|
||||
void set_hpf();
|
||||
void set_bpf();
|
||||
void set_lpf();
|
||||
void update_frequency();
|
||||
|
||||
StereoSample generate();
|
||||
|
||||
double get_volume() const;
|
||||
|
||||
bool is_active() const;
|
||||
bool is_playing(uint8_t note_) const;
|
||||
bool is_released() const;
|
||||
|
||||
private:
|
||||
Envelope envelope;
|
||||
Filter filter_left;
|
||||
Filter filter_right;
|
||||
std::array<UnisonOscillator, 7> oscillators{};
|
||||
|
||||
uint8_t note;
|
||||
uint8_t unison_voices;
|
||||
|
||||
double envelope_value;
|
||||
double base_frequency;
|
||||
double pitch_bend;
|
||||
double vibrato;
|
||||
double stereo_spread;
|
||||
double detune_amount;
|
||||
double unison_gain;
|
||||
bool osc1_enabled = true;
|
||||
bool osc2_enabled = false;
|
||||
double osc1_level = 1.0;
|
||||
double osc2_level = 0.0;
|
||||
|
||||
bool active;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user