liquidsfz
Loading...
Searching...
No Matches
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#pragma once
4
5#include <memory>
6#include <array>
7#include <cstdint>
8#include <functional>
9#include <vector>
10#include <string>
11
12typedef unsigned int uint;
13
17
18namespace LiquidSFZ
19{
20
24enum class Log {
25 DEBUG,
26 INFO,
27 WARNING,
28 ERROR,
29 DISABLE_ALL // special log level which can be used to disable all logging
30};
31
35class CCInfo
36{
37 friend class Synth;
38
39 struct Impl;
40 std::unique_ptr<Impl> impl;
41public:
42 CCInfo();
43 CCInfo (CCInfo&&) = default;
44 ~CCInfo();
45
49 int cc() const;
50
59 std::string label() const;
60
67 bool has_label() const;
68
74 int default_value() const;
75};
76
80class KeyInfo
81{
82 friend class Synth;
83
84 struct Impl;
85 std::unique_ptr<Impl> impl;
86public:
87 KeyInfo();
88 KeyInfo (KeyInfo&&) = default;
89 ~KeyInfo();
90
94 int key() const;
95
102 std::string label() const;
103
110 bool is_switch() const;
111};
112
116class ProgramInfo
117{
118 friend class Synth;
119
120 struct Impl;
121 std::unique_ptr<Impl> impl;
122public:
123 ProgramInfo();
124 ProgramInfo (ProgramInfo&&) = default;
125 ~ProgramInfo();
126
133 uint index() const;
134
140 std::string label() const;
141};
142
146class Synth
147{
148 struct Impl;
149 std::unique_ptr<Impl> impl;
150
151public:
152 Synth();
153 ~Synth();
154
161
167 uint sample_rate() const;
168
174 void set_max_voices (uint n_voices);
175
183 uint max_voices() const;
184
199
209 bool live_mode() const;
210
223 void set_preload_time (uint time_ms);
224
234 uint preload_time() const;
235
255
264
277 uint active_voice_count() const;
278
286 void set_gain (float gain);
287
300 bool load (const std::string& filename);
301
310 bool is_bank (const std::string& filename) const;
311
322 bool load_bank (const std::string& filename);
323
332 std::vector<ProgramInfo> list_programs() const;
333
339 bool select_program (uint program);
340
346 std::vector<CCInfo> list_ccs() const;
347
357 std::vector<KeyInfo> list_keys() const;
358
364 using KeyStates = std::array<unsigned char, 128>;
365
376 KeyStates key_states() const;
377
391 std::uint64_t key_state_revision() const noexcept;
392
409 void add_event_note_on (uint time_frames, int channel, int key, int velocity);
410
425 void add_event_note_off (uint time_frames, int channel, int key);
426
442 void add_event_cc (uint time_frames, int channel, int cc, int value);
443
459 void add_event_pitch_bend (uint time_frames, int channel, int value);
460
484 void process (float **outputs, uint n_frames);
485
495
508
523 void set_log_level (Log log_level);
524
530 void set_log_function (std::function<void (Log, const char *)> log_function);
531
543 void set_progress_function (std::function<void (double)> progress_function);
544
557 size_t cache_size() const;
558
571 uint cache_file_count() const;
572
590 uint cache_miss_count() const;
591
608
618 size_t max_cache_size() const;
619};
620
621
753
754}
std::string label() const
int default_value() const
bool has_label() const
int cc() const
std::string label() const
bool is_switch() const
std::string label() const
std::vector< KeyInfo > list_keys() const
List active keys used by this .sfz file.
uint cache_miss_count() const
Get number of sample cache lookup misses.
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.
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.
bool select_program(uint program)
Select program from previously loaded AriaBank file.
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.
bool load_bank(const std::string &filename)
Load an AriaBank file.
bool is_bank(const std::string &filename) const
Check if the file is in AriaBank format.
void set_gain(float gain)
Set global gain.
KeyStates key_states() const
Get current keyboard state for each midi note.
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.
std::uint64_t key_state_revision() const noexcept
Get change counter for key_states().
std::vector< ProgramInfo > list_programs() const
List available programs defined in AriaBank file.
void set_sample_rate(uint sample_rate)
Set sample rate of the synthesizer.
KeyState
Definition liquidsfz.hh:359
@ KEY_REGION_ACTIVE
Playable key of a selected keyswitched region.
Definition liquidsfz.hh:362
@ KEY_PRESSED
Held on at least one MIDI channel (not sustain).
Definition liquidsfz.hh:360
@ KEY_SWITCH_ACTIVE
In the sw_last range of a selected region.
Definition liquidsfz.hh:361
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:24