mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-01 00:21:14 +00:00
remove fluid_rvoice_dsp_t::is_looping flag
and pass it to interpolate functions directly and reorder flags
This commit is contained in:
parent
b95266cf6c
commit
0b64c8d887
3 changed files with 25 additions and 40 deletions
|
@ -272,7 +272,7 @@ int
|
|||
fluid_rvoice_write (fluid_rvoice_t* voice, fluid_real_t *dsp_buf)
|
||||
{
|
||||
int ticks = voice->envlfo.ticks;
|
||||
int count;
|
||||
int count, is_looping;
|
||||
|
||||
/******************* sample sanity check **********/
|
||||
|
||||
|
@ -358,7 +358,8 @@ fluid_rvoice_write (fluid_rvoice_t* voice, fluid_real_t *dsp_buf)
|
|||
/* if phase_incr is not advancing, set it to the minimum fraction value (prevent stuckage) */
|
||||
if (voice->dsp.phase_incr == 0) voice->dsp.phase_incr = 1;
|
||||
|
||||
voice->dsp.is_looping = voice->dsp.samplemode == FLUID_LOOP_DURING_RELEASE
|
||||
/* voice is currently looping? */
|
||||
is_looping = voice->dsp.samplemode == FLUID_LOOP_DURING_RELEASE
|
||||
|| (voice->dsp.samplemode == FLUID_LOOP_UNTIL_RELEASE
|
||||
&& fluid_adsr_env_get_section(&voice->envlfo.volenv) < FLUID_VOICE_ENVRELEASE);
|
||||
|
||||
|
@ -371,17 +372,17 @@ fluid_rvoice_write (fluid_rvoice_t* voice, fluid_real_t *dsp_buf)
|
|||
switch (voice->dsp.interp_method)
|
||||
{
|
||||
case FLUID_INTERP_NONE:
|
||||
count = fluid_rvoice_dsp_interpolate_none (&voice->dsp, dsp_buf);
|
||||
count = fluid_rvoice_dsp_interpolate_none (&voice->dsp, dsp_buf, is_looping);
|
||||
break;
|
||||
case FLUID_INTERP_LINEAR:
|
||||
count = fluid_rvoice_dsp_interpolate_linear (&voice->dsp, dsp_buf);
|
||||
count = fluid_rvoice_dsp_interpolate_linear (&voice->dsp, dsp_buf, is_looping);
|
||||
break;
|
||||
case FLUID_INTERP_4THORDER:
|
||||
default:
|
||||
count = fluid_rvoice_dsp_interpolate_4th_order (&voice->dsp, dsp_buf);
|
||||
count = fluid_rvoice_dsp_interpolate_4th_order (&voice->dsp, dsp_buf, is_looping);
|
||||
break;
|
||||
case FLUID_INTERP_7THORDER:
|
||||
count = fluid_rvoice_dsp_interpolate_7th_order (&voice->dsp, dsp_buf);
|
||||
count = fluid_rvoice_dsp_interpolate_7th_order (&voice->dsp, dsp_buf, is_looping);
|
||||
break;
|
||||
}
|
||||
fluid_check_fpe ("voice_write interpolation");
|
||||
|
|
|
@ -84,17 +84,22 @@ struct _fluid_rvoice_envlfo_t
|
|||
struct _fluid_rvoice_dsp_t
|
||||
{
|
||||
/* interpolation method, as in fluid_interp in fluidsynth.h */
|
||||
int interp_method;
|
||||
enum fluid_interp interp_method;
|
||||
enum fluid_loop samplemode;
|
||||
|
||||
/* Flag that is set as soon as the first loop is completed. */
|
||||
char has_looped;
|
||||
|
||||
/* Flag that initiates, that sample-related parameters have to be checked. */
|
||||
char check_sample_sanity_flag;
|
||||
|
||||
fluid_sample_t* sample;
|
||||
int check_sample_sanity_flag; /* Flag that initiates, that sample-related parameters
|
||||
have to be checked. */
|
||||
|
||||
/* sample and loop start and end points (offset in sample memory). */
|
||||
int start;
|
||||
int end;
|
||||
int loopstart;
|
||||
int loopend; /* Note: first point following the loop (superimposed on loopstart) */
|
||||
enum fluid_loop samplemode;
|
||||
|
||||
/* Stuff needed for portamento calculations */
|
||||
fluid_real_t pitchoffset; /* the portamento range in midicents */
|
||||
|
@ -108,7 +113,6 @@ struct _fluid_rvoice_dsp_t
|
|||
|
||||
/* Stuff needed for amplitude calculations */
|
||||
|
||||
int has_looped; /* Flag that is set as soon as the first loop is completed. */
|
||||
fluid_real_t attenuation; /* the attenuation in centibels */
|
||||
fluid_real_t prev_attenuation; /* the previous attenuation in centibels
|
||||
used by fluid_rvoice_multi_retrigger_attack() */
|
||||
|
@ -118,17 +122,13 @@ struct _fluid_rvoice_dsp_t
|
|||
fluid_real_t amplitude_that_reaches_noise_floor_loop;
|
||||
fluid_real_t synth_gain; /* master gain */
|
||||
|
||||
|
||||
/* Dynamic input to the interpolator below */
|
||||
|
||||
|
||||
fluid_real_t amp; /* current linear amplitude */
|
||||
fluid_real_t amp_incr; /* amplitude increment value for the next FLUID_BUFSIZE samples */
|
||||
|
||||
fluid_phase_t phase; /* the phase (current sample offset) of the sample wave */
|
||||
fluid_real_t phase_incr; /* the phase increment for the next FLUID_BUFSIZE samples */
|
||||
int is_looping;
|
||||
|
||||
};
|
||||
|
||||
/* Currently left, right, reverb, chorus. To be changed if we
|
||||
|
@ -193,10 +193,10 @@ DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_set_sample);
|
|||
|
||||
/* defined in fluid_rvoice_dsp.c */
|
||||
void fluid_rvoice_dsp_config (void);
|
||||
int fluid_rvoice_dsp_interpolate_none (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf);
|
||||
int fluid_rvoice_dsp_interpolate_linear (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf);
|
||||
int fluid_rvoice_dsp_interpolate_4th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf);
|
||||
int fluid_rvoice_dsp_interpolate_7th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf);
|
||||
int fluid_rvoice_dsp_interpolate_none (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int is_looping);
|
||||
int fluid_rvoice_dsp_interpolate_linear (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int is_looping);
|
||||
int fluid_rvoice_dsp_interpolate_4th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int is_looping);
|
||||
int fluid_rvoice_dsp_interpolate_7th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int is_looping);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -130,7 +130,7 @@ fluid_rvoice_get_float_sample(const short int* dsp_msb, const char* dsp_lsb, uns
|
|||
* the playback pointer. Questionable quality, but very
|
||||
* efficient. */
|
||||
int
|
||||
fluid_rvoice_dsp_interpolate_none (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf)
|
||||
fluid_rvoice_dsp_interpolate_none (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int looping)
|
||||
{
|
||||
fluid_phase_t dsp_phase = voice->phase;
|
||||
fluid_phase_t dsp_phase_incr;
|
||||
|
@ -141,14 +141,10 @@ fluid_rvoice_dsp_interpolate_none (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUI
|
|||
unsigned int dsp_i = 0;
|
||||
unsigned int dsp_phase_index;
|
||||
unsigned int end_index;
|
||||
int looping;
|
||||
|
||||
/* Convert playback "speed" floating point value to phase index/fract */
|
||||
fluid_phase_set_float (dsp_phase_incr, voice->phase_incr);
|
||||
|
||||
/* voice is currently looping? */
|
||||
looping = voice->is_looping;
|
||||
|
||||
end_index = looping ? voice->loopend - 1 : voice->end;
|
||||
|
||||
while (1)
|
||||
|
@ -191,7 +187,7 @@ fluid_rvoice_dsp_interpolate_none (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUI
|
|||
* smaller if end of sample occurs).
|
||||
*/
|
||||
int
|
||||
fluid_rvoice_dsp_interpolate_linear (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf)
|
||||
fluid_rvoice_dsp_interpolate_linear (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int looping)
|
||||
{
|
||||
fluid_phase_t dsp_phase = voice->phase;
|
||||
fluid_phase_t dsp_phase_incr;
|
||||
|
@ -204,14 +200,10 @@ fluid_rvoice_dsp_interpolate_linear (fluid_rvoice_dsp_t *voice, fluid_real_t *FL
|
|||
unsigned int end_index;
|
||||
fluid_real_t point;
|
||||
const fluid_real_t *FLUID_RESTRICT coeffs;
|
||||
int looping;
|
||||
|
||||
/* Convert playback "speed" floating point value to phase index/fract */
|
||||
fluid_phase_set_float (dsp_phase_incr, voice->phase_incr);
|
||||
|
||||
/* voice is currently looping? */
|
||||
looping = voice->is_looping;
|
||||
|
||||
/* last index before 2nd interpolation point must be specially handled */
|
||||
end_index = (looping ? voice->loopend - 1 : voice->end) - 1;
|
||||
|
||||
|
@ -280,7 +272,7 @@ fluid_rvoice_dsp_interpolate_linear (fluid_rvoice_dsp_t *voice, fluid_real_t *FL
|
|||
* smaller if end of sample occurs).
|
||||
*/
|
||||
int
|
||||
fluid_rvoice_dsp_interpolate_4th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf)
|
||||
fluid_rvoice_dsp_interpolate_4th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int looping)
|
||||
{
|
||||
fluid_phase_t dsp_phase = voice->phase;
|
||||
fluid_phase_t dsp_phase_incr;
|
||||
|
@ -293,14 +285,10 @@ fluid_rvoice_dsp_interpolate_4th_order (fluid_rvoice_dsp_t *voice, fluid_real_t
|
|||
unsigned int start_index, end_index;
|
||||
fluid_real_t start_point, end_point1, end_point2;
|
||||
const fluid_real_t *FLUID_RESTRICT coeffs;
|
||||
int looping;
|
||||
|
||||
/* Convert playback "speed" floating point value to phase index/fract */
|
||||
fluid_phase_set_float (dsp_phase_incr, voice->phase_incr);
|
||||
|
||||
/* voice is currently looping? */
|
||||
looping = voice->is_looping;
|
||||
|
||||
/* last index before 4th interpolation point must be specially handled */
|
||||
end_index = (looping ? voice->loopend - 1 : voice->end) - 2;
|
||||
|
||||
|
@ -434,7 +422,7 @@ fluid_rvoice_dsp_interpolate_4th_order (fluid_rvoice_dsp_t *voice, fluid_real_t
|
|||
* smaller if end of sample occurs).
|
||||
*/
|
||||
int
|
||||
fluid_rvoice_dsp_interpolate_7th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf)
|
||||
fluid_rvoice_dsp_interpolate_7th_order (fluid_rvoice_dsp_t *voice, fluid_real_t *FLUID_RESTRICT dsp_buf, int looping)
|
||||
{
|
||||
fluid_phase_t dsp_phase = voice->phase;
|
||||
fluid_phase_t dsp_phase_incr;
|
||||
|
@ -447,7 +435,6 @@ fluid_rvoice_dsp_interpolate_7th_order (fluid_rvoice_dsp_t *voice, fluid_real_t
|
|||
unsigned int start_index, end_index;
|
||||
fluid_real_t start_points[3], end_points[3];
|
||||
const fluid_real_t *FLUID_RESTRICT coeffs;
|
||||
int looping;
|
||||
|
||||
/* Convert playback "speed" floating point value to phase index/fract */
|
||||
fluid_phase_set_float (dsp_phase_incr, voice->phase_incr);
|
||||
|
@ -456,9 +443,6 @@ fluid_rvoice_dsp_interpolate_7th_order (fluid_rvoice_dsp_t *voice, fluid_real_t
|
|||
* the 4th sample point */
|
||||
fluid_phase_incr (dsp_phase, (fluid_phase_t)0x80000000);
|
||||
|
||||
/* voice is currently looping? */
|
||||
looping = voice->is_looping;
|
||||
|
||||
/* last index before 7th interpolation point must be specially handled */
|
||||
end_index = (looping ? voice->loopend - 1 : voice->end) - 3;
|
||||
|
||||
|
|
Loading…
Reference in a new issue