Merge pull request #297 from FluidSynth/cleanup3

YetAnotherCleanup
This commit is contained in:
Tom M 2017-12-07 17:14:13 +01:00 committed by GitHub
commit d463dff617
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 204 additions and 353 deletions

View file

@ -28,9 +28,9 @@ set ( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
set ( PACKAGE "fluidsynth" )
# FluidSynth package version
set ( FLUIDSYNTH_VERSION_MAJOR 1 )
set ( FLUIDSYNTH_VERSION_MINOR 1 )
set ( FLUIDSYNTH_VERSION_MICRO 8 )
set ( FLUIDSYNTH_VERSION_MAJOR 2 )
set ( FLUIDSYNTH_VERSION_MINOR 0 )
set ( FLUIDSYNTH_VERSION_MICRO 0 )
set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" )
set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" )
@ -43,9 +43,9 @@ set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" )
# if any interfaces have been added: AGE++
# if any interfaces have been removed/changed (compatibility broken): AGE=0
# This is not exactly the same algorithm as the libtool one, but the results are the same.
set ( LIB_VERSION_CURRENT 1 )
set ( LIB_VERSION_AGE 6 )
set ( LIB_VERSION_REVISION 1 )
set ( LIB_VERSION_CURRENT 2 )
set ( LIB_VERSION_AGE 0 )
set ( LIB_VERSION_REVISION 0 )
set ( LIB_VERSION_INFO
"${LIB_VERSION_CURRENT}.${LIB_VERSION_AGE}.${LIB_VERSION_REVISION}" )

View file

@ -88,7 +88,7 @@ FILE_PATTERNS = *.c *.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = fluid_*.h
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = ../doc
EXAMPLE_PATTERNS = *.c
@ -200,7 +200,7 @@ EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
PREDEFINED = __DOXYGEN__
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------

View file

@ -88,7 +88,7 @@ FILE_PATTERNS = *.c *.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = fluid_*.h
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/doc
EXAMPLE_PATTERNS = *.c
@ -200,7 +200,7 @@ EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
PREDEFINED = __DOXYGEN__
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------

View file

@ -74,33 +74,45 @@ FluidSynths SOVERSION was bumped. The API was reworked, deprecated functions wer
Changes in FluidSynth 2.0.0 concerning developers:
- remove deprecated fluid_synth_get_program() and fluid_synth_get_channel_preset(), use fluid_synth_get_channel_info() instead
- remove deprecated fluid_synth_get_channel_info() in favour of fluid_synth_get_program() and fluid_synth_get_channel_preset()
- remove deprecated fluid_settings_getstr()
- remove deprecated fluid_synth_set_midi_router()
- remove deprecated fluid_get_hinstance() and fluid_set_hinstance() (dsound driver now uses the desktop window)
- remove deprecated fluid_synth_create_key_tuning(), use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead
- remove deprecated fluid_synth_create_octave_tuning(), use fluid_synth_activate_octave_tuning(synth, bank, prog, name, pitch, FALSE) instead
- remove deprecated fluid_synth_select_tuning(), use fluid_synth_activate_tuning(synth, chan, bank, prog, FALSE) instead
- remove deprecated fluid_synth_reset_tuning(), use fluid_synth_deactivate_tuning(synth, chan, FALSE) instead
- remove deprecated FLUID_HINT_INTEGER
- remove misspelled FLUID_SEQ_PITCHWHHELSENS macro
- remove obsolete "audio.[out|in]put-channels" settings
- remove unimplemented "synth.dump" setting
- remove fluid_synth_set_gen2(), fluid_synth_set_gen() now behaves as fluid_synth_set_gen2()
- remove struct fluid_mod_t from public API, use the getters and setters of mod.h instead
- remove struct _fluid_mod_t from public API, use the getters and setters of mod.h instead
- remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API
- remove macros fluid_sfont_get_id() and fluid_sample_refcount() from public API
- remove FLUID_NUM_MOD macro from public API
- remove the following deprecated enum values:
- GEN_LAST
- LAST_LOG_LEVEL
- FLUID_SEQ_LASTEVENT
- FLUID_MIDI_ROUTER_RULE_COUNT
<br /><br />
- all public \c fluid_settings_* functions that return an integer which is not meant to be interpreted as bool consistently return either FLUID_OK or FLUID_FAILED
- all public delete_* functions return void and are safe when called with NULL
- the shell command handler was decoupled internally, as a consequence the param list of new_fluid_server() and new_fluid_cmd_handler() was adapted
- reverb: roomsize is now limited to an upper threshold of 1.0
- use unique device names for the "audio.portaudio.device" setting
- rename fluid_mod_new() and fluid_mod_delete() to match naming conventions: new_fluid_mod() and delete_fluid_mod()
<br /><br />
- add "synth.volenv" a setting for volume envelope processing
- add "midi.autoconnect" a setting for automatically connecting fluidsynth to available MIDI input ports
- add support for polyonic key pressure events, see fluid_event_key_pressure() and fluid_synth_key_pressure()
- add support for polyphonic key pressure events, see fluid_event_key_pressure() and fluid_synth_key_pressure()
- add fluid_synth_add_default_mod() and fluid_synth_remove_default_mod() for manipulating default modulators
- add individual reverb setters: fluid_synth_set_reverb_roomsize(), fluid_synth_set_reverb_damp(), fluid_synth_set_reverb_width(), fluid_synth_set_reverb_level()
- add individual chorus setters: fluid_synth_set_chorus_nr(), fluid_synth_set_chorus_level(), fluid_synth_set_chorus_speed(), fluid_synth_set_chorus_depth(), fluid_synth_set_chorus_type()
- introduce a separate data type for sequencer client IDs: #fluid_seq_id_t
- add file callback struct to _fluid_sfloader_t and expose new_fluid_defsfloader() to enable soundfont loading from memory ( see fluid_sfload_mem.c )
- add seek support to midi-player, see fluid_player_seek()
- expose functions to manipulate the ladspa effects unit (see ladspa.h)
\section NewIn1_1_9 Whats new in 1.1.9?

View file

@ -59,7 +59,9 @@ enum fluid_seq_event_type {
FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */
FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */
FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */
FLUID_SEQ_LASTEVENT /**< Defines the count of event enums @deprecated As of 1.1.7 this enum value is deprecated and will be removed in a future release, because it prevents adding new enum values without breaking ABI compatibility. */
#ifndef __DOXYGEN__
FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
#endif
};
/* Event alloc/free */

View file

@ -99,7 +99,9 @@ enum fluid_gen_type {
* is used, however, as the destination for the default pitch wheel
* modulator. */
GEN_PITCH, /**< Pitch @note Not a real SoundFont generator */
GEN_LAST /**< Value defines the count of generators (#fluid_gen_type) @deprecated As of 1.1.7 this enum value is deprecated and will be removed in a future release, because it prevents adding new enum values without breaking ABI compatibility. */
#ifndef __DOXYGEN__
GEN_LAST /**< @internal Value defines the count of generators (#fluid_gen_type) @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
#endif
};

View file

@ -25,6 +25,17 @@
extern "C" {
#endif
/**
* @file ladspa.h
* @brief Functions for manipulating the ladspa effects unit
*
* This header defines useful functions for programatically manipulating the ladspa
* effects unit of the synth that can be retrieved via fluid_synth_get_ladspa_fx().
*
* Using any of those functions requires fluidsynth to be compiled with ladspa support.
* Else all of those functions are useless dummies.
*/
FLUIDSYNTH_API int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_activate(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx);

View file

@ -58,7 +58,9 @@ enum fluid_log_level {
FLUID_WARN, /**< Warning */
FLUID_INFO, /**< Verbose informational messages */
FLUID_DBG, /**< Debugging messages */
LAST_LOG_LEVEL /**< @deprecated As of 1.1.7 this enum value is deprecated and will be removed in a future release, because it prevents adding new enum values without breaking ABI compatibility. */
#ifndef __DOXYGEN__
LAST_LOG_LEVEL /**< @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
#endif
};
/**

View file

@ -64,7 +64,9 @@ typedef enum
FLUID_MIDI_ROUTER_RULE_PITCH_BEND, /**< MIDI pitch bend rule */
FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, /**< MIDI channel pressure rule */
FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, /**< MIDI key pressure rule */
FLUID_MIDI_ROUTER_RULE_COUNT /**< Total count of rule types */
#ifndef __DOXYGEN__
FLUID_MIDI_ROUTER_RULE_COUNT /**< @internal Total count of rule types @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time!*/
#endif
} fluid_midi_router_rule_type;
/**

View file

@ -30,7 +30,6 @@ extern "C" {
* @brief SoundFont modulator functions and constants.
*/
#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */
/**
* Flags defining the polarity, mapping function and type of a modulator source.
@ -68,8 +67,8 @@ enum fluid_mod_src
FLUID_MOD_PITCHWHEELSENS = 16 /**< Pitch wheel sensitivity */
};
FLUIDSYNTH_API fluid_mod_t* fluid_mod_new(void);
FLUIDSYNTH_API void fluid_mod_delete(fluid_mod_t * mod);
FLUIDSYNTH_API fluid_mod_t* new_fluid_mod(void);
FLUIDSYNTH_API void delete_fluid_mod(fluid_mod_t * mod);
FLUIDSYNTH_API void fluid_mod_set_source1(fluid_mod_t* mod, int src, int flags);
FLUIDSYNTH_API void fluid_mod_set_source2(fluid_mod_t* mod, int src, int flags);

View file

@ -70,6 +70,18 @@ enum {
FLUID_SAMPLE_DONE /**< Sample no longer needed notify */
};
/**
* Indicates the type of a sample used by the _fluid_sample_t::sampletype field.
*/
enum fluid_sample_type
{
FLUID_SAMPLETYPE_MONO = 0x1, /**< Used for mono samples */
FLUID_SAMPLETYPE_RIGHT = 0x2, /**< Used for right samples of a stereo pair */
FLUID_SAMPLETYPE_LEFT = 0x4, /**< Used for left samples of a stereo pair */
FLUID_SAMPLETYPE_LINKED = 0x8, /**< Currently not used */
FLUID_SAMPLETYPE_OGG_VORBIS = 0x10, /**< Used for Ogg Vorbis compressed samples @since 1.1.7 */
FLUID_SAMPLETYPE_ROM = 0x8000 /**< Indicates ROM samples, causes sample to be ignored */
};
/**
* SoundFont loader structure.
@ -191,7 +203,6 @@ struct _fluid_sfont_t {
int (*iteration_next)(fluid_sfont_t* sfont, fluid_preset_t* preset);
};
#define fluid_sfont_get_id(_sf) ((_sf)->id)
/**
* Virtual SoundFont preset.
@ -284,14 +295,14 @@ struct _fluid_sample_t
unsigned int samplerate; /**< Sample rate */
int origpitch; /**< Original pitch (MIDI note number, 0-127) */
int pitchadj; /**< Fine pitch adjustment (+/- 99 cents) */
int sampletype; /**< Values: #FLUID_SAMPLETYPE_MONO, FLUID_SAMPLETYPE_RIGHT, FLUID_SAMPLETYPE_LEFT, FLUID_SAMPLETYPE_ROM */
int sampletype; /**< Specifies the type of this sample as indicated by the #fluid_sample_type enum */
int valid; /**< Should be TRUE if sample data is valid, FALSE otherwise (in which case it will not be synthesized) */
short* data; /**< Pointer to the sample's data */
int amplitude_that_reaches_noise_floor_is_valid; /**< Indicates if \a amplitude_that_reaches_noise_floor is valid (TRUE), set to FALSE initially to calculate. */
double amplitude_that_reaches_noise_floor; /**< The amplitude at which the sample's loop will be below the noise floor. For voice off optimization, calculated automatically. */
unsigned int refcount; /**< Count of voices using this sample (use #fluid_sample_refcount to access this field) */
unsigned int refcount; /**< Count of voices using this sample */
/**
* Implement this function to receive notification when sample is no longer used.
@ -305,18 +316,6 @@ struct _fluid_sample_t
};
#define fluid_sample_refcount(_sample) ((_sample)->refcount) /**< Get the reference count of a sample. Should only be called from within synthesis context (noteon method for example) */
#define FLUID_SAMPLETYPE_MONO 1 /**< Flag for #fluid_sample_t \a sampletype field for mono samples */
#define FLUID_SAMPLETYPE_RIGHT 2 /**< Flag for #fluid_sample_t \a sampletype field for right samples of a stereo pair */
#define FLUID_SAMPLETYPE_LEFT 4 /**< Flag for #fluid_sample_t \a sampletype field for left samples of a stereo pair */
#define FLUID_SAMPLETYPE_LINKED 8 /**< Flag for #fluid_sample_t \a sampletype field, not used currently */
#define FLUID_SAMPLETYPE_OGG_VORBIS 0x10 /**< Flag for #fluid_sample_t \a sampletype field for Ogg Vorbis compressed samples @since 1.1.7 */
#define FLUID_SAMPLETYPE_ROM 0x8000 /**< Flag for #fluid_sample_t \a sampletype field, ROM sample, causes sample to be ignored */
#ifdef __cplusplus
}
#endif

View file

@ -45,22 +45,6 @@ extern "C" {
* fluid_synth_noteon(), fluid_synth_noteoff(), ...
*/
#define FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE 32 /**< Length of channel info name field (including zero terminator) */
/**
* Channel information structure for fluid_synth_get_channel_info().
* @since 2.0.0
*/
struct _fluid_synth_channel_info_t
{
int assigned : 1; /**< TRUE if a preset is assigned, FALSE otherwise */
/* Reserved flag bits (at the least 31) */
int sfont_id; /**< ID of parent SoundFont */
int bank; /**< MIDI bank number (0-16383) */
int program; /**< MIDI program number (0-127) */
char name[FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE]; /**< Channel preset name */
char reserved[32]; /**< Reserved data for future expansion */
};
FLUIDSYNTH_API fluid_synth_t* new_fluid_synth(fluid_settings_t* settings);
FLUIDSYNTH_API void delete_fluid_synth(fluid_synth_t* synth);
@ -95,9 +79,6 @@ FLUIDSYNTH_API
int fluid_synth_get_program(fluid_synth_t* synth, int chan, unsigned int* sfont_id,
unsigned int* bank_num, unsigned int* preset_num);
FLUIDSYNTH_API int fluid_synth_unset_program (fluid_synth_t *synth, int chan);
FLUIDSYNTH_API
FLUID_DEPRECATED
int fluid_synth_get_channel_info (fluid_synth_t *synth, int chan, fluid_synth_channel_info_t *info);
FLUIDSYNTH_API int fluid_synth_program_reset(fluid_synth_t* synth);
FLUIDSYNTH_API int fluid_synth_system_reset(fluid_synth_t* synth);
@ -237,6 +218,8 @@ enum fluid_interp {
/* Generator interface */
FLUIDSYNTH_API int fluid_synth_set_gen (fluid_synth_t* synth, int chan,
int param, float value);
FLUIDSYNTH_API int fluid_synth_set_gen2 (fluid_synth_t* synth, int chan,
int param, float value,
int absolute, int normalized);
FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int param);
@ -244,33 +227,19 @@ FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int par
/* Tuning */
FLUIDSYNTH_API
FLUID_DEPRECATED
int fluid_synth_create_key_tuning(fluid_synth_t* synth, int bank, int prog,
const char* name, const double* pitch);
FLUIDSYNTH_API
int fluid_synth_activate_key_tuning(fluid_synth_t* synth, int bank, int prog,
const char* name, const double* pitch, int apply);
FLUIDSYNTH_API
FLUID_DEPRECATED
int fluid_synth_create_octave_tuning(fluid_synth_t* synth, int bank, int prog,
const char* name, const double* pitch);
FLUIDSYNTH_API
int fluid_synth_activate_octave_tuning(fluid_synth_t* synth, int bank, int prog,
const char* name, const double* pitch, int apply);
FLUIDSYNTH_API
int fluid_synth_tune_notes(fluid_synth_t* synth, int bank, int prog,
int len, const int *keys, const double* pitch, int apply);
FLUIDSYNTH_API
FLUID_DEPRECATED
int fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int bank, int prog);
FLUIDSYNTH_API
int fluid_synth_activate_tuning(fluid_synth_t* synth, int chan, int bank, int prog,
int apply);
FLUIDSYNTH_API
FLUID_DEPRECATED
int fluid_synth_reset_tuning(fluid_synth_t* synth, int chan);
FLUIDSYNTH_API
int fluid_synth_deactivate_tuning(fluid_synth_t* synth, int chan, int apply);
FLUIDSYNTH_API void fluid_synth_tuning_iteration_start(fluid_synth_t* synth);
FLUIDSYNTH_API
@ -343,9 +312,6 @@ FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t*
FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t* synth,
fluid_voice_t* buf[], int bufsize, int ID);
FLUIDSYNTH_API int fluid_synth_handle_midi_event(void* data, fluid_midi_event_t* event);
FLUIDSYNTH_API
FLUID_DEPRECATED
void fluid_synth_set_midi_router(fluid_synth_t* synth, fluid_midi_router_t* router);
/* LADSPA */

View file

@ -35,7 +35,6 @@ extern "C" {
typedef struct _fluid_hashtable_t fluid_settings_t; /**< Configuration settings instance */
typedef struct _fluid_synth_t fluid_synth_t; /**< Synthesizer instance */
typedef struct _fluid_synth_channel_info_t fluid_synth_channel_info_t; /**< SoundFont channel info */
typedef struct _fluid_voice_t fluid_voice_t; /**< Synthesis voice instance */
typedef struct _fluid_sfloader_t fluid_sfloader_t; /**< SoundFont loader plugin */
typedef struct _fluid_sfont_t fluid_sfont_t; /**< SoundFont */

View file

@ -36,8 +36,6 @@ extern "C" {
*/
FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen);
/**
* Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators.
*/
@ -48,21 +46,22 @@ enum fluid_voice_add_mod {
};
FLUIDSYNTH_API void fluid_voice_add_mod(fluid_voice_t* voice, fluid_mod_t* mod, int mode);
FLUIDSYNTH_API void fluid_voice_gen_set(fluid_voice_t* voice, int gen, float val);
FLUIDSYNTH_API float fluid_voice_gen_get(fluid_voice_t* voice, int gen);
FLUIDSYNTH_API void fluid_voice_gen_set(fluid_voice_t* voice, int gen, float val);
FLUIDSYNTH_API void fluid_voice_gen_incr(fluid_voice_t* voice, int gen, float val);
FLUIDSYNTH_API unsigned int fluid_voice_get_id(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_channel(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_key(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_actual_key(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_velocity(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_actual_velocity(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_is_playing(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_is_on(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_is_sustained(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_is_sostenuto(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_channel(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_actual_key(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_key(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_actual_velocity(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_get_velocity(const fluid_voice_t* voice);
FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t* s);
FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t* s);
FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen);
#ifdef __cplusplus

View file

@ -27,7 +27,7 @@
#include "fluid_ladspa.h"
#ifdef LADSPA
#if defined(LADSPA) || defined(__DOXYGEN__)
#include <math.h>
#include <ladspa.h>

View file

@ -263,7 +263,7 @@ int fluid_track_send_events(fluid_track_t* track,
#define fluid_track_eot(track) ((track)->cur == NULL)
/**
/*
* fluid_playlist_item
* Used as the `data' elements of the fluid_player.playlist.
* Represents either a filename or a pre-loaded memory buffer.

View file

@ -48,7 +48,7 @@ enum fluid_loop {
FLUID_LOOP_UNTIL_RELEASE = 3
};
/**
/*
* rvoice ticks-based parameters
* These parameters must be updated even if the voice is currently quiet.
*/
@ -77,7 +77,7 @@ struct _fluid_rvoice_envlfo_t
fluid_real_t viblfo_to_pitch;
};
/**
/*
* rvoice parameters needed for dsp interpolation
*/
struct _fluid_rvoice_dsp_t
@ -129,7 +129,7 @@ struct _fluid_rvoice_dsp_t
ever add surround positioning, or stereo reverb/chorus */
#define FLUID_RVOICE_MAX_BUFS (4)
/**
/*
* rvoice mixer-related parameters
*/
struct _fluid_rvoice_buffers_t
@ -142,7 +142,7 @@ struct _fluid_rvoice_buffers_t
};
/**
/*
* Hard real-time parameters needed to synthesize a voice
*/
struct _fluid_rvoice_t

View file

@ -42,7 +42,7 @@ struct _fluid_rvoice_event_t {
void fluid_rvoice_event_dispatch(fluid_rvoice_event_t* event);
/**
/*
* Bridge between the renderer thread and the midi state thread.
* If is_threadsafe is true, that means fluid_rvoice_eventhandler_fetch_all
* can be called in parallell with fluid_rvoice_eventhandler_push/flush

View file

@ -552,7 +552,7 @@ int delete_fluid_defsfont(fluid_defsfont_t* sfont)
/* Check that no samples are currently used */
for (list = sfont->sample; list; list = fluid_list_next(list)) {
sample = (fluid_sample_t*) fluid_list_get(list);
if (fluid_sample_refcount(sample) != 0) {
if (sample->refcount != 0) {
return FLUID_FAILED;
}
}
@ -1221,7 +1221,7 @@ delete_fluid_preset_zone(fluid_preset_zone_t* zone)
{
tmp = mod;
mod = mod->next;
fluid_mod_delete (tmp);
delete_fluid_mod (tmp);
}
FLUID_FREE (zone->name);
@ -1272,7 +1272,7 @@ fluid_preset_zone_import_sfont(fluid_preset_zone_t* zone, SFZone *sfzone, fluid_
for (count = 0, r = sfzone->mod; r != NULL; count++) {
SFMod* mod_src = (SFMod *)r->data;
fluid_mod_t * mod_dest = fluid_mod_new();
fluid_mod_t * mod_dest = new_fluid_mod();
int type;
if (mod_dest == NULL){
@ -1613,7 +1613,7 @@ delete_fluid_inst_zone(fluid_inst_zone_t* zone)
{
tmp = mod;
mod = mod->next;
fluid_mod_delete (tmp);
delete_fluid_mod (tmp);
}
FLUID_FREE (zone->name);
@ -1675,7 +1675,7 @@ fluid_inst_zone_import_sfont(fluid_inst_zone_t* zone, SFZone *sfzone, fluid_defs
int type;
fluid_mod_t* mod_dest;
mod_dest = fluid_mod_new();
mod_dest = new_fluid_mod();
if (mod_dest == NULL){
return FLUID_FAILED;
}

View file

@ -256,7 +256,7 @@ delete_fluid_ramsfont (fluid_ramsfont_t* sfont)
/* Check that no samples are currently used */
for (list = sfont->sample; list; list = fluid_list_next(list)) {
fluid_sample_t* sam = (fluid_sample_t*) fluid_list_get(list);
if (fluid_sample_refcount(sam) != 0) {
if (sam->refcount != 0) {
return -1;
}
}

View file

@ -32,6 +32,8 @@
#define delete_fluid_sfont(_sf) ( ((_sf) && (_sf)->free)? (*(_sf)->free)(_sf) : 0)
#define fluid_sfont_get_id(_sf) ((_sf)->id)
#define fluid_sfont_get_name(_sf) (*(_sf)->get_name)(_sf)
#define fluid_sfont_get_preset(_sf,_bank,_prenum) (*(_sf)->get_preset)(_sf,_bank,_prenum)
#define fluid_sfont_iteration_start(_sf) (*(_sf)->iteration_start)(_sf)

View file

@ -33,7 +33,7 @@ typedef struct _fluid_gen_info_t {
float def; /* The default value (cfr. fluid_gen_set_default_values()) */
} fluid_gen_info_t;
/**
/*
* SoundFont generator structure.
*/
typedef struct _fluid_gen_t
@ -44,7 +44,7 @@ typedef struct _fluid_gen_t
double nrpn; /**< Change by NRPN messages */
} fluid_gen_t;
/**
/*
* Enum value for 'flags' field of #fluid_gen_t (not really flags).
*/
enum fluid_gen_flags

View file

@ -383,7 +383,7 @@ fluid_mod_get_value(fluid_mod_t* mod, fluid_channel_t* chan, fluid_voice_t* voic
* @return New allocated modulator or NULL if out of memory
*/
fluid_mod_t*
fluid_mod_new()
new_fluid_mod()
{
fluid_mod_t* mod = FLUID_NEW (fluid_mod_t);
if (mod == NULL) {
@ -398,7 +398,7 @@ fluid_mod_new()
* @param mod Modulator to free
*/
void
fluid_mod_delete (fluid_mod_t *mod)
delete_fluid_mod (fluid_mod_t *mod)
{
FLUID_FREE(mod);
}

View file

@ -24,7 +24,7 @@
#include "fluidsynth_priv.h"
#include "fluid_conv.h"
/**
/*
* Modulator structure. See SoundFont 2.04 PDF section 8.2.
*/
struct _fluid_mod_t

View file

@ -917,7 +917,7 @@ delete_fluid_synth(fluid_synth_t* synth)
while (default_mod != NULL) {
mod = default_mod;
default_mod = mod->next;
fluid_mod_delete(mod);
delete_fluid_mod(mod);
}
FLUID_FREE(synth->overflow.important_channels);
@ -1118,7 +1118,7 @@ fluid_synth_add_default_mod(fluid_synth_t* synth, fluid_mod_t* mod, int mode)
}
/* Add a new modulator (no existing modulator to add / overwrite). */
new_mod = fluid_mod_new();
new_mod = new_fluid_mod();
if (new_mod == NULL)
FLUID_API_RETURN(FLUID_FAILED);
@ -1163,7 +1163,7 @@ fluid_synth_remove_default_mod(fluid_synth_t* synth, const fluid_mod_t* mod)
{
last_mod->next = default_mod->next;
}
fluid_mod_delete(default_mod);
delete_fluid_mod(default_mod);
FLUID_API_RETURN(FLUID_OK);
}
last_mod = default_mod;
@ -3312,8 +3312,7 @@ static void
fluid_synth_kill_by_exclusive_class_LOCAL(fluid_synth_t* synth,
fluid_voice_t* new_voice)
{
int excl_class = _GEN(new_voice,GEN_EXCLUSIVECLASS);
fluid_voice_t* existing_voice;
int excl_class = fluid_voice_gen_value(new_voice, GEN_EXCLUSIVECLASS);
int i;
/* Excl. class 0: No exclusive class */
@ -3321,14 +3320,15 @@ fluid_synth_kill_by_exclusive_class_LOCAL(fluid_synth_t* synth,
/* Kill all notes on the same channel with the same exclusive class */
for (i = 0; i < synth->polyphony; i++) {
existing_voice = synth->voice[i];
fluid_voice_t* existing_voice = synth->voice[i];
int existing_excl_class = fluid_voice_gen_value(existing_voice, GEN_EXCLUSIVECLASS);
/* If voice is playing, on the same channel, has same exclusive
* class and is not part of the same noteon event (voice group), then kill it */
if (fluid_voice_is_playing(existing_voice)
&& fluid_voice_get_channel(existing_voice) == fluid_voice_get_channel(new_voice)
&& (int)_GEN (existing_voice, GEN_EXCLUSIVECLASS) == excl_class
&& existing_excl_class == excl_class
&& fluid_voice_get_id (existing_voice) != fluid_voice_get_id(new_voice))
fluid_voice_kill_excl(existing_voice);
}
@ -3811,63 +3811,6 @@ fluid_synth_get_channel_preset(fluid_synth_t* synth, int chan)
return result;
}
/**
* Get information on the currently selected preset on a MIDI channel.
* @param synth FluidSynth instance
* @param chan MIDI channel number (0 to MIDI channel count - 1)
* @param info Caller supplied structure to fill with preset information
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
* @deprecated Provides redundant functionality that can be achieved with
* fluid_synth_get_channel_preset() or fluid_synth_get_program().
* @since 1.1.1
*/
int
fluid_synth_get_channel_info (fluid_synth_t *synth, int chan,
fluid_synth_channel_info_t *info)
{
fluid_channel_t *channel;
fluid_preset_t *preset;
const char *name;
if (info)
{
info->assigned = FALSE;
info->name[0] = '\0';
}
fluid_return_val_if_fail (info != NULL, FLUID_FAILED);
FLUID_API_ENTRY_CHAN(FLUID_FAILED);
channel = synth->channel[chan];
preset = channel->preset;
if (preset)
{
info->assigned = TRUE;
name = fluid_preset_get_name (preset);
if (name)
{
strncpy (info->name, name, FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE);
info->name[FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE - 1] = '\0';
}
else info->name[0] = '\0';
info->sfont_id = preset->sfont->id;
info->bank = fluid_preset_get_banknum (preset);
info->program = fluid_preset_get_num (preset);
}
else
{
info->assigned = FALSE;
fluid_channel_get_sfont_bank_prog (channel, &info->sfont_id, &info->bank, &info->program);
info->name[0] = '\0';
}
fluid_synth_api_exit(synth);
return FLUID_OK;
}
/**
* Get list of currently playing voices.
* @param synth FluidSynth instance
@ -4561,30 +4504,6 @@ fluid_synth_update_voice_tuning_LOCAL (fluid_synth_t *synth, fluid_channel_t *ch
}
}
/**
* Set the tuning of the entire MIDI note scale.
* @param synth FluidSynth instance
* @param bank Tuning bank number (0-127), not related to MIDI instrument bank
* @param prog Tuning preset number (0-127), not related to MIDI instrument program
* @param name Label name for this tuning
* @param pitch Array of pitch values (length of 128, each value is number of
* cents, for example normally note 0 is 0.0, 1 is 100.0, 60 is 6000.0, etc).
* Pass NULL to create a equal tempered (normal) scale.
* @return FLUID_OK on success, FLUID_FAILED otherwise
*
* @note Tuning is not applied in realtime to existing notes of the replaced
* tuning (if any), use fluid_synth_activate_key_tuning() instead to specify
* this behavior.
*
* @deprecated Use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead.
*/
int
fluid_synth_create_key_tuning(fluid_synth_t* synth, int bank, int prog,
const char* name, const double* pitch)
{
return fluid_synth_activate_key_tuning (synth, bank, prog, name, pitch, FALSE);
}
/**
* Set the tuning of the entire MIDI note scale.
* @param synth FluidSynth instance
@ -4625,30 +4544,6 @@ fluid_synth_activate_key_tuning(fluid_synth_t* synth, int bank, int prog,
FLUID_API_RETURN(retval);
}
/**
* Apply an octave tuning to every octave in the MIDI note scale.
* @param synth FluidSynth instance
* @param bank Tuning bank number (0-127), not related to MIDI instrument bank
* @param prog Tuning preset number (0-127), not related to MIDI instrument program
* @param name Label name for this tuning
* @param pitch Array of pitch values (length of 12 for each note of an octave
* starting at note C, values are number of offset cents to add to the normal
* tuning amount)
* @return FLUID_OK on success, FLUID_FAILED otherwise
*
* @note Tuning is not applied in realtime to existing notes of the replaced
* tuning (if any), use fluid_synth_activate_octave_tuning() instead to specify
* this behavior.
*
* @deprecated Use fluid_synth_activate_octave_tuning(synth, bank, prog, name, pitch, FALSE) instead.
*/
int
fluid_synth_create_octave_tuning(fluid_synth_t* synth, int bank, int prog,
const char* name, const double* pitch)
{
return fluid_synth_activate_octave_tuning (synth, bank, prog, name, pitch, FALSE);
}
/**
* Activate an octave tuning on every octave in the MIDI note scale.
* @param synth FluidSynth instance
@ -4743,30 +4638,6 @@ fluid_synth_tune_notes(fluid_synth_t* synth, int bank, int prog,
FLUID_API_RETURN(retval);
}
/**
* Select a tuning scale on a MIDI channel.
* @param synth FluidSynth instance
* @param chan MIDI channel number (0 to MIDI channel count - 1)
* @param bank Tuning bank number (0-127), not related to MIDI instrument bank
* @param prog Tuning preset number (0-127), not related to MIDI instrument program
* @return FLUID_OK on success, FLUID_FAILED otherwise
*
* @note This function does NOT activate tuning in realtime, use
* fluid_synth_activate_tuning() instead to specify whether tuning change
* should cause existing notes to update.
*
* @note Prior to version 1.1.0 it was an error to select a tuning that didn't
* already exist. Starting with 1.1.0, a default equal tempered scale will be
* created, if no tuning exists for the given bank and prog.
*
* @deprecated Use fluid_synth_activate_tuning(synth, chan, bank, prog, FALSE) instead.
*/
int
fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int bank, int prog)
{
return fluid_synth_activate_tuning (synth, chan, bank, prog, FALSE);
}
/**
* Activate a tuning scale on a MIDI channel.
* @param synth FluidSynth instance
@ -4842,24 +4713,6 @@ fluid_synth_set_tuning_LOCAL (fluid_synth_t *synth, int chan,
return FLUID_OK;
}
/**
* Clear tuning scale on a MIDI channel (set it to the default equal tempered scale).
* @param synth FluidSynth instance
* @param chan MIDI channel number (0 to MIDI channel count - 1)
* @return FLUID_OK on success, FLUID_FAILED otherwise
*
* @note This function does NOT activate tuning change in realtime, use
* fluid_synth_deactivate_tuning() instead to specify whether tuning change
* should cause existing notes to update.
*
* @deprecated Use fluid_synth_deactivate_tuning(synth, chan, FALSE) instead.
*/
int
fluid_synth_reset_tuning(fluid_synth_t* synth, int chan)
{
return fluid_synth_deactivate_tuning (synth, chan, FALSE);
}
/**
* Clear tuning scale on a MIDI channel (use default equal tempered scale).
* @param synth FluidSynth instance
@ -4994,6 +4847,14 @@ fluid_synth_get_settings(fluid_synth_t* synth)
return synth->settings;
}
/**
* Same as calling \c fluid_synth_set_gen2(synth, chan, param, value, FALSE, FALSE)
* @return FLUID_OK on success, FLUID_FAILED otherwise
*/
int fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param, float value)
{
return fluid_synth_set_gen2(synth, chan, param, value, FALSE, FALSE);
}
/**
* Set a SoundFont generator (effect) value on a MIDI channel in real-time.
@ -5006,19 +4867,15 @@ fluid_synth_get_settings(fluid_synth_t* synth)
* TRUE to take the value as a 0.0-1.0 range and apply it to the valid
* generator effect range (scaled and shifted as necessary).
* @return FLUID_OK on success, FLUID_FAILED otherwise
* @since 2.0.0
*
* This function allows for setting all effect parameters in real time on a
* MIDI channel. Setting absolute to non-zero will cause the value to override
* MIDI channel. Setting absolute to non-zero will cause the value to override
* any generator values set in the instruments played on the MIDI channel.
* See SoundFont 2.01 spec, paragraph 8.1.3, page 48 for details on SoundFont
* generator parameters and valid ranges.
*
* @note The old behaviour of fluid_synth_set_gen() assumed \c absolute and \c normalized to
* be FALSE.
*/
int
fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param,
fluid_synth_set_gen2(fluid_synth_t* synth, int chan, int param,
float value, int absolute, int normalized)
{
float v;

View file

@ -74,7 +74,7 @@ enum fluid_synth_status
#define SYNTH_REVERB_CHANNEL 0
#define SYNTH_CHORUS_CHANNEL 1
/**
/*
* Structure used for sfont_info field in #fluid_synth_t for each loaded
* SoundFont with the SoundFont instance and additional fields.
*/

View file

@ -368,7 +368,7 @@ fluid_voice_gen_get(fluid_voice_t* voice, int gen)
return voice->gen[gen].val;
}
fluid_real_t fluid_voice_gen_value(fluid_voice_t* voice, int num)
fluid_real_t fluid_voice_gen_value(const fluid_voice_t* voice, int num)
{
/* This is an extension to the SoundFont standard. More
* documentation is available at the fluid_synth_set_gen2()
@ -420,7 +420,9 @@ void fluid_voice_start(fluid_voice_t* voice)
fluid_voice_calculate_runtime_synthesis_parameters(voice);
#ifdef WITH_PROFILING
voice->ref = fluid_profile_ref();
#endif
voice->status = FLUID_VOICE_ON;
@ -428,6 +430,17 @@ void fluid_voice_start(fluid_voice_t* voice)
voice->channel->synth->active_voice_count++;
}
/**
* Calculate the amplitude of a voice.
*
* @param gain The gain value in the range [0.0 ; 1.0]
* @return An amplitude used by rvoice_mixer's buffers
*/
static fluid_real_t fluid_voice_calculate_gain_amplitude(const fluid_voice_t* voice, fluid_real_t gain)
{
return gain * voice->synth_gain / 32768.0f;
}
void
fluid_voice_calculate_gen_pitch(fluid_voice_t* voice)
{
@ -438,7 +451,7 @@ fluid_voice_calculate_gen_pitch(fluid_voice_t* voice)
* modulator paradigm. Now the nominal pitch of the key is set.
* Note about SCALETUNE: SF2.01 8.1.3 says, that this generator is a
* non-realtime parameter. So we don't allow modulation (as opposed
* to _GEN(voice, GEN_SCALETUNE) When the scale tuning is varied,
* to fluid_voice_gen_value(voice, GEN_SCALETUNE) When the scale tuning is varied,
* one key remains fixed. Here C3 (MIDI number 60) is used.
*/
if (fluid_channel_has_tuning(voice->channel)) {
@ -601,7 +614,7 @@ calculate_hold_decay_buffers(fluid_voice_t* voice, int gen_base,
* will cause (60-72)*100=-1200 timecents of time variation.
* The time is cut in half.
*/
timecents = (_GEN(voice, gen_base) + _GEN(voice, gen_key2base) * (60.0 - fluid_voice_get_actual_key(voice)));
timecents = (fluid_voice_gen_value(voice, gen_base) + fluid_voice_gen_value(voice, gen_key2base) * (60.0 - fluid_voice_get_actual_key(voice)));
/* Range checking */
if (is_decay){
@ -649,7 +662,7 @@ calculate_hold_decay_buffers(fluid_voice_t* voice, int gen_base,
*
* Note: The generator holds three values: The base value .val, an
* offset caused by modulators .mod, and an offset caused by the
* NRPN system. _GEN(voice, generator_enumerator) returns the sum
* NRPN system. fluid_voice_gen_value(voice, generator_enumerator) returns the sum
* of all three.
*/
/**
@ -663,22 +676,24 @@ calculate_hold_decay_buffers(fluid_voice_t* voice, int gen_base,
void
fluid_voice_update_param(fluid_voice_t* voice, int gen)
{
double q_dB;
fluid_real_t x;
fluid_real_t y;
unsigned int count, z;
// Alternate attenuation scale used by EMU10K1 cards when setting the attenuation at the preset or instrument level within the SoundFont bank.
static const float ALT_ATTENUATION_SCALE = 0.4f;
unsigned int count, z;
fluid_real_t q_dB;
fluid_real_t x = fluid_voice_gen_value(voice, gen);
switch (gen) {
case GEN_PAN:
/* range checking is done in the fluid_pan function */
voice->pan = _GEN(voice, GEN_PAN);
voice->amp_left = fluid_pan(voice->pan, 1) * voice->synth_gain / 32768.0f;
voice->amp_right = fluid_pan(voice->pan, 0) * voice->synth_gain / 32768.0f;
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, voice->amp_left);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, voice->amp_right);
voice->pan = x;
/* left amp */
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, fluid_voice_calculate_gain_amplitude(voice, fluid_pan(x, 1)));
/* right amp */
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, fluid_voice_calculate_gain_amplitude(voice, fluid_pan(x, 0)));
break;
case GEN_ATTENUATION:
@ -699,26 +714,24 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
case GEN_COARSETUNE:
case GEN_FINETUNE:
/* The testing for allowed range is done in 'fluid_ct2hz' */
voice->pitch = (_GEN(voice, GEN_PITCH)
+ 100.0f * _GEN(voice, GEN_COARSETUNE)
+ _GEN(voice, GEN_FINETUNE));
voice->pitch = (fluid_voice_gen_value(voice, GEN_PITCH)
+ 100.0f * fluid_voice_gen_value(voice, GEN_COARSETUNE)
+ fluid_voice_gen_value(voice, GEN_FINETUNE));
UPDATE_RVOICE_R1(fluid_rvoice_set_pitch, voice->pitch);
break;
case GEN_REVERBSEND:
/* The generator unit is 'tenths of a percent'. */
voice->reverb_send = _GEN(voice, GEN_REVERBSEND) / 1000.0f;
voice->reverb_send = x / 1000.0f;
fluid_clip(voice->reverb_send, 0.0, 1.0);
voice->amp_reverb = voice->reverb_send * voice->synth_gain / 32768.0f;
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, voice->amp_reverb);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, fluid_voice_calculate_gain_amplitude(voice, voice->reverb_send));
break;
case GEN_CHORUSSEND:
/* The generator unit is 'tenths of a percent'. */
voice->chorus_send = _GEN(voice, GEN_CHORUSSEND) / 1000.0f;
voice->chorus_send = x / 1000.0f;
fluid_clip(voice->chorus_send, 0.0, 1.0);
voice->amp_chorus = voice->chorus_send * voice->synth_gain / 32768.0f;
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, voice->amp_chorus);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, fluid_voice_calculate_gain_amplitude(voice, voice->chorus_send));
break;
case GEN_OVERRIDEROOTKEY:
@ -754,14 +767,13 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
* modulation. The allowed range is tested in the 'fluid_ct2hz'
* function [PH,20021214]
*/
x = _GEN(voice, GEN_FILTERFC);
UPDATE_RVOICE_FILTER1(fluid_iir_filter_set_fres, x);
break;
case GEN_FILTERQ:
/* The generator contains 'centibels' (1/10 dB) => divide by 10 to
* obtain dB */
q_dB = _GEN(voice, GEN_FILTERQ) / 10.0f;
q_dB = x / 10.0f;
/* Range: SF2.01 section 8.1.3 # 8 (convert from cB to dB => /10) */
fluid_clip(q_dB, 0.0f, 96.0f);
@ -787,25 +799,21 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
break;
case GEN_MODLFOTOPITCH:
x = _GEN(voice, GEN_MODLFOTOPITCH);
fluid_clip(x, -12000.0, 12000.0);
UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_pitch, x);
break;
case GEN_MODLFOTOVOL:
x = _GEN(voice, GEN_MODLFOTOVOL);
fluid_clip(x, -960.0, 960.0);
UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_vol, x);
break;
case GEN_MODLFOTOFILTERFC:
x = _GEN(voice, GEN_MODLFOTOFILTERFC);
fluid_clip(x, -12000, 12000);
UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_fc, x);
break;
case GEN_MODLFODELAY:
x = _GEN(voice, GEN_MODLFODELAY);
fluid_clip(x, -12000.0f, 5000.0f);
z = (unsigned int) (voice->output_rate * fluid_tc2sec_delay(x));
UPDATE_RVOICE_ENVLFO_I1(fluid_lfo_set_delay, modlfo, z);
@ -815,7 +823,6 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
/* - the frequency is converted into a delta value, per buffer of FLUID_BUFSIZE samples
* - the delay into a sample delay
*/
x = _GEN(voice, GEN_MODLFOFREQ);
fluid_clip(x, -16000.0f, 4500.0f);
x = (4.0f * FLUID_BUFSIZE * fluid_act2hz(x) / voice->output_rate);
UPDATE_RVOICE_ENVLFO_R1(fluid_lfo_set_incr, modlfo, x);
@ -827,21 +834,18 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
* - the frequency is converted into a delta value, per buffer of FLUID_BUFSIZE samples
* - the delay into a sample delay
*/
x = _GEN(voice, GEN_VIBLFOFREQ);
fluid_clip(x, -16000.0f, 4500.0f);
x = 4.0f * FLUID_BUFSIZE * fluid_act2hz(x) / voice->output_rate;
UPDATE_RVOICE_ENVLFO_R1(fluid_lfo_set_incr, viblfo, x);
break;
case GEN_VIBLFODELAY:
x = _GEN(voice,GEN_VIBLFODELAY);
fluid_clip(x, -12000.0f, 5000.0f);
z = (unsigned int) (voice->output_rate * fluid_tc2sec_delay(x));
UPDATE_RVOICE_ENVLFO_I1(fluid_lfo_set_delay, viblfo, z);
break;
case GEN_VIBLFOTOPITCH:
x = _GEN(voice, GEN_VIBLFOTOPITCH);
fluid_clip(x, -12000.0, 12000.0);
UPDATE_RVOICE_R1(fluid_rvoice_set_viblfo_to_pitch, x);
break;
@ -860,7 +864,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
* never be released on a noteoff event
*/
#if 0
x = _GEN(voice, GEN_KEYNUM);
x = fluid_voice_gen_value(voice, GEN_KEYNUM);
if (x >= 0){
voice->key = x;
}
@ -876,12 +880,12 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
* There is a flag, which should indicate, whether a generator is
* enabled or not. But here we rely on the default value of -1.
*/
/* 2017-09-02: do not change the voice's velocity here, user
/* 2017-09-02: do not change the voice's velocity here, use
* fluid_voice_get_actual_velocity() to get the value of this generator
* if active.
*/
#if 0
x = _GEN(voice, GEN_VELOCITY);
x = fluid_voice_gen_value(voice, GEN_VELOCITY);
if (x > 0) {
voice->vel = x;
}
@ -889,14 +893,11 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
break;
case GEN_MODENVTOPITCH:
x = _GEN(voice, GEN_MODENVTOPITCH);
fluid_clip(x, -12000.0, 12000.0);
UPDATE_RVOICE_R1(fluid_rvoice_set_modenv_to_pitch, x);
break;
case GEN_MODENVTOFILTERFC:
x = _GEN(voice,GEN_MODENVTOFILTERFC);
/* Range: SF2.01 section 8.1.3 # 1
* Motivation for range checking:
* Filter is reported to make funny noises now and then
@ -919,39 +920,47 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
*/
case GEN_STARTADDROFS: /* SF2.01 section 8.1.3 # 0 */
case GEN_STARTADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 4 */
if (voice->sample != NULL) {
z = (voice->sample->start
+ (int) _GEN(voice, GEN_STARTADDROFS)
+ 32768 * (int) _GEN(voice, GEN_STARTADDRCOARSEOFS));
UPDATE_RVOICE_I1(fluid_rvoice_set_start, z);
if (voice->sample != NULL)
{
fluid_real_t start_fine = fluid_voice_gen_value(voice, GEN_STARTADDROFS);
fluid_real_t start_coar = fluid_voice_gen_value(voice, GEN_STARTADDRCOARSEOFS);
z = voice->sample->start + (int)start_fine + 32768 * (int)start_coar;
UPDATE_RVOICE_I1(fluid_rvoice_set_start, z);
}
break;
case GEN_ENDADDROFS: /* SF2.01 section 8.1.3 # 1 */
case GEN_ENDADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 12 */
if (voice->sample != NULL) {
z = (voice->sample->end
+ (int) _GEN(voice, GEN_ENDADDROFS)
+ 32768 * (int) _GEN(voice, GEN_ENDADDRCOARSEOFS));
UPDATE_RVOICE_I1(fluid_rvoice_set_end, z);
if (voice->sample != NULL)
{
fluid_real_t end_fine = fluid_voice_gen_value(voice, GEN_ENDADDROFS);
fluid_real_t end_coar = fluid_voice_gen_value(voice, GEN_ENDADDRCOARSEOFS);
z = voice->sample->end + (int)end_fine + 32768 * (int)end_coar;
UPDATE_RVOICE_I1(fluid_rvoice_set_end, z);
}
break;
case GEN_STARTLOOPADDROFS: /* SF2.01 section 8.1.3 # 2 */
case GEN_STARTLOOPADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 45 */
if (voice->sample != NULL) {
z = (voice->sample->loopstart
+ (int) _GEN(voice, GEN_STARTLOOPADDROFS)
+ 32768 * (int) _GEN(voice, GEN_STARTLOOPADDRCOARSEOFS));
UPDATE_RVOICE_I1(fluid_rvoice_set_loopstart, z);
if (voice->sample != NULL)
{
fluid_real_t lstart_fine = fluid_voice_gen_value(voice, GEN_STARTLOOPADDROFS);
fluid_real_t lstart_coar = fluid_voice_gen_value(voice, GEN_STARTLOOPADDRCOARSEOFS);
z = voice->sample->loopstart + (int)lstart_fine + 32768 * (int)lstart_coar;
UPDATE_RVOICE_I1(fluid_rvoice_set_loopstart, z);
}
break;
case GEN_ENDLOOPADDROFS: /* SF2.01 section 8.1.3 # 3 */
case GEN_ENDLOOPADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 50 */
if (voice->sample != NULL) {
z = (voice->sample->loopend
+ (int) _GEN(voice, GEN_ENDLOOPADDROFS)
+ 32768 * (int) _GEN(voice, GEN_ENDLOOPADDRCOARSEOFS));
UPDATE_RVOICE_I1(fluid_rvoice_set_loopend, z);
if (voice->sample != NULL)
{
fluid_real_t lend_fine = fluid_voice_gen_value(voice, GEN_ENDLOOPADDROFS);
fluid_real_t lend_coar = fluid_voice_gen_value(voice, GEN_ENDLOOPADDRCOARSEOFS);
z = voice->sample->loopend + (int)lend_fine + 32768 * (int)lend_coar;
UPDATE_RVOICE_I1(fluid_rvoice_set_loopend, z);
}
break;
@ -967,7 +976,6 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
* - attack, decay and release are converted to their increment per sample
*/
case GEN_VOLENVDELAY: /* SF2.01 section 8.1.3 # 33 */
x = _GEN(voice, GEN_VOLENVDELAY);
fluid_clip(x, -12000.0f, 5000.0f);
count = NUM_BUFFERS_DELAY(x);
fluid_voice_update_volenv(voice, FLUID_VOICE_ENVDELAY,
@ -975,7 +983,6 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
break;
case GEN_VOLENVATTACK: /* SF2.01 section 8.1.3 # 34 */
x = _GEN(voice, GEN_VOLENVATTACK);
fluid_clip(x, -12000.0f, 8000.0f);
count = 1 + NUM_BUFFERS_ATTACK(x);
fluid_voice_update_volenv(voice, FLUID_VOICE_ENVATTACK,
@ -992,15 +999,14 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
case GEN_VOLENVDECAY: /* SF2.01 section 8.1.3 # 36 */
case GEN_VOLENVSUSTAIN: /* SF2.01 section 8.1.3 # 37 */
case GEN_KEYTOVOLENVDECAY: /* SF2.01 section 8.1.3 # 40 */
y = 1.0f - 0.001f * _GEN(voice, GEN_VOLENVSUSTAIN);
fluid_clip(y, 0.0f, 1.0f);
x = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_VOLENVSUSTAIN);
fluid_clip(x , 0.0f, 1.0f);
count = calculate_hold_decay_buffers(voice, GEN_VOLENVDECAY, GEN_KEYTOVOLENVDECAY, 1); /* 1 for decay */
fluid_voice_update_volenv(voice, FLUID_VOICE_ENVDECAY,
count, 1.0f, count ? -1.0f / count : 0.0f, y, 2.0f);
count, 1.0f, count ? -1.0f / count : 0.0f, x, 2.0f);
break;
case GEN_VOLENVRELEASE: /* SF2.01 section 8.1.3 # 38 */
x = _GEN(voice, GEN_VOLENVRELEASE);
fluid_clip(x, FLUID_MIN_VOLENVRELEASE, 8000.0f);
count = 1 + NUM_BUFFERS_RELEASE(x);
fluid_voice_update_volenv(voice, FLUID_VOICE_ENVRELEASE,
@ -1009,14 +1015,12 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
/* Modulation envelope */
case GEN_MODENVDELAY: /* SF2.01 section 8.1.3 # 25 */
x = _GEN(voice, GEN_MODENVDELAY);
fluid_clip(x, -12000.0f, 5000.0f);
fluid_voice_update_modenv(voice, FLUID_VOICE_ENVDELAY,
NUM_BUFFERS_DELAY(x), 0.0f, 0.0f, -1.0f, 1.0f);
break;
case GEN_MODENVATTACK: /* SF2.01 section 8.1.3 # 26 */
x = _GEN(voice, GEN_MODENVATTACK);
fluid_clip(x, -12000.0f, 8000.0f);
count = 1 + NUM_BUFFERS_ATTACK(x);
fluid_voice_update_modenv(voice, FLUID_VOICE_ENVATTACK,
@ -1034,14 +1038,13 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen)
case GEN_MODENVSUSTAIN: /* SF 2.01 section 8.1.3 # 29 */
case GEN_KEYTOMODENVDECAY: /* SF 2.01 section 8.1.3 # 32 */
count = calculate_hold_decay_buffers(voice, GEN_MODENVDECAY, GEN_KEYTOMODENVDECAY, 1); /* 1 for decay */
y = 1.0f - 0.001f * _GEN(voice, GEN_MODENVSUSTAIN);
fluid_clip(y, 0.0f, 1.0f);
x = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_MODENVSUSTAIN);
fluid_clip(x, 0.0f, 1.0f);
fluid_voice_update_modenv(voice, FLUID_VOICE_ENVDECAY,
count, 1.0f, count ? -1.0f / count : 0.0f, y, 2.0f);
count, 1.0f, count ? -1.0f / count : 0.0f, x, 2.0f);
break;
case GEN_MODENVRELEASE: /* SF 2.01 section 8.1.3 # 30 */
x = _GEN(voice, GEN_MODENVRELEASE);
fluid_clip(x, -12000.0f, 8000.0f);
count = 1 + NUM_BUFFERS_RELEASE(x);
fluid_voice_update_modenv(voice, FLUID_VOICE_ENVRELEASE,
@ -1452,7 +1455,7 @@ int fluid_voice_get_channel(const fluid_voice_t* voice)
*/
int fluid_voice_get_actual_key(const fluid_voice_t* voice)
{
fluid_real_t x = _GEN(voice, GEN_KEYNUM);
fluid_real_t x = fluid_voice_gen_value(voice, GEN_KEYNUM);
if (x >= 0)
{
return (int)x;
@ -1485,7 +1488,7 @@ int fluid_voice_get_key(const fluid_voice_t* voice)
*/
int fluid_voice_get_actual_velocity(const fluid_voice_t* voice)
{
fluid_real_t x = _GEN(voice, GEN_VELOCITY);
fluid_real_t x = fluid_voice_gen_value(voice, GEN_VELOCITY);
if (x > 0)
{
return (int)x;
@ -1589,22 +1592,24 @@ int fluid_voice_set_param(fluid_voice_t* voice, int gen, fluid_real_t nrpn_value
int fluid_voice_set_gain(fluid_voice_t* voice, fluid_real_t gain)
{
fluid_real_t left, right, reverb, chorus;
/* avoid division by zero*/
if (gain < 0.0000001){
gain = 0.0000001;
}
voice->synth_gain = gain;
voice->amp_left = fluid_pan(voice->pan, 1) * gain / 32768.0f;
voice->amp_right = fluid_pan(voice->pan, 0) * gain / 32768.0f;
voice->amp_reverb = voice->reverb_send * gain / 32768.0f;
voice->amp_chorus = voice->chorus_send * gain / 32768.0f;
left = fluid_voice_calculate_gain_amplitude(voice, fluid_pan(voice->pan, 1));
right = fluid_voice_calculate_gain_amplitude(voice, fluid_pan(voice->pan, 0));
reverb = fluid_voice_calculate_gain_amplitude(voice, voice->reverb_send);
chorus = fluid_voice_calculate_gain_amplitude(voice, voice->chorus_send);
UPDATE_RVOICE_R1(fluid_rvoice_set_synth_gain, gain);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, voice->amp_left);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, voice->amp_right);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, voice->amp_reverb);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, voice->amp_chorus);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, left);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, right);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, reverb);
UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, chorus);
return FLUID_OK;
}

View file

@ -33,6 +33,7 @@
#define NO_CHANNEL 0xff
typedef struct _fluid_overflow_prio_t fluid_overflow_prio_t;
struct _fluid_overflow_prio_t
@ -90,16 +91,12 @@ struct _fluid_voice_t
/* pan */
fluid_real_t pan;
fluid_real_t amp_left;
fluid_real_t amp_right;
/* reverb */
fluid_real_t reverb_send;
fluid_real_t amp_reverb;
/* chorus */
fluid_real_t chorus_send;
fluid_real_t amp_chorus;
/* rvoice control */
fluid_rvoice_t* rvoice;
@ -108,8 +105,10 @@ struct _fluid_voice_t
char can_access_overflow_rvoice; /* False if overflow_rvoice is being rendered in separate thread */
char has_noteoff; /* Flag set when noteoff has been sent */
#ifdef WITH_PROFILING
/* for debugging */
double ref;
#endif
};
@ -182,15 +181,9 @@ fluid_voice_unlock_rvoice(fluid_voice_t* voice)
#define _SAMPLEMODE(voice) ((int)(voice)->gen[GEN_SAMPLEMODE].val)
/* FIXME - This doesn't seem to be used anywhere - JG */
fluid_real_t fluid_voice_gen_value(fluid_voice_t* voice, int num);
fluid_real_t fluid_voice_gen_value(const fluid_voice_t* voice, int num);
#define fluid_voice_get_loudness(voice) (fluid_adsr_env_get_max_val(&voice->volenv))
#define _GEN(_voice, _n) \
((fluid_real_t)(_voice)->gen[_n].val \
+ (fluid_real_t)(_voice)->gen[_n].mod \
+ (fluid_real_t)(_voice)->gen[_n].nrpn)
#endif /* _FLUID_VOICE_H */

View file

@ -23,7 +23,7 @@
#include "fluid_sys.h"
/**
/*
* Lockless event queue instance.
*/
struct _fluid_ringbuffer_t

View file

@ -214,6 +214,7 @@ typedef struct _fluid_sample_timer_t fluid_sample_timer_t;
#define FLUID_MAX_EVENT_QUEUES 16 /**< Maximum number of unique threads queuing events */
#define FLUID_DEFAULT_AUDIO_RT_PRIO 60 /**< Default setting for audio.realtime-prio */
#define FLUID_DEFAULT_MIDI_RT_PRIO 50 /**< Default setting for midi.realtime-prio */
#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */
/***************************************************************
*