Sample rate update

This commit is contained in:
David Henningsson 2010-07-14 08:46:03 +00:00
parent 5225b46b5d
commit 94e5844b60
4 changed files with 22 additions and 1 deletions

View file

@ -404,7 +404,7 @@ new_fluid_jack_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func
fluid_settings_getnum (settings, "synth.sample-rate", &sample_rate);
if ((int)sample_rate != jack_srate) {
FLUID_LOG(FLUID_WARN, "Jack sample rate mismatch, adjusting."
FLUID_LOG(FLUID_INFO, "Jack sample rate mismatch, adjusting."
" (synth.sample-rate=%lu, jackd=%lu)", (int)sample_rate, jack_srate);
fluid_settings_setnum (settings, "synth.sample-rate", jack_srate);
}

View file

@ -2613,6 +2613,8 @@ fluid_synth_set_sample_rate(fluid_synth_t* synth, float sample_rate)
fluid_settings_getint(synth->settings, "synth.min-note-length", &i);
synth->min_note_length_ticks = (unsigned int) (i*synth->sample_rate/1000.0f);
for (i=0; i < synth->polyphony; i++)
fluid_voice_set_output_rate(synth->voice[i], sample_rate);
fluid_synth_update_mixer(synth, fluid_rvoice_mixer_set_samplerate,
0, sample_rate);
fluid_synth_api_exit(synth);

View file

@ -226,6 +226,23 @@ fluid_voice_init(fluid_voice_t* voice, fluid_sample_t* sample,
return FLUID_OK;
}
/**
* Update sample rate.
* NOTE: If the voice is active, it will be turned off.
*/
int
fluid_voice_set_output_rate(fluid_voice_t* voice, fluid_real_t value)
{
if (_PLAYING(voice))
fluid_voice_off(voice);
voice->output_rate = value;
UPDATE_RVOICE_R1(fluid_rvoice_set_output_rate, value);
return FLUID_FAILED;
}
/**
* Set the value of a generator.
* @param voice Voice instance

View file

@ -119,6 +119,8 @@ int fluid_voice_set_param(fluid_voice_t* voice, int gen, fluid_real_t value, int
/** Set the gain. */
int fluid_voice_set_gain(fluid_voice_t* voice, fluid_real_t gain);
int fluid_voice_set_output_rate(fluid_voice_t* voice, fluid_real_t value);
/** Update all the synthesis parameters, which depend on generator
'gen'. This is only necessary after changing a generator of an