summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/ptformat/ptfformat.cc78
-rw-r--r--libs/ptformat/ptfformat.h1
2 files changed, 75 insertions, 4 deletions
diff --git a/libs/ptformat/ptfformat.cc b/libs/ptformat/ptfformat.cc
index 8a2f0f2c23..3004ef2c0a 100644
--- a/libs/ptformat/ptfformat.cc
+++ b/libs/ptformat/ptfformat.cc
@@ -111,17 +111,16 @@ PTFFormat::load(std::string path, int64_t targetsr) {
xor_type = ptfunxored[0x12];
xor_value = ptfunxored[0x13];
+ xor_len = 256;
// xor_type 0x01 = ProTools 5, 6, 7, 8 and 9
// xor_type 0x05 = ProTools 10, 11, 12
switch(xor_type) {
case 0x01:
xor_delta = gen_xor_delta(xor_value, 53, false);
- xor_len = 256;
break;
case 0x05:
xor_delta = gen_xor_delta(xor_value, 11, true);
- xor_len = 128;
break;
default:
fclose(fp);
@@ -138,7 +137,7 @@ PTFFormat::load(std::string path, int64_t targetsr) {
i = 0x14;
fseek(fp, i, SEEK_SET);
while (fread(&ct, 1, 1, fp) != 0) {
- uint8_t xor_index = (xor_type == 0x01) ? i & 0xff : (i >> 12) & 0x7f;
+ uint8_t xor_index = (xor_type == 0x01) ? i & 0xff : (i >> 12) & 0xff;
ptfunxored[i++] = ct ^ xxor[xor_index];
}
fclose(fp);
@@ -278,7 +277,7 @@ PTFFormat::parse(void) {
setrates();
if (sessionrate < 44100 || sessionrate > 192000)
return -1;
- parseaudio();
+ parseaudio10();
parserest10();
parsemidi();
} else {
@@ -796,6 +795,77 @@ PTFFormat::parsemidi(void) {
}
void
+PTFFormat::parseaudio10(void) {
+ uint64_t i,j,k,l;
+ uint8_t charlen;
+
+ // Find end of wav file list
+ k = 0;
+ while (k < len) {
+ if ( (ptfunxored[k ] == 0xff) &&
+ (ptfunxored[k+1] == 0xff) &&
+ (ptfunxored[k+2] == 0xff) &&
+ (ptfunxored[k+3] == 0xff)) {
+ break;
+ }
+ k++;
+ }
+
+ // Find actual wav names
+ uint16_t numberofwavs = 0;
+ uint16_t n = 0;
+ char wavname[256];
+ for (i = k; i > 2; i--) {
+ if ( (ptfunxored[i ] == 0x01) &&
+ (ptfunxored[i-1] == 0x5a)) {
+
+ numberofwavs = 0;
+ numberofwavs |= (uint32_t)(ptfunxored[i-2] << 24);
+ numberofwavs |= (uint32_t)(ptfunxored[i-3] << 16);
+ numberofwavs |= (uint32_t)(ptfunxored[i-4] << 8);
+ numberofwavs |= (uint32_t)(ptfunxored[i-5]);
+ break;
+ }
+ }
+ if (numberofwavs == 0)
+ return;
+
+ // Skip over "Audio Files"
+ j = i + 17;
+ charlen = ptfunxored[j];
+ j += 4;
+ j += charlen + 9;
+
+ // Get wav filenames
+ while (n < numberofwavs) {
+ charlen = ptfunxored[j];
+ j += 4;
+ l = 0;
+ while (l < charlen) {
+ wavname[l] = ptfunxored[j];
+ l++;
+ j++;
+ }
+ j += 9;
+ wavname[l] = 0;
+ std::string wave = string(wavname);
+ wav_t f = { wave, n, 0, 0 };
+
+ if (foundin(wave, string(".grp"))) {
+ continue;
+ }
+
+ if (foundin(wavname, ".wav")) {
+ extension = string(".wav");
+ } else if (foundin(wavname, ".aif")) {
+ extension = string(".aif");
+ }
+ actualwavs.push_back(f);
+ n++;
+ }
+}
+
+void
PTFFormat::parseaudio(void) {
uint64_t i,j,k,l;
diff --git a/libs/ptformat/ptfformat.h b/libs/ptformat/ptfformat.h
index e5f4ed94bd..7a3eb40d37 100644
--- a/libs/ptformat/ptfformat.h
+++ b/libs/ptformat/ptfformat.h
@@ -141,6 +141,7 @@ private:
void parserest89(void);
void parserest10(void);
void parseaudio5(void);
+ void parseaudio10(void);
void parseaudio(void);
void parsemidi(void);
void resort(std::vector<wav_t>& ws);