SoundFont class

class SoundFont

Represents a SoundFont file.

Construction / Destruction

SoundFont()

Constructor.

~SoundFont()

Destructor.

SoundFont file loading methods

bool load(const std::filesystem::path &path)

Load a SoundFont file.

Parameters:

path – Path to the SoundFont file

Returns:

True if the file was loaded successfully, false otherwise

bool load(const char *buffer, size_t size)

Load a SoundFont file from a buffer.

Parameters:
  • buffer – The buffer

  • size – Size of the buffer

Returns:

True if the file was loaded successfully, false otherwise

Principal methods for synthesis

bool getKeyInfo(uint16_t bank, uint16_t preset, uint8_t key, uint8_t velocity, key_info_t &result) const

Returns all the information needed to synthetise a key using a given preset.

All the relevant generators and modulators from the preset and the instrument are combined according to the specification and returned along with the relevant sample.

Parameters:
  • bank – The preset bank

  • preset – The preset number

  • key – The MIDI key

  • velocity – The velocity

  • result[out] The information about the key

Returns:

True if the information was found

inline const float *getBuffer() const

Returns the buffer of audio data, from which samples must be extracted.

Returns:

The buffer of audio data

SoundFont file content retrieval

inline const information_t &getInformation() const

Returns the information about the SoundFont file.

Returns:

The information

inline size_t nbPresets() const

Returns the number of presets.

Returns:

The number of presets

inline const preset_map_t &getPresets() const

Returns the presets.

Returns:

The list of presets

const preset_t *getPreset(uint16_t bank, uint16_t number) const

Returns the specified preset, identified by a ‘bank:number’ pair.

Parameters:
  • bank – The preset bank

  • number – The preset number

Returns:

The preset, nullptr if not found

inline size_t nbInstruments() const

Returns the number of instruments.

Returns:

The number of instruments

inline const std::vector<instrument_t> &getInstruments() const

Returns the instruments.

Returns:

The list of instruments

inline size_t nbSamples() const

Returns the number of samples.

Returns:

The number of samples

inline const std::vector<sample_t> &getSamples() const

Returns the samples.

Returns:

The list of samples