SpectMorph
sminsteditsynth.hh
1 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl-2.1.html
2 
3 #ifndef SPECTMORPH_INST_EDIT_SYNTH_HH
4 #define SPECTMORPH_INST_EDIT_SYNTH_HH
5 
6 #include "smlivedecoder.hh"
7 #include "smnotifybuffer.hh"
8 
9 #include <string>
10 #include <memory>
11 
12 namespace SpectMorph {
13 
14 struct MidiSynthCallbacks;
15 
17 {
18 public:
19  struct Decoders {
20  std::unique_ptr<WavSet> wav_set;
21  std::vector<std::unique_ptr<LiveDecoder>> decoders;
22  };
23 private:
24  enum class State {
25  ON,
26  RELEASE,
27  IDLE
28  };
29  struct Voice {
30  State state = State::IDLE;
31  LiveDecoder *decoder = nullptr;
32  double decoder_factor = 0;
33  int note = 0;
34  unsigned int layer = 0;
35  int channel = 0;
36  int clap_id = -1;
37  };
38 
39  static constexpr uint n_layers = 3;
40  static constexpr uint voices_per_layer = 64;
41 
42  float mix_freq;
43  float gain = 1;
44  bool midi_to_reference = false;
45  float max_peak = 0;
46  std::vector<Voice> voices;
47  Decoders decoders;
48 
49 public:
50  InstEditSynth (float mix_freq);
51  ~InstEditSynth();
52 
53  Decoders create_decoders (WavSet *take_wav_set, WavSet *ref_wav_set);
54  void swap_decoders (Decoders& decoders);
55 
56  void set_gain (float gain);
57  void set_midi_to_reference (bool new_midi_to_reference);
58  void process_note_on (int channel, int note, int clap_id, int layer = -1);
59  void process_note_off (int channel, int note, int layer = -1);
60 
61  void process (float *output, size_t n_values, RTMemoryArea& rt_memory_area, NotifyBuffer& notify_buffer, MidiSynthCallbacks *process_callbacks);
62 };
63 
64 }
65 
66 #endif
Definition: sminsteditsynth.hh:17
Definition: smlivedecoder.hh:19
Definition: sminsteditsynth.hh:19