Files
osc/include/synth.hpp
T
s13bby 9b01cf0480 добавлено управление Pitch Bend и Vibrato через MIDI
реализовано:
1. обработка MIDI Pitch Bend
2. управление глубиной вибрато через Mod Wheel (CC1)
3. реализован LFO на основе синусоидальной волны
4. добавлена частотная модуляция голосов с помощью LFO
5. реализовано совместное применение Pitch Bend и Vibrato без взаимного перезаписывания эффектов
6. добавлен пересчет частоты осциллятора с учетом всех множителей
2026-11-15 12:35:20 +06:00

59 lines
1.3 KiB
C++

#ifndef SYNTH
#define SYNTH
#include <cstdint>
#include <array>
#include <cmath>
#include "../include/spsc_queue.hpp"
#include "../include/command.hpp"
#include "../include/voice.hpp"
#include "../include/stereo_sample.hpp"
#include "../include/lfo.hpp"
class Synth {
public:
Synth(){
pitch_bend_range = 2.0;
pitch_semitones = 0.0;
pitch_multiplier = 1.0;
vibrato_depth_ = 0.0;
mod_wheel = 0;
stolen_voices = 0;
}
StereoSample generate();
void generate_buffer(double* array, int size);
void set_mod_wheel(uint8_t value);
void pitch_bend(uint16_t value);
double pitch_to_semitones(uint16_t value);
double semitones_to_multiplier(double semitones);
double mod_wheel_to_depth(uint8_t value);
bool note_on(uint8_t note, uint8_t velocity);
bool note_off(uint8_t note);
private:
Voice* find_free_voice();
Voice* find_quietest_voice();
SpscQueue queue;
Lfo lfo;
double pitch_bend_range;
double pitch_semitones;
double pitch_multiplier;
double vibrato_depth_;
uint8_t mod_wheel;
uint64_t stolen_voices;
std::array<Voice, 8> voices;
};
#endif