liquidsfz
|
SFZ Synthesizer (main API) More...
#include <liquidsfz.hh>
Public Member Functions | |
void | set_sample_rate (uint sample_rate) |
Set sample rate of the synthesizer. More... | |
void | set_max_voices (uint n_voices) |
Set maximum number of voices. More... | |
void | set_gain (float gain) |
Set global gain. More... | |
bool | load (const std::string &filename) |
Load .sfz file including all samples. More... | |
std::vector< CCInfo > | list_ccs () const |
List CCs supported by this .sfz file. More... | |
void | add_event_note_on (uint time_frames, int channel, int key, int velocity) |
Add a note on event. More... | |
void | add_event_note_off (uint time_frames, int channel, int key) |
Add a note off event. More... | |
void | add_event_cc (uint time_frames, int channel, int cc, int value) |
Add a cc event. More... | |
void | add_event_pitch_bend (uint time_frames, int channel, int value) |
Add a pitch bend event. More... | |
void | process (float **outputs, uint n_frames) |
Synthesize audio. More... | |
void | set_log_level (Log log_level) |
Set minimum log level. More... | |
void | set_log_function (std::function< void(Log, const char *)> log_function) |
Set custom logging function. More... | |
void | set_progress_function (std::function< void(double)> progress_function) |
Set progress function. More... | |
SFZ Synthesizer (main API)
void LiquidSFZ::Synth::add_event_cc | ( | uint | time_frames, |
int | channel, | ||
int | cc, | ||
int | value | ||
) |
Add a cc event.
This function adds a cc event to the event list that will be rendered by the next process() call.
Events must always be added sorted by event time (time_frames).
time_frames | the start time of the event (in frames) |
channel | midi channel |
cc | the controller |
value | new value for the controller |
void LiquidSFZ::Synth::add_event_note_off | ( | uint | time_frames, |
int | channel, | ||
int | key | ||
) |
Add a note off event.
This function adds a note off event to the event list that will be rendered by the next process() call.
Events must always be added sorted by event time (time_frames).
time_frames | the start time of the event (in frames) |
channel | midi channel |
key | note that was pressed |
void LiquidSFZ::Synth::add_event_note_on | ( | uint | time_frames, |
int | channel, | ||
int | key, | ||
int | velocity | ||
) |
Add a note on event.
This function adds a note on event to the event list that will be rendered by the next process() call. A note on with velocity 0 will be treated as note off.
Events must always be added sorted by event time (time_frames).
time_frames | the start time of the event (in frames) |
channel | midi channel |
key | note that was pressed |
velocity | velocity for note on |
void LiquidSFZ::Synth::add_event_pitch_bend | ( | uint | time_frames, |
int | channel, | ||
int | value | ||
) |
Add a pitch bend event.
This function adds a pitch bend event to the event list that will be rendered by the next process() call.
Events must always be added sorted by event time (time_frames). The pitch bend value must in range [0..16383], center value is 8192.
time_frames | the start time of the event (in frames) |
channel | midi channel |
value | new value for the controller [0..16383] |
std::vector<CCInfo> LiquidSFZ::Synth::list_ccs | ( | ) | const |
List CCs supported by this .sfz file.
bool LiquidSFZ::Synth::load | ( | const std::string & | filename | ) |
Load .sfz file including all samples.
filename | name of the .sfz file |
void LiquidSFZ::Synth::process | ( | float ** | outputs, |
uint | n_frames | ||
) |
Synthesize audio.
This will render one stereo output stream, left output to outputs[0] and right output to outputs[1]. The contents of the output buffers will be overwritten.
Events that should be processed by this function can be added by calling some event functions before process():
These events will processed at the appropriate time positions (which means we provide sample accurate timing for all events). Events must always be added sorted by event time. After process() is done, the contents of event buffer will be discarded.
outputs | buffers for the output of the synthesizer |
n_frames | number of stereo frames to be written |
void LiquidSFZ::Synth::set_gain | ( | float | gain | ) |
Set global gain.
gain | gain (as a factor) |
void LiquidSFZ::Synth::set_log_function | ( | std::function< void(Log, const char *)> | log_function | ) |
Set custom logging function.
log_function | function to be called for log entries |
void LiquidSFZ::Synth::set_log_level | ( | Log | log_level | ) |
Set minimum log level.
This function can be used to set the minimum level of log messages that you are interested in. By default this is set to Log::INFO, which means that you will get errors, warnings and info messages, but not debug messages. Note that if you want to ignore some messages, it is better (more efficient) to do so by setting the log level than by setting a logging function with set_log_function() and ignoring some messages.
If you want to disable all messages, log_level can be set to Log::DISABLE_ALL.
log_level | minimum log level |
void LiquidSFZ::Synth::set_max_voices | ( | uint | n_voices | ) |
Set maximum number of voices.
n_voices | maximum number of voices |
void LiquidSFZ::Synth::set_progress_function | ( | std::function< void(double)> | progress_function | ) |
Set progress function.
Loading .sfz files can take a long time. In order to give feedback to the user, a progress function can be registered before calling load(). This progress function will be called during load() periodically with a percentage from 0%..100%. This can be used to display a progress bar at the ui.
progress_function | function to be called |
void LiquidSFZ::Synth::set_sample_rate | ( | uint | sample_rate | ) |
Set sample rate of the synthesizer.
sample_rate | new sample rate |