Hi! Can you give me an example on how to use the "fluid_synth_write_s16" function? #1493
-
Well, I'm wanting to write an application that renders midi, preferable interleaved stereo to uncompressed PCM raw data, or simply wave data. I just need an example in C/C++. Thanks. :-) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
fluidsynth/src/drivers/fluid_sdl2.c Lines 45 to 52 in 724b8c8 Where |
Beta Was this translation helpful? Give feedback.
-
And Mr. @derselbst I will try that code and I will see what I can do. By the way, it's not my first time here: I already asked for this subject: "Please add a 'fluid_player_get_total_time' and 'fluid_player_get_current_time' functions in milliseconds and pause/resume functions too." #1151. It would be so simple to implement this but I managed to do in my Fluidsynyh player already mentioned above. Thanks for the replies! Cheers! :-) |
Beta Was this translation helpful? Give feedback.
-
Hey guys! I solved here! :-D But not with "fluid_synth_write_s16" function, I'm using "fluid_synth_write_float" now and it works now. BASS supports float samples with the BASS_SAMPLE_FLOAT flag. https://www.un4seen.com/doc/#bass/BASS_StreamCreate.html Looks like the library "libfluidsynth-3.dll" was compiled with libsndfile support and even there is another DLL called sndfile.dll in the main Fluidsynth distribution. Well, I checked the source code of Fluidsynth to get an example of how to use the function, especially the file "fluid_filerenderer.c" found in "src/bindings" and I noticed the file renderer, the function "fluid_file_renderer_process_block" uses "fluid_synth_write_float" instead of "fluid_synth_write_s16" due a conditional compiler directive callled "LIBSNDFILE_SUPPORT". Anyway, thanks for the replies and I think you can close this subject as it's solved. See ya! ;-) |
Beta Was this translation helpful? Give feedback.
So you want to do something like this: https://www.fluidsynth.org/api/FileRenderer.html
But instead of
fluid_file_renderer_process_block(renderer)
you would callfluid_synth_write_s16()
. And yes, the rendering buffer is an array of 16 bit signed integers. That's why the rendering function is called s16 ;)The length of that buffer is up to you. But using a multiple of
fluid_synth_get_internal_bufsize()
will work most efficient.