mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 23:11:41 +00:00
Rounded samples do not need to be float.
Actually, the function roundi() already returns an "int" type value, so in my opinion there is no need to use a floating point value for saturating the values in the range -32768/+32767. The generated assembly code looks more efficient after that.
This commit is contained in:
parent
7517c17524
commit
d8890038b6
1 changed files with 22 additions and 26 deletions
|
@ -3851,8 +3851,8 @@ fluid_synth_write_s16(fluid_synth_t *synth, int len,
|
||||||
signed short *right_out = (signed short *) rout;
|
signed short *right_out = (signed short *) rout;
|
||||||
fluid_real_t *left_in;
|
fluid_real_t *left_in;
|
||||||
fluid_real_t *right_in;
|
fluid_real_t *right_in;
|
||||||
fluid_real_t left_sample;
|
int left_sample;
|
||||||
fluid_real_t right_sample;
|
int right_sample;
|
||||||
double time = fluid_utime();
|
double time = fluid_utime();
|
||||||
int di;
|
int di;
|
||||||
float cpu_load;
|
float cpu_load;
|
||||||
|
@ -3880,32 +3880,30 @@ fluid_synth_write_s16(fluid_synth_t *synth, int len,
|
||||||
left_sample = roundi(left_in[0 * FLUID_BUFSIZE * FLUID_MIXER_MAX_BUFFERS_DEFAULT + cur] * 32766.0f + rand_table[0][di]);
|
left_sample = roundi(left_in[0 * FLUID_BUFSIZE * FLUID_MIXER_MAX_BUFFERS_DEFAULT + cur] * 32766.0f + rand_table[0][di]);
|
||||||
right_sample = roundi(right_in[0 * FLUID_BUFSIZE * FLUID_MIXER_MAX_BUFFERS_DEFAULT + cur] * 32766.0f + rand_table[1][di]);
|
right_sample = roundi(right_in[0 * FLUID_BUFSIZE * FLUID_MIXER_MAX_BUFFERS_DEFAULT + cur] * 32766.0f + rand_table[1][di]);
|
||||||
|
|
||||||
di++;
|
if(++di >= DITHER_SIZE)
|
||||||
|
|
||||||
if(di >= DITHER_SIZE)
|
|
||||||
{
|
{
|
||||||
di = 0;
|
di = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* digital clipping */
|
/* digital clipping */
|
||||||
if(left_sample > 32767.0f)
|
if(left_sample > 32767)
|
||||||
{
|
{
|
||||||
left_sample = 32767.0f;
|
left_sample = 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(left_sample < -32768.0f)
|
if(left_sample < -32768)
|
||||||
{
|
{
|
||||||
left_sample = -32768.0f;
|
left_sample = -32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(right_sample > 32767.0f)
|
if(right_sample > 32767)
|
||||||
{
|
{
|
||||||
right_sample = 32767.0f;
|
right_sample = 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(right_sample < -32768.0f)
|
if(right_sample < -32768)
|
||||||
{
|
{
|
||||||
right_sample = -32768.0f;
|
right_sample = -32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
left_out[j] = (signed short) left_sample;
|
left_out[j] = (signed short) left_sample;
|
||||||
|
@ -3950,8 +3948,8 @@ fluid_synth_dither_s16(int *dither_index, int len, float *lin, float *rin,
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
signed short *left_out = (signed short *) lout;
|
signed short *left_out = (signed short *) lout;
|
||||||
signed short *right_out = (signed short *) rout;
|
signed short *right_out = (signed short *) rout;
|
||||||
fluid_real_t left_sample;
|
int left_sample;
|
||||||
fluid_real_t right_sample;
|
int right_sample;
|
||||||
int di = *dither_index;
|
int di = *dither_index;
|
||||||
fluid_profile_ref_var(prof_ref);
|
fluid_profile_ref_var(prof_ref);
|
||||||
|
|
||||||
|
@ -3961,32 +3959,30 @@ fluid_synth_dither_s16(int *dither_index, int len, float *lin, float *rin,
|
||||||
left_sample = roundi(lin[i] * 32766.0f + rand_table[0][di]);
|
left_sample = roundi(lin[i] * 32766.0f + rand_table[0][di]);
|
||||||
right_sample = roundi(rin[i] * 32766.0f + rand_table[1][di]);
|
right_sample = roundi(rin[i] * 32766.0f + rand_table[1][di]);
|
||||||
|
|
||||||
di++;
|
if(++di >= DITHER_SIZE)
|
||||||
|
|
||||||
if(di >= DITHER_SIZE)
|
|
||||||
{
|
{
|
||||||
di = 0;
|
di = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* digital clipping */
|
/* digital clipping */
|
||||||
if(left_sample > 32767.0f)
|
if(left_sample > 32767)
|
||||||
{
|
{
|
||||||
left_sample = 32767.0f;
|
left_sample = 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(left_sample < -32768.0f)
|
if(left_sample < -32768)
|
||||||
{
|
{
|
||||||
left_sample = -32768.0f;
|
left_sample = -32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(right_sample > 32767.0f)
|
if(right_sample > 32767)
|
||||||
{
|
{
|
||||||
right_sample = 32767.0f;
|
right_sample = 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(right_sample < -32768.0f)
|
if(right_sample < -32768)
|
||||||
{
|
{
|
||||||
right_sample = -32768.0f;
|
right_sample = -32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
left_out[j] = (signed short) left_sample;
|
left_out[j] = (signed short) left_sample;
|
||||||
|
|
Loading…
Reference in a new issue