From d519d9328568167c484102cc24384de5aafb51db Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 5 Nov 2014 13:10:51 +0100 Subject: [PATCH] file renderer: Add encoding quality API Based on a patch by willem179@users.sf.net. Signed-off-by: David Henningsson --- fluidsynth/include/fluidsynth/audio.h | 1 + fluidsynth/src/bindings/fluid_filerenderer.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/fluidsynth/include/fluidsynth/audio.h b/fluidsynth/include/fluidsynth/audio.h index 014daf43..bf024d03 100644 --- a/fluidsynth/include/fluidsynth/audio.h +++ b/fluidsynth/include/fluidsynth/audio.h @@ -67,6 +67,7 @@ FLUIDSYNTH_API void delete_fluid_audio_driver(fluid_audio_driver_t* driver); FLUIDSYNTH_API fluid_file_renderer_t *new_fluid_file_renderer(fluid_synth_t* synth); FLUIDSYNTH_API int fluid_file_renderer_process_block(fluid_file_renderer_t* dev); FLUIDSYNTH_API void delete_fluid_file_renderer(fluid_file_renderer_t* dev); +FLUIDSYNTH_API int fluid_file_set_encoding_quality(fluid_file_renderer_t* dev, double q); #ifdef __cplusplus } diff --git a/fluidsynth/src/bindings/fluid_filerenderer.c b/fluidsynth/src/bindings/fluid_filerenderer.c index 2dc56c97..d65fcba7 100644 --- a/fluidsynth/src/bindings/fluid_filerenderer.c +++ b/fluidsynth/src/bindings/fluid_filerenderer.c @@ -290,6 +290,7 @@ new_fluid_file_renderer(fluid_synth_t* synth) /* Turn on clipping and normalization of floats (-1.0 - 1.0) */ sf_command (dev->sndfile, SFC_SET_CLIPPING, NULL, SF_TRUE); sf_command (dev->sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE); + #else dev->file = fopen(filename, "wb"); if (dev->file == NULL) { @@ -306,6 +307,22 @@ new_fluid_file_renderer(fluid_synth_t* synth) return NULL; } +/** + * Set vbr encoding quality (only available with libsndfile support) + * @param dev File renderer object. + * @since 1.1.7 + */ +int +fluid_file_set_encoding_quality(fluid_file_renderer_t* r, double q) +{ +#if LIBSNDFILE_SUPPORT + if (sf_command (r->sndfile, SFC_SET_VBR_ENCODING_QUALITY, &q, sizeof (double)) == 0) + return FLUID_OK; + else +#endif + return FLUID_FAILED; +} + /** * Close file and destroy a file renderer object. * @param dev File renderer object.