Merge pull request #288 from FluidSynth/misc-fixes

remove unused code + fix compiler warnings
This commit is contained in:
Tom M 2017-11-24 20:17:41 +01:00 committed by GitHub
commit a1623f673f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 37 additions and 226 deletions

View file

@ -32,6 +32,10 @@ include_directories (
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include
${PTHREADS_INCLUDE_DIR}
)
include_directories (
SYSTEM
${GLIB_INCLUDEDIR}
${GLIB_INCLUDE_DIRS}
)

View file

@ -2182,18 +2182,6 @@ fluid_is_number(char* a)
return TRUE;
}
int
fluid_is_empty(char* a)
{
while (*a != 0) {
if ((*a != ' ') && (*a != '\t') && (*a != '\n') && (*a != '\r')) {
return FALSE;
}
a++;
}
return TRUE;
}
char*
fluid_expand_path(char* path, char* new_path, int len)
{

View file

@ -29,7 +29,6 @@ void fluid_shell_settings(fluid_settings_t* settings);
/** some help functions */
int fluid_is_number(char* a);
int fluid_is_empty(char* a);
char* fluid_expand_path(char* path, char* new_path, int len);
/** the handlers for the command lines */

View file

@ -100,25 +100,6 @@ static int fluid_file_renderer_parse_options (char *filetype, char *format,
static int fluid_file_renderer_find_file_type (char *extension, int *type);
static int fluid_file_renderer_find_valid_format (SF_INFO *info);
#else /* No libsndfile support */
/* File type names. */
static const char * const type_names[] = {
"raw"
};
/* File audio format names. */
static const char * const format_names[] = {
"s16"
};
/* File endian byte order names. */
static const char * const endian_names[] = {
"cpu"
};
#endif

View file

@ -673,7 +673,7 @@ delete_fluid_jack_midi_driver(fluid_midi_driver_t *p)
if (dev->client_ref != NULL)
fluid_jack_client_close (dev->client_ref, dev);
delete_fluid_midi_parser (dev->parser);
delete_fluid_midi_parser (dev->parser);
FLUID_FREE (dev);
}

View file

@ -238,7 +238,7 @@ fluid_midi_file_read_mthd(fluid_midi_file *mf)
mf->type = mthd[9];
mf->ntracks = (unsigned) mthd[11];
mf->ntracks += (unsigned int) (mthd[10]) << 16;
if ((mthd[12]) < 0) {
if ((mthd[12]) & (1 << 7)) {
mf->uses_smpte = 1;
mf->smpte_fps = -mthd[12];
mf->smpte_res = (unsigned) mthd[13];
@ -1093,15 +1093,6 @@ fluid_track_set_name(fluid_track_t *track, char *name)
return FLUID_OK;
}
/*
* fluid_track_get_name
*/
char *
fluid_track_get_name(fluid_track_t *track)
{
return track->name;
}
/*
* fluid_track_get_duration
*/
@ -1117,24 +1108,6 @@ fluid_track_get_duration(fluid_track_t *track)
return time;
}
/*
* fluid_track_count_events
*/
int
fluid_track_count_events(fluid_track_t *track, int *on, int *off)
{
fluid_midi_event_t *evt = track->first;
while (evt != NULL) {
if (evt->type == NOTE_ON) {
(*on)++;
} else if (evt->type == NOTE_OFF) {
(*off)++;
}
evt = evt->next;
}
return FLUID_OK;
}
/*
* fluid_track_add_event
*/
@ -1153,16 +1126,6 @@ fluid_track_add_event(fluid_track_t *track, fluid_midi_event_t *evt)
return FLUID_OK;
}
/*
* fluid_track_first_event
*/
fluid_midi_event_t *
fluid_track_first_event(fluid_track_t *track)
{
track->cur = track->first;
return track->cur;
}
/*
* fluid_track_next_event
*/
@ -1377,28 +1340,6 @@ fluid_player_add_track(fluid_player_t *player, fluid_track_t *track)
}
}
/*
* fluid_player_count_tracks
*/
int
fluid_player_count_tracks(fluid_player_t *player)
{
return player->ntracks;
}
/*
* fluid_player_get_track
*/
fluid_track_t *
fluid_player_get_track(fluid_player_t *player, int i)
{
if ((i >= 0) && (i < MAX_NUMBER_OF_TRACKS)) {
return player->track[i];
} else {
return NULL;
}
}
/**
* Change the MIDI callback function. This is usually set to
* fluid_synth_handle_midi_event, but can optionally be changed

View file

@ -250,9 +250,7 @@ typedef struct _fluid_track_t fluid_track_t;
fluid_track_t* new_fluid_track(int num);
void delete_fluid_track(fluid_track_t* track);
int fluid_track_set_name(fluid_track_t* track, char* name);
char* fluid_track_get_name(fluid_track_t* track);
int fluid_track_add_event(fluid_track_t* track, fluid_midi_event_t* evt);
fluid_midi_event_t* fluid_track_first_event(fluid_track_t* track);
fluid_midi_event_t* fluid_track_next_event(fluid_track_t* track);
int fluid_track_get_duration(fluid_track_t* track);
int fluid_track_reset(fluid_track_t* track);
@ -312,8 +310,6 @@ struct _fluid_player_t {
int fluid_player_add_track(fluid_player_t* player, fluid_track_t* track);
int fluid_player_callback(void* data, unsigned int msec);
int fluid_player_count_tracks(fluid_player_t* player);
fluid_track_t* fluid_player_get_track(fluid_player_t* player, int i);
int fluid_player_reset(fluid_player_t* player);
int fluid_player_load(fluid_player_t* player, fluid_playlist_item *item);

View file

@ -19,49 +19,23 @@
/* Denormalising:
*
* According to music-dsp thread 'Denormalise', Pentium processors
* have a hardware 'feature', that is of interest here, related to
* numeric underflow. We have a recursive filter. The output decays
* exponentially, if the input stops. So the numbers get smaller and
* smaller... At some point, they reach 'denormal' level. This will
* lead to drastic spikes in the CPU load. The effect was reproduced
* with the reverb - sometimes the average load over 10 s doubles!!.
* We have a recursive filter. The output decays exponentially, if the input
* stops. So the numbers get smaller and smaller... At some point, they reach
* 'denormal' level. On some platforms this will lead to drastic spikes in the
* CPU load. This is especially noticable on some older Pentium (especially
* Pentium 3) processors, but even more modern Intel Core processors still show
* reduced performance with denormals. While there are compile-time switches to
* treat denormals as zero for a lot of processors, those are not available or
* effective on all platforms.
*
* The 'undenormalise' macro fixes the problem: As soon as the number
* is close enough to denormal level, the macro forces the number to
* 0.0f. The original macro is:
*
* #define undenormalise(sample) if(((*(unsigned int*)&sample)&0x7f800000)==0) sample=0.0f
*
* This will zero out a number when it reaches the denormal level.
* Advantage: Maximum dynamic range Disadvantage: We'll have to check
* every sample, expensive. The alternative macro comes from a later
* mail from Jon Watte. It will zap a number before it reaches
* denormal level. Jon suggests to run it once per block instead of
* every sample.
* The fix used here: Use a small DC-offset in the filter calculations. Now
* the signals converge not against 0, but against the offset. The constant
* offset is invisible from the outside world (i.e. it does not appear at the
* output. There is a very small turn-on transient response, which should not
* cause problems.
*/
# if defined(WITH_FLOATX)
# define zap_almost_zero(sample) (((*(unsigned int*)&(sample))&0x7f800000) < 0x08000000)?0.0f:(sample)
# else
/* 1e-20 was chosen as an arbitrary (small) threshold. */
#define zap_almost_zero(sample) fabs(sample)<1e-10 ? 0 : sample;
#endif
/* Denormalising part II:
*
* Another method fixes the problem cheaper: Use a small DC-offset in
* the filter calculations. Now the signals converge not against 0,
* but against the offset. The constant offset is invisible from the
* outside world (i.e. it does not appear at the output. There is a
* very small turn-on transient response, which should not cause
* problems.
*/
//#define DC_OFFSET 0
#define DC_OFFSET 1e-8
//#define DC_OFFSET 0.001f
typedef struct _fluid_allpass fluid_allpass;
typedef struct _fluid_comb fluid_comb;
@ -126,20 +100,6 @@ fluid_allpass_getfeedback(fluid_allpass* allpass)
_input = output; \
}
/* fluid_real_t fluid_allpass_process(fluid_allpass* allpass, fluid_real_t input) */
/* { */
/* fluid_real_t output; */
/* fluid_real_t bufout; */
/* bufout = allpass->buffer[allpass->bufidx]; */
/* undenormalise(bufout); */
/* output = -input + bufout; */
/* allpass->buffer[allpass->bufidx] = input + (bufout * allpass->feedback); */
/* if (++allpass->bufidx >= allpass->bufsize) { */
/* allpass->bufidx = 0; */
/* } */
/* return output; */
/* } */
struct _fluid_comb {
fluid_real_t feedback;
fluid_real_t filterstore;
@ -220,22 +180,6 @@ fluid_comb_getfeedback(fluid_comb* comb)
_output += _tmp; \
}
/* fluid_real_t fluid_comb_process(fluid_comb* comb, fluid_real_t input) */
/* { */
/* fluid_real_t output; */
/* output = comb->buffer[comb->bufidx]; */
/* undenormalise(output); */
/* comb->filterstore = (output * comb->damp2) + (comb->filterstore * comb->damp1); */
/* undenormalise(comb->filterstore); */
/* comb->buffer[comb->bufidx] = input + (comb->filterstore * comb->feedback); */
/* if (++comb->bufidx >= comb->bufsize) { */
/* comb->bufidx = 0; */
/* } */
/* return output; */
/* } */
#define numcombs 8
#define numallpasses 4
#define fixedgain 0.015f

View file

@ -530,7 +530,7 @@ new_fluid_rvoice_mixer(int buf_count, int fx_buf_count, fluid_real_t sample_rate
/* allocate the reverb module */
mixer->fx.reverb = new_fluid_revmodel(sample_rate);
mixer->fx.chorus = new_fluid_chorus(sample_rate);
if (mixer->fx.reverb == NULL) {
if (mixer->fx.reverb == NULL || mixer->fx.chorus == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
delete_fluid_rvoice_mixer(mixer);
return NULL;

View file

@ -865,7 +865,7 @@ delete_fluid_synth(fluid_synth_t* synth)
for (i = 0; i < synth->midi_channels; i++)
fluid_channel_set_preset(synth->channel[i], NULL);
delete_fluid_rvoice_eventhandler(synth->eventhandler);
delete_fluid_rvoice_eventhandler(synth->eventhandler);
/* delete all the SoundFonts */
for (list = synth->sfont_info; list; list = fluid_list_next (list)) {

View file

@ -34,11 +34,11 @@ fluid_tuning_t* new_fluid_tuning(const char* name, int bank, int prog)
FLUID_LOG(FLUID_PANIC, "Out of memory");
return NULL;
}
FLUID_MEMSET(tuning, 0, sizeof(fluid_tuning_t));
tuning->name = NULL;
if (name != NULL) {
tuning->name = FLUID_STRDUP(name);
if (fluid_tuning_set_name(tuning, name) != FLUID_OK) {
delete_fluid_tuning(tuning);
return NULL;
}
tuning->bank = bank;
@ -66,19 +66,12 @@ fluid_tuning_duplicate (fluid_tuning_t *tuning)
FLUID_LOG (FLUID_PANIC, "Out of memory");
return NULL;
}
FLUID_MEMSET(new_tuning, 0, sizeof(fluid_tuning_t));
if (tuning->name)
{
new_tuning->name = FLUID_STRDUP (tuning->name);
if (!new_tuning->name)
{
FLUID_FREE (new_tuning);
FLUID_LOG (FLUID_PANIC, "Out of memory");
return NULL;
}
if (fluid_tuning_set_name(new_tuning, tuning->name) != FLUID_OK) {
delete_fluid_tuning(new_tuning);
return NULL;
}
else new_tuning->name = NULL;
new_tuning->bank = tuning->bank;
new_tuning->prog = tuning->prog;
@ -129,7 +122,7 @@ fluid_tuning_unref (fluid_tuning_t *tuning, int count)
else return FALSE;
}
void fluid_tuning_set_name(fluid_tuning_t* tuning, char* name)
int fluid_tuning_set_name(fluid_tuning_t* tuning, const char* name)
{
if (tuning->name != NULL) {
FLUID_FREE(tuning->name);
@ -137,7 +130,12 @@ void fluid_tuning_set_name(fluid_tuning_t* tuning, char* name)
}
if (name != NULL) {
tuning->name = FLUID_STRDUP(name);
if (tuning->name == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
return FLUID_FAILED;
}
}
return FLUID_OK;
}
char* fluid_tuning_get_name(fluid_tuning_t* tuning)
@ -145,11 +143,6 @@ char* fluid_tuning_get_name(fluid_tuning_t* tuning)
return tuning->name;
}
void fluid_tuning_set_key(fluid_tuning_t* tuning, int key, double pitch)
{
tuning->pitch[key] = pitch;
}
void fluid_tuning_set_octave(fluid_tuning_t* tuning, const double* pitch_deriv)
{
int i;

View file

@ -48,7 +48,7 @@ fluid_tuning_t *fluid_tuning_duplicate (fluid_tuning_t *tuning);
void fluid_tuning_ref (fluid_tuning_t *tuning);
int fluid_tuning_unref (fluid_tuning_t *tuning, int count);
void fluid_tuning_set_name(fluid_tuning_t* tuning, char* name);
int fluid_tuning_set_name(fluid_tuning_t* tuning, const char* name);
char* fluid_tuning_get_name(fluid_tuning_t* tuning);
#define fluid_tuning_get_bank(_t) ((_t)->bank)

View file

@ -409,38 +409,6 @@ fluid_voice_write (fluid_voice_t* voice, fluid_real_t *dsp_buf)
return result;
}
/**
* Mix voice data to left/right (panning), reverb and chorus buffers.
* @param count Number of samples
* @param dsp_buf Source buffer
* @param voice Voice to mix
* @param left_buf Left audio buffer
* @param right_buf Right audio buffer
* @param reverb_buf Reverb buffer
* @param chorus_buf Chorus buffer
*
*/
void
fluid_voice_mix (fluid_voice_t *voice, int count, fluid_real_t* dsp_buf,
fluid_real_t* left_buf, fluid_real_t* right_buf,
fluid_real_t* reverb_buf, fluid_real_t* chorus_buf)
{
fluid_rvoice_buffers_t buffers;
fluid_real_t* dest_buf[4] = {left_buf, right_buf, reverb_buf, chorus_buf};
fluid_rvoice_buffers_set_amp(&buffers, 0, voice->amp_left);
fluid_rvoice_buffers_set_amp(&buffers, 1, voice->amp_right);
fluid_rvoice_buffers_set_amp(&buffers, 2, voice->amp_reverb);
fluid_rvoice_buffers_set_amp(&buffers, 3, voice->amp_chorus);
fluid_rvoice_buffers_mix(&buffers, dsp_buf, count, dest_buf, 4);
fluid_check_fpe ("voice_mix");
}
/*
* fluid_voice_start
*/

View file

@ -146,9 +146,6 @@ int fluid_voice_noteoff(fluid_voice_t* voice);
void fluid_voice_off(fluid_voice_t* voice);
void fluid_voice_stop(fluid_voice_t* voice);
void fluid_voice_overflow_rvoice_finished(fluid_voice_t* voice);
void fluid_voice_mix (fluid_voice_t *voice, int count, fluid_real_t* dsp_buf,
fluid_real_t* left_buf, fluid_real_t* right_buf,
fluid_real_t* reverb_buf, fluid_real_t* chorus_buf);
int fluid_voice_kill_excl(fluid_voice_t* voice);
fluid_real_t fluid_voice_get_overflow_prio(fluid_voice_t* voice,