mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-22 20:01:04 +00:00
move fluid_rvoice_buffers_mix() to rvoice_mixer
This commit is contained in:
parent
907ec27a9e
commit
f2cf1f82c7
3 changed files with 53 additions and 58 deletions
|
@ -404,60 +404,6 @@ fluid_rvoice_write (fluid_rvoice_t* voice, fluid_real_t *dsp_buf)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FLUID_INLINE fluid_real_t*
|
|
||||||
get_dest_buf(fluid_rvoice_buffers_t* buffers, int index,
|
|
||||||
fluid_real_t** dest_bufs, int dest_bufcount)
|
|
||||||
{
|
|
||||||
int j = buffers->bufs[index].mapping;
|
|
||||||
if (j >= dest_bufcount || j < 0) return NULL;
|
|
||||||
return dest_bufs[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mix data down to buffers
|
|
||||||
*
|
|
||||||
* @param buffers Destination buffer(s)
|
|
||||||
* @param dsp_buf Mono sample source
|
|
||||||
* @param samplecount Number of samples to process (no FLUID_BUFSIZE restriction)
|
|
||||||
* @param dest_bufs Array of buffers to mixdown to
|
|
||||||
* @param dest_bufcount Length of dest_bufs
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t* buffers,
|
|
||||||
fluid_real_t* dsp_buf, int start, int samplecount,
|
|
||||||
fluid_real_t** dest_bufs, int dest_bufcount)
|
|
||||||
{
|
|
||||||
int bufcount = buffers->count;
|
|
||||||
int i, dsp_i;
|
|
||||||
if (!samplecount || !bufcount || !dest_bufcount)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i=0; i < bufcount; i++) {
|
|
||||||
fluid_real_t* buf = get_dest_buf(buffers, i, dest_bufs, dest_bufcount);
|
|
||||||
fluid_real_t* next_buf;
|
|
||||||
fluid_real_t amp = buffers->bufs[i].amp;
|
|
||||||
if (buf == NULL || amp == 0.0f)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Optimization for centered stereo samples - we can save one
|
|
||||||
multiplication per sample */
|
|
||||||
next_buf = (i+1 >= bufcount ? NULL : get_dest_buf(buffers, i+1, dest_bufs, dest_bufcount));
|
|
||||||
if (next_buf && buffers->bufs[i+1].amp == amp) {
|
|
||||||
for (dsp_i = start; dsp_i < samplecount; dsp_i++) {
|
|
||||||
fluid_real_t samp = amp * dsp_buf[dsp_i];
|
|
||||||
buf[dsp_i] += samp;
|
|
||||||
next_buf[dsp_i] += samp;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (dsp_i = start; dsp_i < samplecount; dsp_i++)
|
|
||||||
buf[dsp_i] += amp * dsp_buf[dsp_i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize buffers up to (and including) bufnum
|
* Initialize buffers up to (and including) bufnum
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -164,10 +164,6 @@ struct _fluid_rvoice_t
|
||||||
|
|
||||||
int fluid_rvoice_write(fluid_rvoice_t* voice, fluid_real_t *dsp_buf);
|
int fluid_rvoice_write(fluid_rvoice_t* voice, fluid_real_t *dsp_buf);
|
||||||
|
|
||||||
void fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t* buffers,
|
|
||||||
fluid_real_t* dsp_buf, int start, int samplecount,
|
|
||||||
fluid_real_t** dest_bufs, int dest_bufcount);
|
|
||||||
|
|
||||||
DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_buffers_set_amp);
|
DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_buffers_set_amp);
|
||||||
DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_buffers_set_mapping);
|
DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_buffers_set_mapping);
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,59 @@ static FLUID_INLINE void fluid_rvoice_mixer_process_finished_voices(fluid_rvoice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static FLUID_INLINE fluid_real_t*
|
||||||
|
get_dest_buf(fluid_rvoice_buffers_t* buffers, int index,
|
||||||
|
fluid_real_t** dest_bufs, int dest_bufcount)
|
||||||
|
{
|
||||||
|
int j = buffers->bufs[index].mapping;
|
||||||
|
if (j >= dest_bufcount || j < 0) return NULL;
|
||||||
|
return dest_bufs[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mix data down to buffers
|
||||||
|
*
|
||||||
|
* @param buffers Destination buffer(s)
|
||||||
|
* @param dsp_buf Mono sample source
|
||||||
|
* @param samplecount Number of samples to process (no FLUID_BUFSIZE restriction)
|
||||||
|
* @param dest_bufs Array of buffers to mixdown to
|
||||||
|
* @param dest_bufcount Length of dest_bufs
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t* buffers,
|
||||||
|
fluid_real_t* dsp_buf, int start, int samplecount,
|
||||||
|
fluid_real_t** dest_bufs, int dest_bufcount)
|
||||||
|
{
|
||||||
|
int bufcount = buffers->count;
|
||||||
|
int i, dsp_i;
|
||||||
|
if (!samplecount || !bufcount || !dest_bufcount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i=0; i < bufcount; i++) {
|
||||||
|
fluid_real_t* buf = get_dest_buf(buffers, i, dest_bufs, dest_bufcount);
|
||||||
|
fluid_real_t* next_buf;
|
||||||
|
fluid_real_t amp = buffers->bufs[i].amp;
|
||||||
|
if (buf == NULL || amp == 0.0f)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Optimization for centered stereo samples - we can save one
|
||||||
|
multiplication per sample */
|
||||||
|
next_buf = (i+1 >= bufcount ? NULL : get_dest_buf(buffers, i+1, dest_bufs, dest_bufcount));
|
||||||
|
if (next_buf && buffers->bufs[i+1].amp == amp) {
|
||||||
|
for (dsp_i = start; dsp_i < samplecount; dsp_i++) {
|
||||||
|
fluid_real_t samp = amp * dsp_buf[dsp_i];
|
||||||
|
buf[dsp_i] += samp;
|
||||||
|
next_buf[dsp_i] += samp;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (dsp_i = start; dsp_i < samplecount; dsp_i++)
|
||||||
|
buf[dsp_i] += amp * dsp_buf[dsp_i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synthesize one voice and add to buffer.
|
* Synthesize one voice and add to buffer.
|
||||||
* NOTE: If return value is less than blockcount*FLUID_BUFSIZE, that means
|
* NOTE: If return value is less than blockcount*FLUID_BUFSIZE, that means
|
||||||
|
|
Loading…
Reference in a new issue