Skip to content

Miscellaneous

Miscellaneous utility functions and defines.

Functions

fluid_free()

void fluid_free(void *ptr)

Wrapper for free() that satisfies at least C90 requirements.

Parameters:

Name Description
ptr Pointer to memory region that should be freed

Note

Only use this function when the API documentation explicitly says so. Otherwise use adequate delete_fluid_* functions.

Warning

Calling C-std lib free() on memory that is advised to be freed with fluid_free() results in undefined behaviour! (cf.: "Potential Errors Passing CRT Objects Across DLL Boundaries" found in MS Docs)

Since

2.0.7

fluid_is_midifile()

int fluid_is_midifile(const char *filename)

Check if a file is a MIDI file.

Parameters:

Name Description
filename Path to the file to check

Returns: TRUE if it could be a MIDI file, FALSE otherwise

The current implementation only checks for the "MThd" header in the file. It is useful only to distinguish between SoundFont and MIDI files.

fluid_is_soundfont()

int fluid_is_soundfont(const char *filename)

Check if a file is a SoundFont file.

Parameters:

Name Description
filename Path to the file to check

Returns: TRUE if it could be a SF2, SF3 or DLS file, FALSE otherwise

This function uses regular fopen(), fread() and fseek() to identify known Soundfont formats. If fluidsynth was built with DLS support, this function will also identify DLS files.

Note

This function only checks whether certain RIFF chunks are present in the file. A call to fluid_synth_sfload() might still fail, as it imposes much stricter structural checks.

fluid_version()

void fluid_version(int *major, int *minor, int *micro)

Get FluidSynth runtime version.

Parameters:

Name Description
major Location to store major number
minor Location to store minor number
micro Location to store micro number

fluid_version_str()

const char * fluid_version_str(void)

Get FluidSynth runtime version as a string.

Returns: FluidSynth version string, which is internal and should not be modified or freed.

Macros

FLUID_FAILED

Value that indicates failure, used by most libfluidsynth functions.

Note

See FLUID_OK for more details.

Since

1.1.0

FLUID_OK

Value that indicates success, used by most libfluidsynth functions.

Note

This was not publicly defined prior to libfluidsynth 1.1.0. When writing code which should also be compatible with older versions, something like the following can be used:

#include <fluidsynth.h>

#ifndef FLUID_OK
#define FLUID_OK      (0)
#define FLUID_FAILED  (-1)
#endif

Since

1.1.0

FLUIDSYNTH_VERSION

String constant of libfluidsynth version.

FLUIDSYNTH_VERSION_MAJOR

libfluidsynth major version integer constant.

FLUIDSYNTH_VERSION_MICRO

libfluidsynth micro version integer constant.

FLUIDSYNTH_VERSION_MINOR

libfluidsynth minor version integer constant.