| 1 |
/* |
| 2 |
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2023 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 24 февр. 2023 г. |
| 7 |
* |
| 8 |
* lsp-runtime-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-runtime-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include <lsp-plug.in/fmt/sfz/DocumentProcessor.h> |
| 23 |
#include <lsp-plug.in/lltl/darray.h> |
| 24 |
#include <lsp-plug.in/test-fw/utest.h> |
| 25 |
|
| 26 |
UTEST_BEGIN("runtime.fmt.sfz", documentprocessor) |
| 27 |
|
| 28 |
class SFZHandler: public sfz::IDocumentHandler |
| 29 |
{ |
| 30 |
protected: |
| 31 |
typedef struct pair_t |
| 32 |
{ |
| 33 |
const char *key; |
| 34 |
const char *value; |
| 35 |
} pair_t; |
| 36 |
|
| 37 |
static ssize_t pairs_cmp(const pair_t *a, const pair_t *b) |
| 38 |
{ |
| 39 |
return strcmp(a->key, b->key); |
| 40 |
} |
| 41 |
|
| 42 |
private: |
| 43 |
LSPString sData; |
| 44 |
lltl::darray<pair_t> vFiles; |
| 45 |
|
| 46 |
protected: |
| 47 |
void dump_opcodes(const char **opcodes, const char **values) |
| 48 |
{ |
| 49 |
lltl::darray<pair_t> pairs; |
| 50 |
for (;*opcodes != NULL; ++opcodes, ++values) |
| 51 |
{ |
| 52 |
pair_t *p = pairs.add(); |
| 53 |
p->key = *opcodes; |
| 54 |
p->value = *values; |
| 55 |
} |
| 56 |
pairs.qsort(pairs_cmp); |
| 57 |
|
| 58 |
for (size_t i=0, n=pairs.size(); i<n; ++i) |
| 59 |
{ |
| 60 |
pair_t *p = pairs.uget(i); |
| 61 |
if (i != 0) |
| 62 |
sData.append(' '); |
| 63 |
sData.fmt_append_ascii("%s=%s", p->key, p->value); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
static uint32_t hash_data(io::IInStream *data) |
| 68 |
{ |
| 69 |
uint32_t hash = 0; |
| 70 |
ssize_t value; |
| 71 |
while ((value = data->read_byte()) >= 0) |
| 72 |
{ |
| 73 |
hash = (hash << 7) | (hash >> (sizeof(hash)*8 - 7)); |
| 74 |
hash += (value & 0xff) * 17; |
| 75 |
} |
| 76 |
return hash; |
| 77 |
} |
| 78 |
|
| 79 |
public: |
| 80 |
const LSPString *data() const { return &sData; } |
| 81 |
void add_file(const char *name, const char *data) |
| 82 |
{ |
| 83 |
pair_t *p = vFiles.add(); |
| 84 |
p->key = name; |
| 85 |
p->value = data; |
| 86 |
} |
| 87 |
|
| 88 |
public: |
| 89 |
virtual status_t begin() override |
| 90 |
{ |
| 91 |
sData.append_ascii("// begin\n"); |
| 92 |
return STATUS_OK; |
| 93 |
} |
| 94 |
|
| 95 |
virtual status_t control(const char **opcodes, const char **values) override |
| 96 |
{ |
| 97 |
sData.append_ascii("<control>\n"); |
| 98 |
dump_opcodes(opcodes, values); |
| 99 |
sData.append('\n'); |
| 100 |
return STATUS_OK; |
| 101 |
} |
| 102 |
|
| 103 |
virtual status_t region(const char **opcodes, const char **values) override |
| 104 |
{ |
| 105 |
sData.append_ascii("<region>\n"); |
| 106 |
dump_opcodes(opcodes, values); |
| 107 |
sData.append('\n'); |
| 108 |
return STATUS_OK; |
| 109 |
} |
| 110 |
|
| 111 |
virtual status_t sample( |
| 112 |
const char *name, io::IInStream *data, |
| 113 |
const char **opcodes, const char **values) override |
| 114 |
{ |
| 115 |
sData.append_ascii("<sample>\n"); |
| 116 |
sData.fmt_append_ascii("name=%s data=0x%08x", name, int(hash_data(data))); |
| 117 |
if (*opcodes != NULL) |
| 118 |
sData.append(' '); |
| 119 |
dump_opcodes(opcodes, values); |
| 120 |
sData.append('\n'); |
| 121 |
return STATUS_OK; |
| 122 |
} |
| 123 |
|
| 124 |
virtual status_t effect(const char **opcodes, const char **values) override |
| 125 |
{ |
| 126 |
sData.append_ascii("<effect>\n"); |
| 127 |
dump_opcodes(opcodes, values); |
| 128 |
sData.append('\n'); |
| 129 |
return STATUS_OK; |
| 130 |
} |
| 131 |
|
| 132 |
virtual status_t midi(const char **opcodes, const char **values) override |
| 133 |
{ |
| 134 |
sData.append_ascii("<midi>\n"); |
| 135 |
dump_opcodes(opcodes, values); |
| 136 |
sData.append('\n'); |
| 137 |
return STATUS_OK; |
| 138 |
} |
| 139 |
|
| 140 |
virtual status_t curve(const char **opcodes, const char **values) override |
| 141 |
{ |
| 142 |
sData.append_ascii("<curve>\n"); |
| 143 |
dump_opcodes(opcodes, values); |
| 144 |
sData.append('\n'); |
| 145 |
return STATUS_OK; |
| 146 |
} |
| 147 |
|
| 148 |
virtual status_t custom_header(const char *name, const char **opcodes, const char **values) override |
| 149 |
{ |
| 150 |
sData.fmt_append_ascii("<%s>\n", name); |
| 151 |
dump_opcodes(opcodes, values); |
| 152 |
sData.append('\n'); |
| 153 |
return STATUS_OK; |
| 154 |
} |
| 155 |
|
| 156 |
virtual status_t include(sfz::PullParser *parser, const char *name) override |
| 157 |
{ |
| 158 |
sData.fmt_append_ascii("// #include \"%s\"\n", name); |
| 159 |
for (size_t i=0, n=vFiles.size(); i<n; ++i) |
| 160 |
{ |
| 161 |
pair_t *p = vFiles.uget(i); |
| 162 |
if (strcmp(p->key, name) == 0) |
| 163 |
return parser->wrap(p->value); |
| 164 |
} |
| 165 |
|
| 166 |
return STATUS_NOT_FOUND; |
| 167 |
} |
| 168 |
|
| 169 |
virtual const char *root_file_name() override |
| 170 |
{ |
| 171 |
return "test.sfz"; |
| 172 |
} |
| 173 |
|
| 174 |
virtual status_t end(status_t result) override |
| 175 |
{ |
| 176 |
sData.append_ascii("// end\n"); |
| 177 |
return STATUS_OK; |
| 178 |
} |
| 179 |
}; |
| 180 |
|
| 181 |
void check_namespaces_simple() |
| 182 |
{ |
| 183 |
static const char *data = |
| 184 |
"<global>\n" |
| 185 |
"loop_mode=one_shot\n" |
| 186 |
"ampeg_attack=0.001\n" |
| 187 |
"ampeg_decay=0.7\n" |
| 188 |
"ampeg_sustain=100\n" |
| 189 |
"\n" |
| 190 |
"<master>\n" |
| 191 |
"amplitude_cc30=100\n" |
| 192 |
"offset_cc33=3000\n" |
| 193 |
"ampeg_sustain_oncc33=-100\n" |
| 194 |
"<group> key=36\n" |
| 195 |
"<region>\n" |
| 196 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 197 |
"<region>\n" |
| 198 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 199 |
"<region>\n" |
| 200 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 201 |
"<region>\n" |
| 202 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 203 |
"\n" |
| 204 |
"<master>\n" |
| 205 |
"amplitude_cc35=100\n" |
| 206 |
"offset_cc38=1500\n" |
| 207 |
"ampeg_sustain_oncc38=-100\n" |
| 208 |
"<group>key=38\n" |
| 209 |
"<region>\n" |
| 210 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr1.wav hirand=0.250\n" |
| 211 |
"<region>\n" |
| 212 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 213 |
"<region>\n" |
| 214 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 215 |
"<region>\n" |
| 216 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr4.wav lorand=0.750\n"; |
| 217 |
|
| 218 |
static const char *expected = |
| 219 |
"// begin\n" |
| 220 |
"<region>\n" |
| 221 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.250 key=36 loop_mode=one_shot offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav\n" |
| 222 |
"<region>\n" |
| 223 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.500 key=36 loop_mode=one_shot lorand=0.250 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav\n" |
| 224 |
"<region>\n" |
| 225 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.750 key=36 loop_mode=one_shot lorand=0.500 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav\n" |
| 226 |
"<region>\n" |
| 227 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 key=36 loop_mode=one_shot lorand=0.750 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav\n" |
| 228 |
"<region>\n" |
| 229 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.250 key=38 loop_mode=one_shot offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr1.wav\n" |
| 230 |
"<region>\n" |
| 231 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.500 key=38 loop_mode=one_shot lorand=0.250 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr2.wav\n" |
| 232 |
"<region>\n" |
| 233 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.750 key=38 loop_mode=one_shot lorand=0.500 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr3.wav\n" |
| 234 |
"<region>\n" |
| 235 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 key=38 loop_mode=one_shot lorand=0.750 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr4.wav\n" |
| 236 |
"// end\n"; |
| 237 |
|
| 238 |
printf("Checking namespace parameter merging...\n"); |
| 239 |
|
| 240 |
SFZHandler handler; |
| 241 |
sfz::DocumentProcessor processor; |
| 242 |
UTEST_ASSERT(processor.wrap(data) == STATUS_OK); |
| 243 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OK); |
| 244 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 245 |
|
| 246 |
const char *processed = handler.data()->get_utf8(); |
| 247 |
|
| 248 |
printf("Source document:\n%s\n", data); |
| 249 |
printf("Processed document:\n%s\n", processed); |
| 250 |
if (strcmp(processed, expected) != 0) |
| 251 |
UTEST_FAIL_MSG("Expected document:\n%s\n", expected); |
| 252 |
} |
| 253 |
|
| 254 |
void check_namespaces_overrides() |
| 255 |
{ |
| 256 |
static const char *data = |
| 257 |
"<control>\n" |
| 258 |
"default_path=../Samples/bobobo/ note_offset=-3\n" |
| 259 |
"<global>\n" |
| 260 |
"loop_mode=one_shot\n" |
| 261 |
"ampeg_attack=0.001\n" |
| 262 |
"ampeg_decay=0.7\n" |
| 263 |
"ampeg_sustain=100\n" |
| 264 |
"\n" |
| 265 |
"<master>\n" |
| 266 |
"amplitude_cc30=100\n" |
| 267 |
"offset_cc33=3000\n" |
| 268 |
"ampeg_sustain_oncc33=-100\n" |
| 269 |
"<group> key=36\n" |
| 270 |
"<region>\n" |
| 271 |
"sample=bobobo_bass_vl1_rr1.wav hirand=0.250 loop_mode=no_loop key=37\n" |
| 272 |
"<region>\n" |
| 273 |
"sample=bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500 ampeg_attack=0.1 offset_cc33=2000\n" |
| 274 |
"<region>\n" |
| 275 |
"sample=bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750 ampeg_attack=0.1\n" |
| 276 |
"<region>\n" |
| 277 |
"sample=bobobo_bass_vl1_rr4.wav lorand=0.750 amplitude_cc30=50 key=37\n" |
| 278 |
"\n" |
| 279 |
"<master>\n" |
| 280 |
"amplitude_cc35=100\n" |
| 281 |
"offset_cc38=1500\n" |
| 282 |
"ampeg_sustain_oncc38=-100\n" |
| 283 |
"<group>key=38\n" |
| 284 |
"<region>\n" |
| 285 |
"sample=bobobo_tenor_l_vl1_rr1.wav hirand=0.250 ampeg_attack=0.1\n" |
| 286 |
"<region>\n" |
| 287 |
"sample=bobobo_tenor_l_vl1_rr2.wav lorand=0.250 hirand=0.500 key=39 offset_cc38=2000\n" |
| 288 |
"<region>\n" |
| 289 |
"sample=bobobo_tenor_l_vl1_rr3.wav lorand=0.500 hirand=0.750 key=39 offset_cc38=4000\n" |
| 290 |
"<region>\n" |
| 291 |
"sample=bobobo_tenor_l_vl1_rr4.wav lorand=0.750 loop_mode=continuous amplitude_cc35=50\n"; |
| 292 |
|
| 293 |
static const char *expected = |
| 294 |
"// begin\n" |
| 295 |
"<control>\n" |
| 296 |
"default_path=../Samples/bobobo/ note_offset=-3\n" |
| 297 |
"<region>\n" |
| 298 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.250 key=37 loop_mode=no_loop offset_cc33=3000 sample=bobobo_bass_vl1_rr1.wav\n" |
| 299 |
"<region>\n" |
| 300 |
"ampeg_attack=0.1 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.500 key=36 loop_mode=one_shot lorand=0.250 offset_cc33=2000 sample=bobobo_bass_vl1_rr2.wav\n" |
| 301 |
"<region>\n" |
| 302 |
"ampeg_attack=0.1 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.750 key=36 loop_mode=one_shot lorand=0.500 offset_cc33=3000 sample=bobobo_bass_vl1_rr3.wav\n" |
| 303 |
"<region>\n" |
| 304 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc33=-100 amplitude_cc30=50 key=37 loop_mode=one_shot lorand=0.750 offset_cc33=3000 sample=bobobo_bass_vl1_rr4.wav\n" |
| 305 |
"<region>\n" |
| 306 |
"ampeg_attack=0.1 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.250 key=38 loop_mode=one_shot offset_cc38=1500 sample=bobobo_tenor_l_vl1_rr1.wav\n" |
| 307 |
"<region>\n" |
| 308 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.500 key=39 loop_mode=one_shot lorand=0.250 offset_cc38=2000 sample=bobobo_tenor_l_vl1_rr2.wav\n" |
| 309 |
"<region>\n" |
| 310 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.750 key=39 loop_mode=one_shot lorand=0.500 offset_cc38=4000 sample=bobobo_tenor_l_vl1_rr3.wav\n" |
| 311 |
"<region>\n" |
| 312 |
"ampeg_attack=0.001 ampeg_decay=0.7 ampeg_sustain=100 ampeg_sustain_oncc38=-100 amplitude_cc35=50 key=38 loop_mode=continuous lorand=0.750 offset_cc38=1500 sample=bobobo_tenor_l_vl1_rr4.wav\n" |
| 313 |
"// end\n"; |
| 314 |
|
| 315 |
printf("Checking namespace parameter overriding...\n"); |
| 316 |
|
| 317 |
SFZHandler handler; |
| 318 |
sfz::DocumentProcessor processor; |
| 319 |
UTEST_ASSERT(processor.process(&handler) == STATUS_CLOSED); |
| 320 |
UTEST_ASSERT(processor.wrap(data) == STATUS_OK); |
| 321 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OK); |
| 322 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 323 |
UTEST_ASSERT(processor.process(&handler) == STATUS_CLOSED); |
| 324 |
|
| 325 |
const char *processed = handler.data()->get_utf8(); |
| 326 |
|
| 327 |
printf("Source document:\n%s\n", data); |
| 328 |
printf("Processed document:\n%s\n", processed); |
| 329 |
if (strcmp(processed, expected) != 0) |
| 330 |
UTEST_FAIL_MSG("Expected document:\n%s\n", expected); |
| 331 |
} |
| 332 |
|
| 333 |
void check_includes_and_defines() |
| 334 |
{ |
| 335 |
static const char *data1 = |
| 336 |
"<control>\n" |
| 337 |
"default_path=../Samples/bobobo/\n" |
| 338 |
"#define $KEY1 36\n" |
| 339 |
"#define $KEY2 37\n" |
| 340 |
"#define $KEY3 38\n" |
| 341 |
"#define $KEY4 39\n" |
| 342 |
"<master>\n" |
| 343 |
"amplitude_cc30=100\n" |
| 344 |
"offset_cc33=3000\n" |
| 345 |
"ampeg_sustain_oncc33=-100\n" |
| 346 |
"<group> key=$KEY1\n" |
| 347 |
"<region>\n" |
| 348 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 349 |
"<region>\n" |
| 350 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 351 |
"<group> key=$KEY2\n" |
| 352 |
"<region>\n" |
| 353 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 354 |
"<region>\n" |
| 355 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 356 |
"\n" |
| 357 |
"#include \"other-config.sfz\"\n" |
| 358 |
"<master>\n" |
| 359 |
"amplitude_cc35=100\n" |
| 360 |
"offset_cc38=1500\n" |
| 361 |
"ampeg_sustain_oncc38=-100\n" |
| 362 |
"<group>key=$KEY3\n" |
| 363 |
"<region>\n" |
| 364 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr1.wav hirand=0.250\n" |
| 365 |
"<region>\n" |
| 366 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 367 |
"<group>key=$KEY4\n" |
| 368 |
"<region>\n" |
| 369 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 370 |
"<region>\n" |
| 371 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr4.wav lorand=0.750\n"; |
| 372 |
|
| 373 |
static const char *data2 = |
| 374 |
"<control>\n" |
| 375 |
"default_path=../Samples/bobobo/\n" |
| 376 |
"#define $KEY1 40\n" |
| 377 |
"#define $KEY2 41\n" |
| 378 |
"#define $KEY3 42\n" |
| 379 |
"#define $KEY4 43\n" |
| 380 |
"<master>\n" |
| 381 |
"amplitude_cc30=100\n" |
| 382 |
"offset_cc33=3000\n" |
| 383 |
"ampeg_sustain_oncc33=-100\n" |
| 384 |
"<group> key=$KEY1\n" |
| 385 |
"<region>\n" |
| 386 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 387 |
"<region>\n" |
| 388 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 389 |
"<group> key=$KEY2\n" |
| 390 |
"<region>\n" |
| 391 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 392 |
"<region>\n" |
| 393 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 394 |
"\n" |
| 395 |
"<master>\n" |
| 396 |
"amplitude_cc35=100\n" |
| 397 |
"offset_cc38=1500\n" |
| 398 |
"ampeg_sustain_oncc38=-100\n" |
| 399 |
"<group>key=$KEY3\n" |
| 400 |
"<region>\n" |
| 401 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr1.wav hirand=0.250\n" |
| 402 |
"<region>\n" |
| 403 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 404 |
"<group>key=$KEY4\n" |
| 405 |
"<region>\n" |
| 406 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 407 |
"<region>\n" |
| 408 |
"sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr4.wav lorand=0.750\n"; |
| 409 |
|
| 410 |
static const char *expected = |
| 411 |
"// begin\n" |
| 412 |
"<control>\n" |
| 413 |
"default_path=../Samples/bobobo/\n" |
| 414 |
"<region>\n" |
| 415 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.250 key=36 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav\n" |
| 416 |
"<region>\n" |
| 417 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.500 key=36 lorand=0.250 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav\n" |
| 418 |
"<region>\n" |
| 419 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.750 key=37 lorand=0.500 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav\n" |
| 420 |
"// #include \"other-config.sfz\"\n" |
| 421 |
"<region>\n" |
| 422 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 key=37 lorand=0.750 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav\n" |
| 423 |
"<control>\n" |
| 424 |
"default_path=../Samples/bobobo/\n" |
| 425 |
"<region>\n" |
| 426 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.250 key=40 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav\n" |
| 427 |
"<region>\n" |
| 428 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.500 key=40 lorand=0.250 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav\n" |
| 429 |
"<region>\n" |
| 430 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 hirand=0.750 key=41 lorand=0.500 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav\n" |
| 431 |
"<region>\n" |
| 432 |
"ampeg_sustain_oncc33=-100 amplitude_cc30=100 key=41 lorand=0.750 offset_cc33=3000 sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav\n" |
| 433 |
"<control>\n" |
| 434 |
"default_path=../Samples/bobobo/\n" |
| 435 |
"<region>\n" |
| 436 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.250 key=42 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr1.wav\n" |
| 437 |
"<region>\n" |
| 438 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.500 key=42 lorand=0.250 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr2.wav\n" |
| 439 |
"<region>\n" |
| 440 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.750 key=43 lorand=0.500 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr3.wav\n" |
| 441 |
"<region>\n" |
| 442 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 key=43 lorand=0.750 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr4.wav\n" |
| 443 |
"<control>\n" |
| 444 |
"default_path=../Samples/bobobo/\n" |
| 445 |
"<region>\n" |
| 446 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.250 key=42 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr1.wav\n" |
| 447 |
"<region>\n" |
| 448 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.500 key=42 lorand=0.250 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr2.wav\n" |
| 449 |
"<region>\n" |
| 450 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 hirand=0.750 key=43 lorand=0.500 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr3.wav\n" |
| 451 |
"<region>\n" |
| 452 |
"ampeg_sustain_oncc38=-100 amplitude_cc35=100 key=43 lorand=0.750 offset_cc38=1500 sample=../Samples/bobobo/bobobo_tenor_l_vl1_rr4.wav\n" |
| 453 |
"// end\n"; |
| 454 |
|
| 455 |
printf("Checking nested file includes...\n"); |
| 456 |
|
| 457 |
SFZHandler handler; |
| 458 |
handler.add_file("other-config.sfz", data2); |
| 459 |
|
| 460 |
sfz::DocumentProcessor processor; |
| 461 |
UTEST_ASSERT(processor.wrap(data1) == STATUS_OK); |
| 462 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OK); |
| 463 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 464 |
|
| 465 |
const char *processed = handler.data()->get_utf8(); |
| 466 |
|
| 467 |
printf("Source document 1:\n%s\n", data1); |
| 468 |
printf("Source document 2:\n%s\n", data2); |
| 469 |
printf("Processed document:\n%s\n", processed); |
| 470 |
if (strcmp(processed, expected) != 0) |
| 471 |
UTEST_FAIL_MSG("Expected document:\n%s\n", expected); |
| 472 |
} |
| 473 |
|
| 474 |
void check_multiple_vars() |
| 475 |
{ |
| 476 |
static const char *instr = |
| 477 |
"#define $instr Crash_left_shank\n" |
| 478 |
"#define $mic center\n" |
| 479 |
"<group>\n" |
| 480 |
"group_label=$instr\n" |
| 481 |
"group=$grp_cl_shk\n" |
| 482 |
"off_by=$off_cl\n" |
| 483 |
"\n" |
| 484 |
"<region> lovel=$v41l hivel=$v41h amp_velcurve_$v41h=1 region_label=1 sample=$instr/1-$instr-$mic.$ext seq_length=3 seq_position=1\n" |
| 485 |
"<region> lovel=$v41l hivel=$v41h amp_velcurve_$v41h=1 region_label=2 sample=$instr/2-$instr-$mic.$ext seq_length=3 seq_position=2\n" |
| 486 |
"<region> lovel=$v41l hivel=$v41h amp_velcurve_$v41h=1 region_label=3 sample=$instr/3-$instr-$mic.$ext seq_length=3 seq_position=3\n" |
| 487 |
"\n" |
| 488 |
"<region> lovel=$v42l hivel=$v42h amp_velcurve_$v42h=1 region_label=4 sample=$instr/4-$instr-$mic.$ext seq_length=3 seq_position=1\n" |
| 489 |
"<region> lovel=$v42l hivel=$v42h amp_velcurve_$v42h=1 region_label=5 sample=$instr/5-$instr-$mic.$ext seq_length=3 seq_position=2\n" |
| 490 |
"<region> lovel=$v42l hivel=$v42h amp_velcurve_$v42h=1 region_label=6 sample=$instr/6-$instr-$mic.$ext seq_length=3 seq_position=3\n" |
| 491 |
"\n" |
| 492 |
"<region> sample=$not_found_var$$instr\n"; |
| 493 |
|
| 494 |
static const char *velocity = |
| 495 |
"#define $v11l 1 #define $v11h 127\n" |
| 496 |
"#define $v41l 1 #define $v41h 31\n" |
| 497 |
"#define $v42l 32 #define $v42h 63\n"; |
| 498 |
|
| 499 |
static const char *macro = |
| 500 |
"#define $ext flac\n"; |
| 501 |
|
| 502 |
static const char *data = |
| 503 |
"#include \"macro.txt\"\n" |
| 504 |
"#include \"velocity.txt\"\n" |
| 505 |
"#include \"crash-left.txt\"\n"; |
| 506 |
|
| 507 |
static const char *expected = |
| 508 |
"// begin\n" |
| 509 |
"// #include \"macro.txt\"\n" |
| 510 |
"// #include \"velocity.txt\"\n" |
| 511 |
"// #include \"crash-left.txt\"\n" |
| 512 |
"<region>\n" |
| 513 |
"amp_velcurve_31=1 group=$grp_cl_shk group_label=Crash_left_shank hivel=31 lovel=1 off_by=$off_cl region_label=1 sample=Crash_left_shank/1-Crash_left_shank-center.flac seq_length=3 seq_position=1\n" |
| 514 |
"<region>\n" |
| 515 |
"amp_velcurve_31=1 group=$grp_cl_shk group_label=Crash_left_shank hivel=31 lovel=1 off_by=$off_cl region_label=2 sample=Crash_left_shank/2-Crash_left_shank-center.flac seq_length=3 seq_position=2\n" |
| 516 |
"<region>\n" |
| 517 |
"amp_velcurve_31=1 group=$grp_cl_shk group_label=Crash_left_shank hivel=31 lovel=1 off_by=$off_cl region_label=3 sample=Crash_left_shank/3-Crash_left_shank-center.flac seq_length=3 seq_position=3\n" |
| 518 |
"<region>\n" |
| 519 |
"amp_velcurve_63=1 group=$grp_cl_shk group_label=Crash_left_shank hivel=63 lovel=32 off_by=$off_cl region_label=4 sample=Crash_left_shank/4-Crash_left_shank-center.flac seq_length=3 seq_position=1\n" |
| 520 |
"<region>\n" |
| 521 |
"amp_velcurve_63=1 group=$grp_cl_shk group_label=Crash_left_shank hivel=63 lovel=32 off_by=$off_cl region_label=5 sample=Crash_left_shank/5-Crash_left_shank-center.flac seq_length=3 seq_position=2\n" |
| 522 |
"<region>\n" |
| 523 |
"amp_velcurve_63=1 group=$grp_cl_shk group_label=Crash_left_shank hivel=63 lovel=32 off_by=$off_cl region_label=6 sample=Crash_left_shank/6-Crash_left_shank-center.flac seq_length=3 seq_position=3\n" |
| 524 |
"<region>\n" |
| 525 |
"group=$grp_cl_shk group_label=Crash_left_shank off_by=$off_cl sample=$not_found_var$Crash_left_shank\n" |
| 526 |
"// end\n"; |
| 527 |
|
| 528 |
printf("Checking namespace parameter overriding...\n"); |
| 529 |
|
| 530 |
SFZHandler handler; |
| 531 |
handler.add_file("macro.txt", macro); |
| 532 |
handler.add_file("velocity.txt", velocity); |
| 533 |
handler.add_file("crash-left.txt", instr); |
| 534 |
|
| 535 |
sfz::DocumentProcessor processor; |
| 536 |
|
| 537 |
UTEST_ASSERT(processor.wrap(data) == STATUS_OK); |
| 538 |
UTEST_ASSERT_MSG(processor.process(&handler) == STATUS_OK, "Processed data: %s\n", handler.data()->get_utf8()); |
| 539 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 540 |
|
| 541 |
const char *processed = handler.data()->get_utf8(); |
| 542 |
|
| 543 |
printf("Source document:\n%s\n", data); |
| 544 |
printf("Processed document:\n%s\n", processed); |
| 545 |
if (strcmp(processed, expected) != 0) |
| 546 |
UTEST_FAIL_MSG("Expected document:\n%s\n", expected); |
| 547 |
} |
| 548 |
|
| 549 |
void check_other_headers() |
| 550 |
{ |
| 551 |
static const char *data = |
| 552 |
"<sample> name=sample1.wav\n" |
| 553 |
"some_opcode1=value1\n" |
| 554 |
"data=gggJ~\x92\x93\x9dJ\x93\x9dJ\x8bJ\x9e\x8f\x9d\x9eJlvylJggg7444oyp7474$\r\n" |
| 555 |
"some_opcode2=value2\n" |
| 556 |
"<sample> name=sample2.wav\n" |
| 557 |
"some_opcode1=value1\n" |
| 558 |
"data=gggJ~\x92\x93\x9dJ\x94\x9eJ\x8bJ\x9e\x8f\x9d\x9eJlvylJggg7444oyp7474$\r\n" |
| 559 |
"<curve>curve_index=17\n" |
| 560 |
"v000=0\n" |
| 561 |
"v095=1\n" |
| 562 |
"v127=1\n" |
| 563 |
"\n" |
| 564 |
"<curve>curve_index=18\n" |
| 565 |
"v000=0\n" |
| 566 |
"v095=0.5\n" |
| 567 |
"v127=1\n" |
| 568 |
"<magic> param1=value1 param2=value2\n" |
| 569 |
"<region> amplitude_curvecc110=9 sample=sample1.wav pitch_keycenter=69\r\n" |
| 570 |
"<region> amplitude_curvecc110=10 sample=sample2.wav pitch_keycenter=80\r\n"; |
| 571 |
|
| 572 |
static const char *expected = |
| 573 |
"// begin\n" |
| 574 |
"<sample>\n" |
| 575 |
"name=sample1.wav data=0x3b61a865 some_opcode1=value1 some_opcode2=value2\n" |
| 576 |
"<sample>\n" |
| 577 |
"name=sample2.wav data=0x5b61a977 some_opcode1=value1\n" |
| 578 |
"<curve>\n" |
| 579 |
"curve_index=17 v000=0 v095=1 v127=1\n" |
| 580 |
"<curve>\n" |
| 581 |
"curve_index=18 v000=0 v095=0.5 v127=1\n" |
| 582 |
"<magic>\n" |
| 583 |
"param1=value1 param2=value2\n" |
| 584 |
"<region>\n" |
| 585 |
"amplitude_curvecc110=9 pitch_keycenter=69 sample=sample1.wav\n" |
| 586 |
"<region>\n" |
| 587 |
"amplitude_curvecc110=10 pitch_keycenter=80 sample=sample2.wav\n" |
| 588 |
"// end\n"; |
| 589 |
|
| 590 |
SFZHandler handler; |
| 591 |
sfz::DocumentProcessor processor; |
| 592 |
UTEST_ASSERT(processor.wrap(data) == STATUS_OK); |
| 593 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OK); |
| 594 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 595 |
|
| 596 |
const char *processed = handler.data()->get_utf8(); |
| 597 |
|
| 598 |
printf("Source document:\n%s\n", data); |
| 599 |
printf("Processed document:\n%s\n", processed); |
| 600 |
if (strcmp(processed, expected) != 0) |
| 601 |
UTEST_FAIL_MSG("Expected document:\n%s\n", expected); |
| 602 |
} |
| 603 |
|
| 604 |
void check_read_file() |
| 605 |
{ |
| 606 |
static const char *expected = |
| 607 |
"// begin\n" |
| 608 |
"<region>\n" |
| 609 |
"amp_velcurve_31=1 hivel=31 key=36 loop_mode=one_shot sample=kick_vl1_rr1.wav seq_length=4 seq_position=1\n" |
| 610 |
"<region>\n" |
| 611 |
"amp_velcurve_31=1 hivel=31 key=36 loop_mode=one_shot sample=kick_vl1_rr2.wav seq_length=4 seq_position=2\n" |
| 612 |
"<region>\n" |
| 613 |
"amp_velcurve_31=1 hivel=31 key=36 loop_mode=one_shot sample=kick_vl1_rr3.wav seq_length=4 seq_position=3\n" |
| 614 |
"<region>\n" |
| 615 |
"amp_velcurve_31=1 hivel=31 key=36 loop_mode=one_shot sample=kick_vl1_rr4.wav seq_length=4 seq_position=4\n" |
| 616 |
"<region>\n" |
| 617 |
"amp_velcurve_63=1 hivel=63 key=36 loop_mode=one_shot lovel=32 sample=kick_vl2_rr1.wav seq_length=4 seq_position=1\n" |
| 618 |
"<region>\n" |
| 619 |
"amp_velcurve_63=1 hivel=63 key=36 loop_mode=one_shot lovel=32 sample=kick_vl2_rr2.wav seq_length=4 seq_position=2\n" |
| 620 |
"<region>\n" |
| 621 |
"amp_velcurve_63=1 hivel=63 key=36 loop_mode=one_shot lovel=32 sample=kick_vl2_rr3.wav seq_length=4 seq_position=3\n" |
| 622 |
"<region>\n" |
| 623 |
"amp_velcurve_63=1 hivel=63 key=36 loop_mode=one_shot lovel=32 sample=kick_vl2_rr4.wav seq_length=4 seq_position=4\n" |
| 624 |
"<region>\n" |
| 625 |
"amp_velcurve_95=1 hivel=95 key=36 loop_mode=one_shot lovel=64 sample=kick_vl3_rr1.wav seq_length=4 seq_position=1\n" |
| 626 |
"<region>\n" |
| 627 |
"amp_velcurve_95=1 hivel=95 key=36 loop_mode=one_shot lovel=64 sample=kick_vl3_rr2.wav seq_length=4 seq_position=2\n" |
| 628 |
"<region>\n" |
| 629 |
"amp_velcurve_95=1 hivel=95 key=36 loop_mode=one_shot lovel=64 sample=kick_vl3_rr3.wav seq_length=4 seq_position=3\n" |
| 630 |
"<region>\n" |
| 631 |
"amp_velcurve_95=1 hivel=95 key=36 loop_mode=one_shot lovel=64 sample=kick_vl3_rr4.wav seq_length=4 seq_position=4\n" |
| 632 |
"<region>\n" |
| 633 |
"key=36 loop_mode=one_shot lovel=96 sample=kick_vl4_rr1.wav seq_length=3 seq_position=1\n" |
| 634 |
"<region>\n" |
| 635 |
"key=36 loop_mode=one_shot lovel=96 sample=kick_vl4_rr2.wav seq_length=3 seq_position=2\n" |
| 636 |
"<region>\n" |
| 637 |
"key=36 loop_mode=one_shot lovel=96 sample=kick_vl4_rr3.wav seq_length=3 seq_position=3\n" |
| 638 |
"// end\n"; |
| 639 |
|
| 640 |
io::Path path; |
| 641 |
UTEST_ASSERT(path.fmt("%s/fmt/sfz/example.sfz", resources()) > 0); |
| 642 |
|
| 643 |
printf("Checking read of the file %s...\n", path.get()); |
| 644 |
|
| 645 |
SFZHandler handler; |
| 646 |
sfz::DocumentProcessor processor; |
| 647 |
UTEST_ASSERT(processor.open(&path) == STATUS_OK); |
| 648 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OK); |
| 649 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 650 |
|
| 651 |
const char *processed = handler.data()->get_utf8(); |
| 652 |
|
| 653 |
printf("Processed document:\n%s\n", processed); |
| 654 |
if (strcmp(processed, expected) != 0) |
| 655 |
UTEST_FAIL_MSG("Expected document:\n%s\n", expected); |
| 656 |
} |
| 657 |
|
| 658 |
void check_invalid_include() |
| 659 |
{ |
| 660 |
static const char *data1 = |
| 661 |
"<master>\n" |
| 662 |
"<group> key=38\n" |
| 663 |
"<region>\n" |
| 664 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 665 |
"<region>\n" |
| 666 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 667 |
"#include \"\"" |
| 668 |
"<group> key=39\n" |
| 669 |
"<region>\n" |
| 670 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 671 |
"<region>\n" |
| 672 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 673 |
"\n"; |
| 674 |
|
| 675 |
printf("Checking invalid file includes...\n"); |
| 676 |
|
| 677 |
SFZHandler handler; |
| 678 |
sfz::DocumentProcessor processor; |
| 679 |
UTEST_ASSERT(processor.wrap(data1) == STATUS_OK); |
| 680 |
UTEST_ASSERT(processor.process(&handler) == STATUS_NOT_FOUND); |
| 681 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 682 |
} |
| 683 |
|
| 684 |
void check_recursive_include_root() |
| 685 |
{ |
| 686 |
static const char *data1 = |
| 687 |
"<master>\n" |
| 688 |
"<group> key=38\n" |
| 689 |
"<region>\n" |
| 690 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 691 |
"<region>\n" |
| 692 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 693 |
"#include \"test.sfz\"" |
| 694 |
"<group> key=39\n" |
| 695 |
"<region>\n" |
| 696 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 697 |
"<region>\n" |
| 698 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 699 |
"\n"; |
| 700 |
|
| 701 |
printf("Checking recursive include of the root file...\n"); |
| 702 |
|
| 703 |
SFZHandler handler; |
| 704 |
sfz::DocumentProcessor processor; |
| 705 |
UTEST_ASSERT(processor.wrap(data1) == STATUS_OK); |
| 706 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OVERFLOW); |
| 707 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 708 |
} |
| 709 |
|
| 710 |
void check_recursive_include_loop() |
| 711 |
{ |
| 712 |
static const char *file0 = |
| 713 |
"<master>\n" |
| 714 |
"<group> key=38\n" |
| 715 |
"<region>\n" |
| 716 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 717 |
"<region>\n" |
| 718 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 719 |
"#include \"file1.sfz\"" |
| 720 |
"<group> key=39\n" |
| 721 |
"<region>\n" |
| 722 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 723 |
"<region>\n" |
| 724 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 725 |
"\n"; |
| 726 |
|
| 727 |
static const char *file1 = |
| 728 |
"<master>\n" |
| 729 |
"<group> key=40\n" |
| 730 |
"<region>\n" |
| 731 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 732 |
"<region>\n" |
| 733 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 734 |
"#include \"file2.sfz\"" |
| 735 |
"<group> key=41\n" |
| 736 |
"<region>\n" |
| 737 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 738 |
"<region>\n" |
| 739 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 740 |
"\n"; |
| 741 |
|
| 742 |
static const char *file2 = |
| 743 |
"<master>\n" |
| 744 |
"<group> key=42\n" |
| 745 |
"<region>\n" |
| 746 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 747 |
"<region>\n" |
| 748 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 749 |
"#include \"file3.sfz\"" |
| 750 |
"<group> key=43\n" |
| 751 |
"<region>\n" |
| 752 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 753 |
"<region>\n" |
| 754 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 755 |
"\n"; |
| 756 |
|
| 757 |
static const char *file3 = |
| 758 |
"<master>\n" |
| 759 |
"<group> key=44\n" |
| 760 |
"<region>\n" |
| 761 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr1.wav hirand=0.250\n" |
| 762 |
"<region>\n" |
| 763 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr2.wav lorand=0.250 hirand=0.500\n" |
| 764 |
"#include \"file1.sfz\"" |
| 765 |
"<group> key=45\n" |
| 766 |
"<region>\n" |
| 767 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr3.wav lorand=0.500 hirand=0.750\n" |
| 768 |
"<region>\n" |
| 769 |
"sample=../Samples/bobobo/bobobo_bass_vl1_rr4.wav lorand=0.750\n" |
| 770 |
"\n"; |
| 771 |
|
| 772 |
printf("Checking recursive include loop...\n"); |
| 773 |
|
| 774 |
SFZHandler handler; |
| 775 |
handler.add_file("file1.sfz", file1); |
| 776 |
handler.add_file("file2.sfz", file2); |
| 777 |
handler.add_file("file3.sfz", file3); |
| 778 |
|
| 779 |
sfz::DocumentProcessor processor; |
| 780 |
UTEST_ASSERT(processor.wrap(file0) == STATUS_OK); |
| 781 |
UTEST_ASSERT(processor.process(&handler) == STATUS_OVERFLOW); |
| 782 |
UTEST_ASSERT(processor.close() == STATUS_OK); |
| 783 |
} |
| 784 |
|
| 785 |
|
| 786 |
UTEST_MAIN |
| 787 |
{ |
| 788 |
check_namespaces_simple(); |
| 789 |
check_namespaces_overrides(); |
| 790 |
check_includes_and_defines(); |
| 791 |
check_multiple_vars(); |
| 792 |
check_other_headers(); |
| 793 |
check_read_file(); |
| 794 |
check_invalid_include(); |
| 795 |
check_recursive_include_root(); |
| 796 |
check_recursive_include_loop(); |
| 797 |
} |
| 798 |
|
| 799 |
UTEST_END |
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|