Add SoundFonts’ names and licences (and score copyright) to waveform file metadata
In order to fulfil the requirements of the MIT licence for our standard soundfont, as well as the requests of the soundfont creators, I propose the following:
For all soundfonts, collect the INAM and ICOP chunks (SF2/SF3; someone should look how this is dealt with in SFZ). Then, create a metadata string like this (pseudocode; might also need to convert from some foreign text encoding to Unicode):
… heh. We could even add the copyright from the score! Changed pseudocode to include it:
String sfmeta = rtrim(score->meta->copyright, "\n");
foreach (sountfont in soundfonts_used_in_playback) {
sfmeta += "\n\nMade using the soundfont " + soundfont.INAM + ":\n\n";
foreach (line in '\n'.split(soundfont.ICOP)) {
sfmeta += "| " + line + "\n";
}
}
Then, embed sfmeta
into the resulting waveform files:
- WAV: perhaps an INFO chunk with an ICOP chunk inside, containing this (might need to convert to some foreign text encoding)
- MP3: perhaps an ID3v2 tag (at the end of file, not at the beginning, as this breaks some MP3 players) with it (ID3v2.4 uses Unicode for encoding TTBOMK)
- OGG Vorbis, FLAC: no idea, but they will likely support metadata as well
Samuel Gossner from Versilian Studios indicated that soundfont providers wish to find music others did using their soundfonts, and that e.g. a keyword search on Soundcloud would help them to find that. Perhaps this metadata would show up there. In any way, it will massively help users in automatically fulfilling most attribution requirements.
Comments
The ICOP chunk is limited to 255 ASCII bytes (plus a NUL byte for padding), so we’d need to put the full licence info into the ICMT chunk (which, according to SF2 format version 2.04, has 65535 bytes available); I also don’t feel as bad putting UTF-8 into ICMT and keeping ICOP to pure ASCII.
For example, I’d patch the standard soundfont (2.315) as packaged in Debian like this:
CHUNK b'ICOP'(124): b'Copyright (c) Frank Wen, Michael Cowgill, and others; see ICMT chunk or Debian fluidr3mono-gm-soundfont for entire licence\x00\x00'
CHUNK b'IENG'(32): b'Mono version by Church Organist\x00'
CHUNK b'ICMT'(1848): b'Fluid (R3) Mono GM SoundFont\n\nOriginal Stereo version (Fluid (R3) SoundFont)\nCopyright \xc2\xa9 2000-2002, 2008 Frank Wen \nInclusion into Debian derivatives \xc2\xa9 2008 Toby Smithe\nDebian packaging \xc2\xa9 2018 Thorsten Glaser \n\nTemple Blocks instrument Copyright \xc2\xa9 2002 Ethan Winer\nDrumline Percussion Copyright \xc2\xa9 2016 Michael Schorsch\n\nMono version Copyright \xc2\xa9 2014-17 Michael Cowgill\n\nFluid was constructed in part from samples found in the public\ndomain that I [Frank Wen] edited/cleaned/remixed/programmed and\nlargely from recordings of my own and in conjunction with the\npeople below who helped along the way: Suren M. Seron,\nScott Hanan, Steve Aupperle, Chris Gillman, Alex Taubr,\nChris Prola, Andrew Klenk, Winfried Hubbe, Dylan, Tim, Gort,\nUros Katic, Ethan Winer (http://www.ethanwiner.com)\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the "Software"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\x00\x00'
I’ve actually just written a Python3 script (ouch…) that patches a RIFF file like this.
With a soundfont annotated like this, only the ICMT chunk is needed (ICOP and IENG are just partial summaries, ICMT contains the entire information). However, external/third-party soundfonts might not do that, or not have an ICMT chunk at all, so all three might be relevant.
Incidentally, I have started on this and have some code already, but it’s nowhere near complete. Just wanted to update the status here in case anyone sees this.
I solved this differently for now, because it turns out it is massively too hard to get the actual soundfonts used during playback or waveform conversion, as they are loaded with MIDI CCs and pretty much on-demand, and I think it would incur massive performance overhead. (Too bad, I already had correct (and that wasn’t trivial, let me tell you) ID3 tag writing code.)
What I do now is:
python3 riffedit.py -i /usr/share/sounds/sf3/MuseScore_General.sf3
to dump the metadata of the soundfont in a format easily converted to XML by the conversion shell script (format is{tag} \xFE {tag-content} \xFF
, tag is something likeICOP
and tag-content is the content taken from the file, in a somewhat sensible encoding (converted to UTF-8 if it wasn’t, and characters not valid in XML removed)function do_soundfont
in the conversion script) for each soundfont (in case they differ for MuseScore 2 vs. 3)xmlstarlet
, look forfunction cvtf2meta
) — allmetaTag
tags,programVersion
, the filename — and add that with a list of all formats I export to and the aforementioned soundfont metadata to an XML fileThe XML files are hugely beta. I plan to eventually make a little brother of musescore.com with in-browser playback, but I’m not good with JavaScript. They currently look like this:
This format is subject to change, of course. For example, I’m not entirely sure I’m happy with the
export
tags, and I’m pretty certain there will be changes to it. Also, no DTD ☺ but something like this will be usable with AJAX, for example…