Hi all, A while ago, we received the following bug report on Fedora for qsynth: https://bugzilla.redhat.com/show_bug.cgi?id=1399896
Basically, qsynth calls fluid_is_soundfont() with a filename, and if the call returns 1, qsynth believes the file is a soundfont and it saves the filename in its config. If the file starts with the RIFF header but is not a soundfont file (e.g. wav, avi, ... file), qsynth fails to load the file. But since the config is already written, qsynth fails on subsequent starts. The workaround is to remove the qsynth config file. I began with working on the qsynth side to fix this problem. But it occured to me, this should best be handled on the fluidsynth side by making the fluid_is_soundfont() function a little smarter. In the attached patch, the function not only checks for the RIFF header, but also checks for the sfbk header between bytes 8-11. "sfbk" is in the soundfont specification. e.g. http://www.vgmpf.com/Wiki/index.php/SF2 Please feel free to take the patch or the idea. Best regards, Orcan Ogetbil
diff -rupN fluidsynth-1.1.9.org/src/utils/fluid_sys.c fluidsynth-1.1.9/src/utils/fluid_sys.c --- fluidsynth-1.1.9.org/src/utils/fluid_sys.c 2018-01-02 10:14:56.000000000 -0500 +++ fluidsynth-1.1.9/src/utils/fluid_sys.c 2018-01-06 14:54:26.602393220 -0500 @@ -342,14 +342,16 @@ fluid_is_midifile(const char *filename) * @param filename Path to the file to check * @return TRUE if it could be a SoundFont, FALSE otherwise * - * The current implementation only checks for the "RIFF" header in the file. - * It is useful only to distinguish between SoundFont and MIDI files. + * The current implementation only checks for the "RIFF" and *sfbk* headers in + * the file. + * It is useful to distinguish between SoundFont and other (e.g. MIDI) files. */ int fluid_is_soundfont(const char *filename) { FILE* fp = fopen(filename, "rb"); char id[4]; + int rval = 0; if (fp == NULL) { return 0; @@ -358,9 +360,14 @@ fluid_is_soundfont(const char *filename) fclose(fp); return 0; } - fclose(fp); - return strncmp(id, "RIFF", 4) == 0; + if (strncmp(id, "RIFF", 4) == 0) + if (fseek(fp, 8, SEEK_SET) == 0) + if (fread((void*) id, 1, 4, fp) == 4) + if (strncmp(id, "sfbk", 4) == 0) + rval = 1; + fclose(fp); + return rval; } /**
_______________________________________________ fluid-dev mailing list fluid-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/fluid-dev