liquidsfz
Public Member Functions | List of all members
LiquidSFZ::Synth Class Reference

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< CCInfolist_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...
 

Detailed Description

SFZ Synthesizer (main API)

Member Function Documentation

◆ add_event_cc()

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).

Parameters
time_framesthe start time of the event (in frames)
channelmidi channel
ccthe controller
valuenew value for the controller

◆ add_event_note_off()

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).

Parameters
time_framesthe start time of the event (in frames)
channelmidi channel
keynote that was pressed

◆ add_event_note_on()

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).

Parameters
time_framesthe start time of the event (in frames)
channelmidi channel
keynote that was pressed
velocityvelocity for note on

◆ add_event_pitch_bend()

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.

Parameters
time_framesthe start time of the event (in frames)
channelmidi channel
valuenew value for the controller [0..16383]

◆ list_ccs()

std::vector<CCInfo> LiquidSFZ::Synth::list_ccs ( ) const

List CCs supported by this .sfz file.

Returns
a vector that contains information for each supported CC

◆ load()

bool LiquidSFZ::Synth::load ( const std::string &  filename)

Load .sfz file including all samples.

Parameters
filenamename of the .sfz file
Returns
true if the .sfz could be loaded successfully

◆ process()

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.

Parameters
outputsbuffers for the output of the synthesizer
n_framesnumber of stereo frames to be written

◆ set_gain()

void LiquidSFZ::Synth::set_gain ( float  gain)

Set global gain.

Parameters
gaingain (as a factor)

◆ set_log_function()

void LiquidSFZ::Synth::set_log_function ( std::function< void(Log, const char *)>  log_function)

Set custom logging function.

Parameters
log_functionfunction to be called for log entries

◆ set_log_level()

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.

Parameters
log_levelminimum log level

◆ set_max_voices()

void LiquidSFZ::Synth::set_max_voices ( uint  n_voices)

Set maximum number of voices.

Parameters
n_voicesmaximum number of voices

◆ set_progress_function()

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.

Parameters
progress_functionfunction to be called

◆ set_sample_rate()

void LiquidSFZ::Synth::set_sample_rate ( uint  sample_rate)

Set sample rate of the synthesizer.

Parameters
sample_ratenew sample rate

The documentation for this class was generated from the following file: