Skip to content

Commit c56b36f

Browse files
committed
implement porta time scale hack
1 parent 3806c6d commit c56b36f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/synth/fluid_voice.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,11 +1277,17 @@ void fluid_voice_update_portamento(fluid_voice_t *voice, int fromkey, int tokey)
12771277
fluid_real_t PitchBeg = fluid_voice_calculate_pitch(voice, fromkey);
12781278
fluid_real_t PitchEnd = fluid_voice_calculate_pitch(voice, tokey);
12791279
fluid_real_t pitchoffset = PitchBeg - PitchEnd;
1280+
unsigned int countinc;
1281+
enum fluid_portamento_time_mode tm = channel->synth->portamento_time_mode;
12801282

12811283
/* Calculates increment countinc */
12821284
/* Increment is function of PortamentoTime (ms)*/
1283-
fluid_real_t ms = fluid_channel_portamentotime_with_mode(channel, channel->synth->portamento_time_mode, channel->synth->portamento_time_has_seen_lsb);
1284-
unsigned int countinc = (unsigned int)(((fluid_real_t)voice->output_rate * 0.001f * ms) /
1285+
fluid_real_t ms = fluid_channel_portamentotime_with_mode(channel, tm, channel->synth->portamento_time_has_seen_lsb);
1286+
// Apply a similar scaling hack as SpessaSynth to fix Descent Game08, it's unclear why exactly. Supposably the portamento time applies to two octaves pitch glide.
1287+
// https://github.com/spessasus/spessasynth_core/blob/0b2d44f48065d3d6bbca24a1d40223b1255dab00/src/synthesizer/audio_engine/engine_methods/portamento_time.ts#L84-L86
1288+
ms *= (tm == FLUID_PORTAMENTO_TIME_MODE_XG_GS) ? (abs(tokey - fromkey) / 24.0f) : 1.0f;
1289+
1290+
countinc = (unsigned int)(((fluid_real_t)voice->output_rate * 0.001f * ms) /
12851291
(fluid_real_t)FLUID_BUFSIZE + 0.5f);
12861292

12871293
/* Send portamento parameters to the voice dsp */

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ add_custom_target(renderHybridCol
179179

180180
add_custom_target(renderPortamento
181181
COMMAND fluidsynth -R 0 -C 0 -g 0.6 -F "${PORTAMENTO_RENDER_DIR}/1TOWOW_reduced_to_A3_C4.${FEXT}" "1TOWOW_reduced_to_A3_C4.mid" ${GENERAL_USER_GS2}
182+
COMMAND fluidsynth -o "synth.portamento-time=linear" -R 0 -C 0 -g 0.6 -F "${PORTAMENTO_RENDER_DIR}/1TOWOW_reduced_to_A3_C4_linear.${FEXT}" "1TOWOW_reduced_to_A3_C4.mid" ${GENERAL_USER_GS2}
182183
COMMAND fluidsynth -R 0 -C 0 -g 0.7 -F "${PORTAMENTO_RENDER_DIR}/1TOWOW.${FEXT}" "1TOWOW.MID" ${GENERAL_USER_GS2}
183184
COMMAND fluidsynth -R 0 -C 0 -g 0.7 -F "${PORTAMENTO_RENDER_DIR}/3 - Turn Up, Strut In, Chill Out (XG).${FEXT}" "3 - Turn Up, Strut In, Chill Out (XG).mid" ${GENERAL_USER_GS2}
184185
COMMAND fluidsynth -R 0 -C 0 -g 0.7 -F "${PORTAMENTO_RENDER_DIR}/6 - Galactic Invasion (XG).${FEXT}" "6 - Galactic Invasion (XG).mid" ${GENERAL_USER_GS2}
185186
COMMAND fluidsynth -R 0 -C 0 -g 0.5 -F "${PORTAMENTO_RENDER_DIR}/Descent_Game08.${FEXT}" "Descent_Game08.mid" ${GENERAL_USER_GS2}
187+
COMMAND fluidsynth -o "synth.portamento-time=linear" -R 0 -C 0 -g 0.5 -F "${PORTAMENTO_RENDER_DIR}/Descent_Game08_linear.${FEXT}" "Descent_Game08.mid" ${GENERAL_USER_GS2}
186188
COMMAND fluidsynth -R 0 -C 0 -g 0.6 -F "${PORTAMENTO_RENDER_DIR}/MM6_-_MrX2010XG.${FEXT}" ${GENERAL_USER_GS2} "MM6_-_MrX2010XG.mid"
187189
COMMENT "Rendering Portamento tests"
188190
DEPENDS fluidsynth create_iir_dir

0 commit comments

Comments
 (0)