liquidsfz
liquidsfz.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2 
3 #ifndef LIQUIDSFZ_LIQUIDSFZ_HH
4 #define LIQUIDSFZ_LIQUIDSFZ_HH
5 
6 #include <memory>
7 #include <functional>
8 #include <vector>
9 #include <string>
10 
11 typedef unsigned int uint;
12 
17 namespace LiquidSFZ
18 {
19 
23 enum class Log {
24  DEBUG,
25  INFO,
26  WARNING,
27  ERROR,
28  DISABLE_ALL // special log level which can be used to disable all logging
29 };
30 
34 class CCInfo
35 {
36  friend class Synth;
37 
38  struct Impl;
39  std::unique_ptr<Impl> impl;
40 public:
41  CCInfo();
42  CCInfo (CCInfo&&) = default;
43  ~CCInfo();
44 
48  int cc() const;
49 
58  std::string label() const;
59 
66  bool has_label() const;
67 
73  int default_value() const;
74 };
75 
79 class KeyInfo
80 {
81  friend class Synth;
82 
83  struct Impl;
84  std::unique_ptr<Impl> impl;
85 public:
86  KeyInfo();
87  KeyInfo (KeyInfo&&) = default;
88  ~KeyInfo();
89 
93  int key() const;
94 
101  std::string label() const;
102 
109  bool is_switch() const;
110 };
111 
115 class Synth
116 {
117  struct Impl;
118  std::unique_ptr<Impl> impl;
119 
120 public:
121  Synth();
122  ~Synth();
123 
130 
136  uint sample_rate() const;
137 
143  void set_max_voices (uint n_voices);
144 
152  uint max_voices() const;
153 
167 
177  bool live_mode() const;
178 
191  void set_preload_time (uint time_ms);
192 
202  uint preload_time() const;
203 
223 
232 
245  uint active_voice_count() const;
246 
254  void set_gain (float gain);
255 
268  bool load (const std::string& filename);
269 
275  std::vector<CCInfo> list_ccs() const;
276 
286  std::vector<KeyInfo> list_keys() const;
287 
304  void add_event_note_on (uint time_frames, int channel, int key, int velocity);
305 
320  void add_event_note_off (uint time_frames, int channel, int key);
321 
337  void add_event_cc (uint time_frames, int channel, int cc, int value);
338 
354  void add_event_pitch_bend (uint time_frames, int channel, int value);
355 
379  void process (float **outputs, uint n_frames);
380 
390 
402  void system_reset();
403 
418  void set_log_level (Log log_level);
419 
425  void set_log_function (std::function<void (Log, const char *)> log_function);
426 
438  void set_progress_function (std::function<void (double)> progress_function);
439 
452  size_t cache_size() const;
453 
466  uint cache_file_count() const;
467 
484 
494  size_t max_cache_size() const;
495 };
496 
497 
630 }
631 #endif
Information for one continuous controller.
Definition: liquidsfz.hh:35
std::string label() const
int default_value() const
bool has_label() const
int cc() const
Information for one key.
Definition: liquidsfz.hh:80
std::string label() const
bool is_switch() const
SFZ Synthesizer (main API)
Definition: liquidsfz.hh:116
uint cache_file_count() const
Get number of cached samples.
void system_reset()
System reset.
void set_max_voices(uint n_voices)
Set maximum number of voices.
std::vector< KeyInfo > list_keys() const
List active keys used by this .sfz file.
size_t max_cache_size() const
Get maximum memory used by sample cache.
void set_log_function(std::function< void(Log, const char *)> log_function)
Set custom logging function.
void add_event_note_on(uint time_frames, int channel, int key, int velocity)
Add a note on event.
void set_sample_quality(int sample_quality)
Set sample quality.
void set_live_mode(bool live_mode)
Set live mode.
void add_event_pitch_bend(uint time_frames, int channel, int value)
Add a pitch bend event.
std::vector< CCInfo > list_ccs() const
List CCs supported by this .sfz file.
int sample_quality()
Get sample quality.
void all_sound_off()
All sound off.
uint preload_time() const
Get preload time.
void set_gain(float gain)
Set global gain.
void add_event_cc(uint time_frames, int channel, int cc, int value)
Add a cc event.
void set_max_cache_size(size_t max_cache_size)
Set maximum memory used by sample cache.
uint max_voices() const
Get maximum number of voices.
bool live_mode() const
Get live mode.
bool load(const std::string &filename)
Load .sfz file including all samples.
void set_sample_rate(uint sample_rate)
Set sample rate of the synthesizer.
void set_log_level(Log log_level)
Set minimum log level.
uint sample_rate() const
Get sample rate.
void set_progress_function(std::function< void(double)> progress_function)
Set progress function.
void add_event_note_off(uint time_frames, int channel, int key)
Add a note off event.
size_t cache_size() const
Get memory used by sample cache.
void set_preload_time(uint time_ms)
Set preload time.
uint active_voice_count() const
Get active voice count.
void process(float **outputs, uint n_frames)
Synthesize audio.
Log
Log levels for LiquidSFZ::Synth.
Definition: liquidsfz.hh:23