3 #ifndef SPECTMORPH_MIDI_SYNTH_HH
4 #define SPECTMORPH_MIDI_SYNTH_HH
6 #include "smmorphplansynth.hh"
7 #include "smnotifybuffer.hh"
8 #include "sminsteditsynth.hh"
9 #include "smrtmemory.hh"
13 namespace SpectMorph {
34 EVENT_PITCH_EXPRESSION,
46 struct ExpressionEvent
85 PitchBendEvent pitch_bend;
89 std::vector<Event> events;
91 typedef std::array<float, MorphPlan::N_CONTROL_INPUTS> ModArray;
101 enum class MonoType {
115 double pitch_bend_freq;
116 double pitch_bend_factor;
117 int pitch_bend_steps;
136 constexpr
static int MAX_VOICES = 256;
141 std::vector<Voice> voices;
142 std::vector<Voice *> idle_voices;
143 std::vector<Voice *> active_voices;
144 ModArray global_modulation;
147 double m_tempo = 120;
148 double m_ppq_pos = 0;
151 uint64 audio_time_stamp;
153 float portamento_glide;
154 int portamento_note_id;
156 bool inst_edit =
false;
157 bool m_control_by_cc =
false;
162 std::vector<float> control = std::vector<float> (MorphPlan::N_CONTROL_INPUTS);
164 Voice *alloc_voice();
165 void free_unused_voices();
166 bool update_mono_voice();
167 float freq_from_note (
float note);
168 void notify_active_voice_status();
170 void set_mono_enabled (
bool new_value);
171 void process_audio (
float *output,
size_t n_values);
172 void process_note_on (
const NoteEvent& note);
173 void process_note_off (
int channel,
int midi_note);
174 void process_midi_controller (
int controller,
int value);
175 void process_pitch_bend (
int channel,
double semi_tones);
176 void process_mod_value (
const ModValueEvent& mod);
177 void start_pitch_bend (Voice *voice,
double dest_freq,
double time_ms);
178 void kill_all_active_voices();
181 MidiSynth (
double mix_freq,
size_t n_voices);
183 void add_midi_event (
size_t offset,
const unsigned char *midi_data);
184 void process (
float *output,
size_t n_values,
MidiSynthCallbacks *process_callbacks =
nullptr);
186 void add_note_on_event (uint offset,
int clap_id,
int channel,
int key,
float velocity);
187 void add_note_off_event (uint offset,
int channel,
int key);
188 void add_control_input_event (uint offset,
int i,
float value);
189 void add_pitch_expression_event (uint offset,
float value,
int channel,
int key);
190 void add_modulation_event (uint offset,
int i,
float value,
int clap_id,
int channel,
int key);
192 void set_control_input (
int i,
float value);
194 void set_tempo (
double tempo);
195 void set_ppq_pos (
double ppq_pos);
196 MorphPlanSynth::UpdateP prepare_update (
const MorphPlan& plan);
197 void apply_update (MorphPlanSynth::UpdateP update);
198 double mix_freq()
const;
200 size_t active_voice_count()
const;
202 void set_inst_edit (
bool inst_edit);
203 void set_gain (
double gain);
204 void set_control_by_cc (
bool control_by_cc);
222 INST_EDIT_VOICE_EVENT = 748293,
223 VOICE_OP_VALUES_EVENT,
224 ACTIVE_VOICE_STATUS_EVENT
234 float fundamental_note;
237 voices (buffer.read_seq<
Voice>()),
238 peak (buffer.read_float())
241 std::vector<Voice> voices;
254 voices (buffer.read_seq<
Voice>())
257 std::vector<Voice> voices;
263 voice (buffer.read_seq<uintptr_t>()),
264 velocity (buffer.read_seq<
float>())
266 for (
auto& ctrl : control)
267 ctrl = buffer.read_seq<
float>();
269 std::vector<uintptr_t> voice;
270 std::vector<float> velocity;
271 std::vector<float> control[MorphPlan::N_CONTROL_INPUTS];
Definition: sminsteditsynth.hh:17
Definition: smmidisynth.hh:27
Definition: smmorphplansynth.hh:20
Definition: smmorphplanvoice.hh:16
Definition: smmorphplan.hh:18
Definition: smnotifybuffer.hh:29
Definition: smrtmemory.hh:16
Definition: smmidisynth.hh:210
Definition: smtimeinfo.hh:18
Definition: smmidisynth.hh:261
Definition: smmidisynth.hh:230
Definition: smmidisynth.hh:228
Definition: smmidisynth.hh:18
Definition: smmidisynth.hh:16
Definition: smmidisynth.hh:248
Definition: smmidisynth.hh:246