equal
deleted
inserted
replaced
274 while (presets_splits_mod.size() < modcount) |
274 while (presets_splits_mod.size() < modcount) |
275 presets_splits_mod.add(null); |
275 presets_splits_mod.add(null); |
276 count--; |
276 count--; |
277 } |
277 } |
278 |
278 |
|
279 if (presets_bagNdx.isEmpty()) { |
|
280 throw new RIFFInvalidDataException(); |
|
281 } |
279 int offset = presets_bagNdx.get(0); |
282 int offset = presets_bagNdx.get(0); |
280 // Offset should be 0 (but just case) |
283 // Offset should be 0 (but just case) |
281 for (int i = 0; i < offset; i++) { |
284 for (int i = 0; i < offset; i++) { |
282 if (count == 0) |
285 if (count == 0) |
283 throw new RIFFInvalidDataException(); |
286 throw new RIFFInvalidDataException(); |
358 while (instruments_splits_mod.size() < modcount) |
361 while (instruments_splits_mod.size() < modcount) |
359 instruments_splits_mod.add(null); |
362 instruments_splits_mod.add(null); |
360 count--; |
363 count--; |
361 } |
364 } |
362 |
365 |
|
366 if (instruments_bagNdx.isEmpty()) { |
|
367 throw new RIFFInvalidDataException(); |
|
368 } |
363 int offset = instruments_bagNdx.get(0); |
369 int offset = instruments_bagNdx.get(0); |
364 // Offset should be 0 (but just case) |
370 // Offset should be 0 (but just case) |
365 for (int i = 0; i < offset; i++) { |
371 for (int i = 0; i < offset; i++) { |
366 if (count == 0) |
372 if (count == 0) |
367 throw new RIFFInvalidDataException(); |
373 throw new RIFFInvalidDataException(); |
399 modulator.sourceOperator = chunk.readUnsignedShort(); |
405 modulator.sourceOperator = chunk.readUnsignedShort(); |
400 modulator.destinationOperator = chunk.readUnsignedShort(); |
406 modulator.destinationOperator = chunk.readUnsignedShort(); |
401 modulator.amount = chunk.readShort(); |
407 modulator.amount = chunk.readShort(); |
402 modulator.amountSourceOperator = chunk.readUnsignedShort(); |
408 modulator.amountSourceOperator = chunk.readUnsignedShort(); |
403 modulator.transportOperator = chunk.readUnsignedShort(); |
409 modulator.transportOperator = chunk.readUnsignedShort(); |
|
410 if (i < 0 || i >= instruments_splits_gen.size()) { |
|
411 throw new RIFFInvalidDataException(); |
|
412 } |
404 SF2LayerRegion split = instruments_splits_gen.get(i); |
413 SF2LayerRegion split = instruments_splits_gen.get(i); |
405 if (split != null) |
414 if (split != null) |
406 split.modulators.add(modulator); |
415 split.modulators.add(modulator); |
407 } |
416 } |
408 } else if (format.equals("igen")) { |
417 } else if (format.equals("igen")) { |
422 for (int i = 0; i < count; i++) { |
431 for (int i = 0; i < count; i++) { |
423 SF2Sample sample = new SF2Sample(this); |
432 SF2Sample sample = new SF2Sample(this); |
424 sample.name = chunk.readString(20); |
433 sample.name = chunk.readString(20); |
425 long start = chunk.readUnsignedInt(); |
434 long start = chunk.readUnsignedInt(); |
426 long end = chunk.readUnsignedInt(); |
435 long end = chunk.readUnsignedInt(); |
427 sample.data = sampleData.subbuffer(start * 2, end * 2, true); |
436 if (sampleData != null) |
|
437 sample.data = sampleData.subbuffer(start * 2, end * 2, true); |
428 if (sampleData24 != null) |
438 if (sampleData24 != null) |
429 sample.data24 = sampleData24.subbuffer(start, end, true); |
439 sample.data24 = sampleData24.subbuffer(start, end, true); |
430 /* |
440 /* |
431 sample.data = new ModelByteBuffer(sampleData, (int)(start*2), |
441 sample.data = new ModelByteBuffer(sampleData, (int)(start*2), |
432 (int)((end - start)*2)); |
442 (int)((end - start)*2)); |
460 SF2LayerRegion split = siter.next(); |
470 SF2LayerRegion split = siter.next(); |
461 if (split.generators.get(SF2LayerRegion.GENERATOR_SAMPLEID) != null) { |
471 if (split.generators.get(SF2LayerRegion.GENERATOR_SAMPLEID) != null) { |
462 int sampleid = split.generators.get( |
472 int sampleid = split.generators.get( |
463 SF2LayerRegion.GENERATOR_SAMPLEID); |
473 SF2LayerRegion.GENERATOR_SAMPLEID); |
464 split.generators.remove(SF2LayerRegion.GENERATOR_SAMPLEID); |
474 split.generators.remove(SF2LayerRegion.GENERATOR_SAMPLEID); |
|
475 if (sampleid < 0 || sampleid >= samples.size()) { |
|
476 throw new RIFFInvalidDataException(); |
|
477 } |
465 split.sample = samples.get(sampleid); |
478 split.sample = samples.get(sampleid); |
466 } else { |
479 } else { |
467 globalsplit = split; |
480 globalsplit = split; |
468 } |
481 } |
469 } |
482 } |
486 SF2InstrumentRegion split = siter.next(); |
499 SF2InstrumentRegion split = siter.next(); |
487 if (split.generators.get(SF2LayerRegion.GENERATOR_INSTRUMENT) != null) { |
500 if (split.generators.get(SF2LayerRegion.GENERATOR_INSTRUMENT) != null) { |
488 int instrumentid = split.generators.get( |
501 int instrumentid = split.generators.get( |
489 SF2InstrumentRegion.GENERATOR_INSTRUMENT); |
502 SF2InstrumentRegion.GENERATOR_INSTRUMENT); |
490 split.generators.remove(SF2LayerRegion.GENERATOR_INSTRUMENT); |
503 split.generators.remove(SF2LayerRegion.GENERATOR_INSTRUMENT); |
|
504 if (instrumentid < 0 || instrumentid >= layers.size()) { |
|
505 throw new RIFFInvalidDataException(); |
|
506 } |
491 split.layer = layers.get(instrumentid); |
507 split.layer = layers.get(instrumentid); |
492 } else { |
508 } else { |
493 globalsplit = split; |
509 globalsplit = split; |
494 } |
510 } |
495 } |
511 } |