1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7     See the AUTHORS file for more details.
8 
9     This program is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License as
11     published by the Free Software Foundation; either version 2 of the
12     License, or (at your option) any later version.  See the file
13     COPYING included with this distribution for more information.
14 */
15 
16 #ifndef RG_SF2_PATCH_EXTRACTOR_H
17 #define RG_SF2_PATCH_EXTRACTOR_H
18 
19 #include <string>
20 #include <map>
21 
22 namespace Rosegarden {
23 
24 /**
25  * Trivial class to suck the patch map out of a .sf2 SoundFont file.
26  * Inspired by (but not based on) sftovkb by Takashi Iwai.
27  *
28  * SoundFont is a straightforward RIFF format so there's some
29  * redundancy between this and RIFFAudioFile -- we don't take any
30  * advantage of that, and this class is completely self-contained.
31  *
32  * Tolerates garbled files; will just suck all it can rather than
33  * throw an error, except if the file is not a SoundFont at all.
34  */
35 
36 class SF2PatchExtractor
37 {
38 public:
39     typedef std::map<int, std::string> Bank;
40     typedef std::map<int, Bank> Device;
41 
42     struct FileNotFoundException { };
43     struct WrongFileFormatException { };
44 
45     static bool isSF2File(std::string fileName);
46     static Device read(std::string fileName);
47 };
48 
49 }
50 
51 #endif
52 
53