修訂 | 882190d2af7d53ad58a7ea18a38cfa3572064dee (tree) |
---|---|
時間 | 2018-10-17 21:51:13 |
作者 | Starg <starg@user...> |
Commiter | Starg |
[sfviewer] Fix cfg output to write "%dls" for dls instruments
@@ -27,8 +27,8 @@ void sfgui_str_free(void **p) | ||
27 | 27 | #include <shlwapi.h> |
28 | 28 | #include "resource.h" |
29 | 29 | |
30 | -void InsertInst(int bank, int preset, const char *str, const char *sfname); | |
31 | -void InsertDrum(int bank, int preset, int note, const char *str, const char *sfname); | |
30 | +void InsertInst(BOOL dls, int bank, int preset, const char *str, const char *sfname); | |
31 | +void InsertDrum(BOOL dls, int bank, int preset, int note, const char *str, const char *sfname); | |
32 | 32 | |
33 | 33 | BOOL IsDLSFile(LPCSTR filename) |
34 | 34 | { |
@@ -145,7 +145,7 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_) | ||
145 | 145 | tv.item.iSelectedImage = 3; |
146 | 146 | TreeView_InsertItem(hTree, &tv); |
147 | 147 | |
148 | - InsertInst(b->bank, p->program, p->name, x_sf_filename_); | |
148 | + InsertInst(TRUE, b->bank, p->program, p->name, x_sf_filename_); | |
149 | 149 | } |
150 | 150 | } |
151 | 151 |
@@ -171,7 +171,7 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_) | ||
171 | 171 | tv.item.iSelectedImage = 3; |
172 | 172 | TreeView_InsertItem(hTree, &tv); |
173 | 173 | |
174 | - InsertDrum(128, d->program, d->notes[j], "", x_sf_filename_); | |
174 | + InsertDrum(TRUE, 128, d->program, d->notes[j], "", x_sf_filename_); | |
175 | 175 | } |
176 | 176 | } |
177 | 177 |
@@ -230,7 +230,7 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_) | ||
230 | 230 | tv.item.iSelectedImage = 3; |
231 | 231 | TreeView_InsertItem(hTree, &tv); |
232 | 232 | |
233 | - InsertInst(x_bank, x_preset, pname_, x_sf_filename_); | |
233 | + InsertInst(FALSE, x_bank, x_preset, pname_, x_sf_filename_); | |
234 | 234 | } |
235 | 235 | |
236 | 236 | } |
@@ -286,7 +286,7 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_) | ||
286 | 286 | tv.item.iImage = 2; |
287 | 287 | tv.item.iSelectedImage = 3; |
288 | 288 | TreeView_InsertItem(hTree, &tv); |
289 | - InsertDrum(128, x_preset, x_keynote, pname_, x_sf_filename_); | |
289 | + InsertDrum(FALSE, 128, x_preset, x_keynote, pname_, x_sf_filename_); | |
290 | 290 | } |
291 | 291 | } |
292 | 292 | } |
@@ -18,6 +18,7 @@ extern "C" { | ||
18 | 18 | #include <string> |
19 | 19 | struct sfvSFInst |
20 | 20 | { |
21 | + BOOL dls; | |
21 | 22 | unsigned char bank; |
22 | 23 | unsigned char preset; |
23 | 24 | std::string str; |
@@ -26,6 +27,7 @@ struct sfvSFInst | ||
26 | 27 | std::map< int, std::map< int, sfvSFInst > > g_sfInst; |
27 | 28 | struct sfvSFDrum |
28 | 29 | { |
30 | + BOOL dls; | |
29 | 31 | unsigned char bank; |
30 | 32 | unsigned char preset; |
31 | 33 | unsigned char note; |
@@ -34,12 +36,13 @@ struct sfvSFDrum | ||
34 | 36 | }; |
35 | 37 | std::map< int, std::map< int, sfvSFDrum > > g_sfDrum; |
36 | 38 | |
37 | -extern "C" void InsertInst(int bank, int preset, char *str, const char *sfname) | |
39 | +extern "C" void InsertInst(BOOL dls, int bank, int preset, char *str, const char *sfname) | |
38 | 40 | { |
39 | 41 | std::map< int, std::map< int, sfvSFInst > >::iterator it = g_sfInst.find(bank); |
40 | 42 | if (it != g_sfInst.end()) { |
41 | 43 | |
42 | 44 | sfvSFInst newdata; |
45 | + newdata.dls = dls; | |
43 | 46 | newdata.bank = bank; |
44 | 47 | newdata.preset = preset; |
45 | 48 | newdata.str = sfname; |
@@ -53,16 +56,17 @@ extern "C" void InsertInst(int bank, int preset, char *str, const char *sfname) | ||
53 | 56 | } |
54 | 57 | } else { |
55 | 58 | g_sfInst.insert(std::make_pair(bank, std::map< int, sfvSFInst >())); |
56 | - InsertInst(bank, preset, str, sfname); | |
59 | + InsertInst(dls, bank, preset, str, sfname); | |
57 | 60 | } |
58 | 61 | } |
59 | 62 | |
60 | -extern "C" void InsertDrum(int bank, int preset, int note, const char *str, const char *sfname) | |
63 | +extern "C" void InsertDrum(BOOL dls, int bank, int preset, int note, const char *str, const char *sfname) | |
61 | 64 | { |
62 | 65 | std::map< int, std::map< int, sfvSFDrum > >::iterator it = g_sfDrum.find(preset); |
63 | 66 | if (it != g_sfDrum.end()) { |
64 | 67 | |
65 | 68 | sfvSFDrum newdata; |
69 | + newdata.dls = dls; | |
66 | 70 | newdata.bank = bank; |
67 | 71 | newdata.preset = preset; |
68 | 72 | newdata.note = note; |
@@ -77,7 +81,7 @@ extern "C" void InsertDrum(int bank, int preset, int note, const char *str, cons | ||
77 | 81 | } |
78 | 82 | } else { |
79 | 83 | g_sfDrum.insert(std::make_pair(preset, std::map< int, sfvSFDrum >())); |
80 | - InsertDrum(bank, preset, note, str, sfname); | |
84 | + InsertDrum(dls, bank, preset, note, str, sfname); | |
81 | 85 | } |
82 | 86 | } |
83 | 87 |
@@ -87,11 +91,11 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen | ||
87 | 91 | if (!outListEnable && prependBaseDir) |
88 | 92 | fprintf(fp, "\ndir \"${basedir}\"\n"); |
89 | 93 | for (std::map< int, std::map< int, sfvSFInst > >::iterator it = g_sfInst.begin(); it != g_sfInst.end(); ++it) { |
90 | - if (outListEnable) | |
91 | - fprintf(fp, "bank %d\n", (*it).first); | |
92 | - else | |
93 | - fprintf(fp, "\nbank %d\n", (*it).first); | |
94 | + if (!outListEnable) | |
95 | + fprintf(fp, "\n"); | |
96 | + fprintf(fp, "bank %d\n", (*it).first); | |
94 | 97 | for (std::map< int, sfvSFInst >::iterator itc = (*it).second.begin(); itc != (*it).second.end(); ++itc) { |
98 | + BOOL dls = (*itc).second.dls; | |
95 | 99 | const char *file = (*itc).second.str.c_str(); |
96 | 100 | const int program = (*itc).first; |
97 | 101 | const int bank = (*itc).second.bank; |
@@ -105,9 +109,9 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen | ||
105 | 109 | fprintf(fp, "%03d:%03d %s (%s)\n", bank, preset, comment, file); |
106 | 110 | else { |
107 | 111 | if (strstr(file, " ")) |
108 | - fprintf(fp, "%d %%font \"%s\" %d %d", program, file, bank, preset); | |
112 | + fprintf(fp, "%d %s \"%s\" %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset); | |
109 | 113 | else |
110 | - fprintf(fp, "%d %%font %s %d %d", program, file, bank, preset); | |
114 | + fprintf(fp, "%d %s %s %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset); | |
111 | 115 | if (outComment && comment && strlen(comment)) |
112 | 116 | fprintf(fp, " # %s", comment); |
113 | 117 | fprintf(fp, "\n"); |
@@ -116,11 +120,11 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen | ||
116 | 120 | } |
117 | 121 | |
118 | 122 | for (std::map< int, std::map< int, sfvSFDrum > >::iterator it = g_sfDrum.begin(); it != g_sfDrum.end(); ++it) { |
119 | - if (outListEnable) | |
120 | - fprintf(fp, "drumset %d\n", (*it).first); | |
121 | - else | |
122 | - fprintf(fp, "\ndrumset %d\n", (*it).first); | |
123 | + if (!outListEnable) | |
124 | + fprintf(fp, "\n"); | |
125 | + fprintf(fp, "drumset %d\n", (*it).first); | |
123 | 126 | for (std::map< int, sfvSFDrum >::iterator itc = (*it).second.begin(); itc != (*it).second.end(); ++itc) { |
127 | + BOOL dls = (*itc).second.dls; | |
124 | 128 | const char *file = (*itc).second.str.c_str(); |
125 | 129 | const int program = (*itc).first; |
126 | 130 | const int bank = (*itc).second.bank; |
@@ -135,9 +139,9 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen | ||
135 | 139 | fprintf(fp, "%03d:%03d %s (%s)\n", preset, note, comment, file); |
136 | 140 | else { |
137 | 141 | if (strstr(file, " ")) |
138 | - fprintf(fp, "%d %%font \"%s\" %d %d %d", program, file, bank, preset, note); | |
142 | + fprintf(fp, "%d %s \"%s\" %d %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset, note); | |
139 | 143 | else |
140 | - fprintf(fp, "%d %%font %s %d %d %d", program, file, bank, preset, note); | |
144 | + fprintf(fp, "%d %s %s %d %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset, note); | |
141 | 145 | if (outComment && comment && strlen(comment)) |
142 | 146 | fprintf(fp, " # %s", comment); |
143 | 147 | fprintf(fp, "\n"); |