Fixed silent-and-disappearing note problem. Thanks to Gerald Pye.

This commit is contained in:
Peter Hanappe 2004-08-06 09:56:24 +00:00
parent 3aed63534d
commit 3142b270d7
8 changed files with 60 additions and 42 deletions

View File

@ -7,7 +7,7 @@ AC_INIT(src/fluidsynth.c)
FLUIDSYNTH_VERSION_MAJOR=1
FLUIDSYNTH_VERSION_MINOR=0
FLUIDSYNTH_VERSION_MICRO=4
FLUIDSYNTH_VERSION_PL=1
FLUIDSYNTH_VERSION_PL=2
FLUIDSYNTH_VERSION=$FLUIDSYNTH_VERSION_MAJOR.$FLUIDSYNTH_VERSION_MINOR.$FLUIDSYNTH_VERSION_MICRO-$FLUIDSYNTH_VERSION_PL
AC_SUBST(FLUIDSYNTH_VERSION_MAJOR)

View File

@ -79,36 +79,39 @@ FLUIDSYNTH_API fluid_settings_t* fluid_synth_get_settings(fluid_synth_t* synth);
*
*/
/** Send a noteon message */
/** Send a noteon message. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_noteon(fluid_synth_t* synth, int chan, int key, int vel);
/** Send a noteoff message */
/** Send a noteoff message. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_noteoff(fluid_synth_t* synth, int chan, int key);
/** Send a control change message */
/** Send a control change message. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_cc(fluid_synth_t* synth, int chan, int ctrl, int val);
/** Get a control value */
/** Get a control value. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_get_cc(fluid_synth_t* synth, int chan, int ctrl, int* pval);
/** Send a pitch bend message */
/** Send a pitch bend message. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_pitch_bend(fluid_synth_t* synth, int chan, int val);
/** Get the pitch bend value */
/** Get the pitch bend value. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API
int fluid_synth_get_pitch_bend(fluid_synth_t* synth, int chan, int* ppitch_bend);
/** Set the pitch wheel sensitivity */
/** Set the pitch wheel sensitivity. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_pitch_wheel_sens(fluid_synth_t* synth, int chan, int val);
/** Send a program change message */
/** Get the pitch wheel sensitivity. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_get_pitch_wheel_sens(fluid_synth_t* synth, int chan, int* pval);
/** Send a program change message. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_program_change(fluid_synth_t* synth, int chan, int program);
/** Select a bank */
/** Select a bank. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API
int fluid_synth_bank_select(fluid_synth_t* synth, int chan, unsigned int bank);
/** Select a sfont */
/** Select a sfont. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API
int fluid_synth_sfont_select(fluid_synth_t* synth, int chan, unsigned int sfont_id);
@ -131,7 +134,7 @@ int fluid_synth_program_select(fluid_synth_t* synth, int chan,
unsigned int preset_num);
/** Returns the program, bank, and SoundFont number of the preset on
a given channel. */
a given channel. Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API
int fluid_synth_get_program(fluid_synth_t* synth, int chan,
unsigned int* sfont_id,
@ -141,7 +144,7 @@ int fluid_synth_get_program(fluid_synth_t* synth, int chan,
/** Send a bank select and a program change to every channel to
* reinitialize the preset of the channel. This function is useful
* mainly after a SoundFont has been loaded, unloaded or
* reloaded. */
* reloaded. . Returns 0 if no error occurred, -1 otherwise. */
FLUIDSYNTH_API int fluid_synth_program_reset(fluid_synth_t* synth);
/** Send a reset. A reset turns all the notes off and resets the

View File

@ -195,7 +195,15 @@ fluid_channel_cc(fluid_channel_t* chan, int num, int value)
{
chan->bank_msb = (unsigned char) (value & 0x7f);
/* printf("** bank select msb recieved: %d\n", value); */
/* FIXME: is this correct? */
/* I fixed the handling of a MIDI bank select controller 0,
e.g., bank select MSB (or "coarse" bank select according to
my spec). Prior to this fix a channel's bank number was only
changed upon reception of MIDI bank select controller 32,
e.g, bank select LSB (or "fine" bank-select according to my
spec). [KLE]
FIXME: is this correct? [PH] */
fluid_channel_set_banknum(chan, (unsigned int)(value & 0x7f)); /* KLE */
}
break;

View File

@ -154,11 +154,18 @@ fluid_tc2sec_delay(fluid_real_t tc)
{
/* SF2.01 section 8.1.2 items 21, 23, 25, 33
* SF2.01 section 8.1.3 items 21, 23, 25, 33
* The most negative number indicates a delay of 0
* Range is limited from -12000 to 5000 */
if (tc<=-32768.){return (fluid_real_t) 0.0;};
if (tc<-12000.){tc=(fluid_real_t) -12000.0;};
if (tc>12000.){tc=(fluid_real_t) 12000.0;};
*
* The most negative number indicates a delay of 0. Range is limited
* from -12000 to 5000 */
if (tc <= -32768.0f) {
return (fluid_real_t) 0.0f;
};
if (tc < -12000.) {
tc = (fluid_real_t) -12000.0f;
}
if (tc > 5000.0f) {
tc = (fluid_real_t) 5000.0f;
}
return (fluid_real_t) pow(2.0, (double) tc / 1200.0);
}

View File

@ -45,7 +45,7 @@ struct _fluid_hashnode_t {
fluid_hashnode_t *next;
};
static fluid_hashnode_t* new_fluid_hashnode(char* key, void* value, int type);
static fluid_hashnode_t* new_fluid_hashnode(char* key, void* value, int type);
static void delete_fluid_hashnode(fluid_hashnode_t *hash_node, fluid_hash_delete_t del);
static void delete_fluid_hashnodes(fluid_hashnode_t *hash_node, fluid_hash_delete_t del);

View File

@ -45,8 +45,6 @@ int fluid_synth_program_select2(fluid_synth_t* synth,
fluid_sfont_t* fluid_synth_get_sfont_by_name(fluid_synth_t* synth, char *name);
int fluid_synth_get_pitch_wheel_sens(fluid_synth_t* synth, int chan, int* pval);
int fluid_synth_set_gen2(fluid_synth_t* synth, int chan,
int param, float value,
int absolute, int normalized);
@ -747,6 +745,10 @@ fluid_synth_noteon(fluid_synth_t* synth, int chan, int key, int vel)
return FLUID_FAILED;
}
/* If there is another voice process on the same channel and key,
advance it to the release phase. */
fluid_synth_release_voice_on_same_note(synth, chan, key);
return fluid_synth_start(synth, synth->noteid++, channel->preset, 0, chan, key, vel);
}
@ -1024,7 +1026,7 @@ fluid_synth_get_pitch_bend(fluid_synth_t* synth, int chan, int* ppitch_bend)
}
/*
* fluid_synth_pitch_wheel_sens
* Fluid_synth_pitch_wheel_sens
*/
int
fluid_synth_pitch_wheel_sens(fluid_synth_t* synth, int chan, int val)
@ -1928,10 +1930,6 @@ fluid_synth_alloc_voice(fluid_synth_t* synth, fluid_sample_t* sample, int chan,
/* fluid_mutex_lock(synth->busy); /\* Don't interfere with the audio thread *\/ */
/* fluid_mutex_unlock(synth->busy); */
/* If there is another voice process on the same channel and key,
advance it to the release phase. */
fluid_synth_release_voice_on_same_note(synth, chan, key);
/* check if there's an available synthesis process */
for (i = 0; i < synth->nvoice; i++) {
if (_AVAILABLE(synth->voice[i])) {

View File

@ -208,6 +208,7 @@ fluid_voice_init(fluid_voice_t* voice, fluid_sample_t* sample,
* the 'working memory' of the voice (position in envelopes, history
* of IIR filters, position in sample etc) is initialized. */
voice->id = id;
voice->chan = fluid_channel_get_num(channel);
voice->key = (unsigned char) key;
@ -1641,6 +1642,7 @@ fluid_voice_noteoff(fluid_voice_t* voice)
voice->modenv_section = FLUID_VOICE_ENVRELEASE;
voice->modenv_count = 0;
}
return FLUID_OK;
}

View File

@ -478,13 +478,13 @@ int main(int argc, char** argv)
/* create the synthesizer */
synth = new_fluid_synth(settings);
if (synth == NULL) {
printf("Failed to create the synthesizer\n");
fprintf(stderr, "Failed to create the synthesizer\n");
exit(-1);
}
cmd_handler = new_fluid_cmd_handler(synth);
if (cmd_handler == NULL) {
printf("Failed to create the command handler\n");
fprintf(stderr, "Failed to create the command handler\n");
goto cleanup;
}
@ -501,7 +501,7 @@ int main(int argc, char** argv)
for (i = arg1; i < argc; i++) {
if ((argv[i][0] != '-') && fluid_is_soundfont(argv[i])) {
if (fluid_synth_sfload(synth, argv[i], 1) == -1) {
printf("Failed to load the SoundFont %s\n", argv[i]);
fprintf(stderr, "Failed to load the SoundFont %s\n", argv[i]);
}
}
}
@ -513,7 +513,7 @@ int main(int argc, char** argv)
/* start the synthesis thread */
adriver = new_fluid_audio_driver(settings, synth);
if (adriver == NULL) {
printf("Failed to create the audio driver\n");
fprintf(stderr, "Failed to create the audio driver\n");
goto cleanup;
}
@ -531,9 +531,9 @@ int main(int argc, char** argv)
(void*)synth);
if (router == NULL) {
printf("Failed to create the MIDI input router; no MIDI input\n"
"will be available. You can access the synthesizer \n"
"through the console.\n");
fprintf(stderr, "Failed to create the MIDI input router; no MIDI input\n"
"will be available. You can access the synthesizer \n"
"through the console.\n");
} else {
fluid_synth_set_midi_router(synth, router); /* Fixme, needed for command handler */
mdriver = new_fluid_midi_driver(
@ -541,9 +541,9 @@ int main(int argc, char** argv)
dump ? fluid_midi_dump_prerouter : fluid_midi_router_handle_midi_event,
(void*) router);
if (mdriver == NULL) {
printf("Failed to create the MIDI thread; no MIDI input\n"
"will be available. You can access the synthesizer \n"
"through the console.\n");
fprintf(stderr, "Failed to create the MIDI thread; no MIDI input\n"
"will be available. You can access the synthesizer \n"
"through the console.\n");
}
}
}
@ -556,8 +556,8 @@ int main(int argc, char** argv)
if (player == NULL) {
player = new_fluid_player(synth);
if (player == NULL) {
printf("Failed to create the midifile player.\n"
"Continuing without a player.\n");
fprintf(stderr, "Failed to create the midifile player.\n"
"Continuing without a player.\n");
break;
}
}
@ -575,7 +575,7 @@ int main(int argc, char** argv)
if (with_server) {
server = new_fluid_server(settings, newclient, synth);
if (server == NULL) {
printf("Failed to create the server.\n"
fprintf(stderr, "Failed to create the server.\n"
"Continuing without it.\n");
}
}
@ -663,8 +663,8 @@ static fluid_cmd_handler_t* newclient(void* data, char* addr)
void
print_usage()
{
printf("Usage: %s [options] [soundfonts]\n", appname);
printf("Try -h for help.\n");
fprintf(stderr, "Usage: %s [options] [soundfonts]\n", appname);
fprintf(stderr, "Try -h for help.\n");
exit(0);
}