liquidsfz
liquidsfz.hh
Go to the documentation of this file.
1 /*
2  * liquidsfz - sfz sampler
3  *
4  * Copyright (C) 2019-2021 Stefan Westerfeld
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef LIQUIDSFZ_LIQUIDSFZ_HH
22 #define LIQUIDSFZ_LIQUIDSFZ_HH
23 
24 #include <memory>
25 #include <functional>
26 #include <vector>
27 #include <string>
28 
29 typedef unsigned int uint;
30 
35 namespace LiquidSFZ
36 {
37 
41 enum class Log {
42  DEBUG,
43  INFO,
44  WARNING,
45  ERROR,
46  DISABLE_ALL // special log level which can be used to disable all logging
47 };
48 
52 class CCInfo
53 {
54  friend class Synth;
55 
56  struct Impl;
57  std::unique_ptr<Impl> impl;
58 public:
59  CCInfo();
60  CCInfo (CCInfo&&) = default;
61  ~CCInfo();
62 
66  int cc() const;
67 
76  std::string label() const;
77 
84  bool has_label() const;
85 
91  int default_value() const;
92 };
93 
97 class KeyInfo
98 {
99  friend class Synth;
100 
101  struct Impl;
102  std::unique_ptr<Impl> impl;
103 public:
104  KeyInfo();
105  KeyInfo (KeyInfo&&) = default;
106  ~KeyInfo();
107 
111  int key() const;
112 
119  std::string label() const;
120 
127  bool is_switch() const;
128 };
129 
133 class Synth
134 {
135  struct Impl;
136  std::unique_ptr<Impl> impl;
137 
138 public:
139  Synth();
140  ~Synth();
141 
147  void set_sample_rate (uint sample_rate);
148 
154  void set_max_voices (uint n_voices);
155 
168  uint active_voice_count() const;
169 
177  void set_gain (float gain);
178 
191  bool load (const std::string& filename);
192 
198  std::vector<CCInfo> list_ccs() const;
199 
209  std::vector<KeyInfo> list_keys() const;
210 
227  void add_event_note_on (uint time_frames, int channel, int key, int velocity);
228 
243  void add_event_note_off (uint time_frames, int channel, int key);
244 
260  void add_event_cc (uint time_frames, int channel, int cc, int value);
261 
277  void add_event_pitch_bend (uint time_frames, int channel, int value);
278 
302  void process (float **outputs, uint n_frames);
303 
312  void all_sound_off();
313 
325  void system_reset();
326 
341  void set_log_level (Log log_level);
342 
348  void set_log_function (std::function<void (Log, const char *)> log_function);
349 
361  void set_progress_function (std::function<void (double)> progress_function);
362 };
363 
364 
497 }
498 #endif
LiquidSFZ::Synth::add_event_pitch_bend
void add_event_pitch_bend(uint time_frames, int channel, int value)
Add a pitch bend event.
LiquidSFZ::KeyInfo
Information for one key.
Definition: liquidsfz.hh:97
LiquidSFZ::Log
Log
Log levels for LiquidSFZ::Synth.
Definition: liquidsfz.hh:41
LiquidSFZ::Synth::set_log_level
void set_log_level(Log log_level)
Set minimum log level.
LiquidSFZ::KeyInfo::key
int key() const
LiquidSFZ::Synth::set_max_voices
void set_max_voices(uint n_voices)
Set maximum number of voices.
LiquidSFZ::KeyInfo::label
std::string label() const
LiquidSFZ::CCInfo::cc
int cc() const
LiquidSFZ::Synth::list_ccs
std::vector< CCInfo > list_ccs() const
List CCs supported by this .sfz file.
LiquidSFZ::Synth::add_event_note_off
void add_event_note_off(uint time_frames, int channel, int key)
Add a note off event.
LiquidSFZ::Synth
SFZ Synthesizer (main API)
Definition: liquidsfz.hh:133
LiquidSFZ::Synth::add_event_note_on
void add_event_note_on(uint time_frames, int channel, int key, int velocity)
Add a note on event.
LiquidSFZ::Synth::process
void process(float **outputs, uint n_frames)
Synthesize audio.
LiquidSFZ::Synth::active_voice_count
uint active_voice_count() const
Get active voice count.
LiquidSFZ::Synth::add_event_cc
void add_event_cc(uint time_frames, int channel, int cc, int value)
Add a cc event.
LiquidSFZ::CCInfo
Information for one continuous controller.
Definition: liquidsfz.hh:52
LiquidSFZ::Synth::all_sound_off
void all_sound_off()
All sound off.
LiquidSFZ::Synth::system_reset
void system_reset()
System reset.
LiquidSFZ::Synth::set_log_function
void set_log_function(std::function< void(Log, const char *)> log_function)
Set custom logging function.
LiquidSFZ::CCInfo::default_value
int default_value() const
LiquidSFZ::CCInfo::label
std::string label() const
LiquidSFZ::CCInfo::has_label
bool has_label() const
LiquidSFZ::Synth::set_gain
void set_gain(float gain)
Set global gain.
LiquidSFZ::Synth::load
bool load(const std::string &filename)
Load .sfz file including all samples.
LiquidSFZ::Synth::set_progress_function
void set_progress_function(std::function< void(double)> progress_function)
Set progress function.
LiquidSFZ::Synth::list_keys
std::vector< KeyInfo > list_keys() const
List active keys used by this .sfz file.
LiquidSFZ::Synth::set_sample_rate
void set_sample_rate(uint sample_rate)
Set sample rate of the synthesizer.
LiquidSFZ::KeyInfo::is_switch
bool is_switch() const