diff options
author | Damien Zammit <damien@zamaudio.com> | 2019-06-18 21:22:45 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2019-06-18 21:25:35 +1000 |
commit | 9526adc184f4beb627038eb2dfb86d6a08ea0f78 (patch) | |
tree | 1519888ed1687a612287f45974f5b327fd4dd84f | |
parent | 77b42b442e897b7befb27edbcd607f04edcf4f1c (diff) |
Fix broken MIDI support for >= pt10
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | ptfformat.cc | 26 | ||||
-rw-r--r-- | tests.sh | 6 | ||||
-rwxr-xr-x | tests/t.12/basicmidi | 2 |
4 files changed, 22 insertions, 13 deletions
@@ -68,7 +68,6 @@ License TODO ==== -- Fix >= PT10 MIDI support - Add >= PT10 Compound MIDI/Audio region support diff --git a/ptfformat.cc b/ptfformat.cc index 5bd0e8f..669a801 100644 --- a/ptfformat.cc +++ b/ptfformat.cc @@ -883,7 +883,7 @@ bool PTFFormat::parserest(void) { uint32_t i, j, count; uint64_t start; - uint16_t rindex, rawindex, tindex; + uint16_t rindex, rawindex, tindex, mindex; uint32_t nch; uint16_t ch_map[MAX_CHANNELS_PER_TRACK]; bool found = false; @@ -957,8 +957,15 @@ PTFFormat::parserest(void) { } } } - } else if (b->content_type == 0x2519) { + } + } + + // Reparse from scratch to exclude audio tracks from all tracks to get midi tracks + for (vector<PTFFormat::block_t>::iterator b = blocks.begin(); + b != blocks.end(); ++b) { + if (b->content_type == 0x2519) { tindex = 0; + mindex = 0; //ntracks = u_endian_read4(&ptfunxored[b->offset+2], is_bigendian); for (vector<PTFFormat::block_t>::iterator c = b->child.begin(); c != b->child.end(); ++c) { @@ -978,11 +985,16 @@ PTFFormat::parserest(void) { track_t t = { trackname, - tindex, + mindex, uint8_t(0), r }; - miditracks.push_back(t); + + // If the current track is not an audio track, insert as midi track + if (!(find_track(tindex, ti) && foundin(trackname, (*ti).name))) { + miditracks.push_back(t); + mindex++; + } tindex++; } } @@ -1156,13 +1168,13 @@ PTFFormat::parsemidi(void) { } // Put chunks onto regions - } else if (b->content_type == 0x2002) { + } else if ((b->content_type == 0x2002) || (b->content_type == 0x2634)) { for (vector<PTFFormat::block_t>::iterator c = b->child.begin(); c != b->child.end(); ++c) { - if (c->content_type == 0x2001) { + if ((c->content_type == 0x2001) || (c->content_type == 0x2633)) { for (vector<PTFFormat::block_t>::iterator d = c->child.begin(); d != c->child.end(); ++d) { - if (d->content_type == 0x1007) { + if ((d->content_type == 0x1007) || (d->content_type == 0x2628)) { j = d->offset + 2; str = parsestring(j); midiregionname = std::string(str); @@ -2,8 +2,6 @@ DIFF=diff PTFTOOL=../../ptftool -FAIL=$(if [ "x$BROKEN" == "x1" ]; then echo "BROKEN"; else echo "FAIL"; fi) -FAILRET=$(if [ "x$BROKEN" == "x1" ]; then echo 0; else echo 1; fi) run_test() { echo "$NAME" @@ -22,8 +20,8 @@ run_test() { exit 0 else echo "$DIFFED" - echo "[$FAIL]" + echo "[FAIL]" echo "" - exit $FAILRET + exit 1 fi } diff --git a/tests/t.12/basicmidi b/tests/t.12/basicmidi index c6884d4..bea3744 100755 --- a/tests/t.12/basicmidi +++ b/tests/t.12/basicmidi @@ -1,6 +1,6 @@ #!/bin/bash -[ -e ../../tests.sh ] && BROKEN=1 . ../../tests.sh +[ -e ../../tests.sh ] && . ../../tests.sh NAME="PT12 with midi" FILE=../../bins/TestPTX.ptx |