diff options
author | Damien Zammit <damien@zamaudio.com> | 2016-02-02 16:11:56 +1100 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2016-02-02 16:11:56 +1100 |
commit | 1a7db628dbf51fa75535f002f65c29b11ecb038d (patch) | |
tree | ce0b7dec6135e801b8db115a29ffb34f44eca1a5 | |
parent | ce73a29c90fc8922a1a17c620f5a6b2577453df6 (diff) |
Sort PT5 wavs before passing to region parser.
Fixes bug with confused naming.
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r-- | ptfformat.cc | 28 | ||||
-rw-r--r-- | ptfformat.h | 7 |
2 files changed, 32 insertions, 3 deletions
diff --git a/ptfformat.cc b/ptfformat.cc index bed4bad..2f0d672 100644 --- a/ptfformat.cc +++ b/ptfformat.cc @@ -631,6 +631,17 @@ PTFFormat::parserest5(void) { } void +PTFFormat::resort(std::vector<wav_t> *ws) { + int j = 0; + std::sort((*ws).begin(), (*ws).end()); + for (std::vector<wav_t>::iterator i = (*ws).begin(); + i != (*ws).end(); ++i) { + (*i).index = j; + j++; + } +} + +void PTFFormat::parseaudio5(void) { int i,k,l; int lengthofname, wavnumber; @@ -670,6 +681,7 @@ PTFFormat::parseaudio5(void) { wavnumber = 0; i+=16; + char ext[5]; while (i < len && numberofwavs > 0) { i++; if ( (ptfunxored[i ] == 0x5a) && @@ -684,11 +696,19 @@ PTFFormat::parseaudio5(void) { wavname[l] = ptfunxored[i+l]; l++; } - i+=lengthofname + 4; + i+=lengthofname; + ext[0] = ptfunxored[i++]; + ext[1] = ptfunxored[i++]; + ext[2] = ptfunxored[i++]; + ext[3] = ptfunxored[i++]; + ext[4] = '\0'; + wavname[l] = 0; - if (foundin(wavname, ".wav")) { + if (foundin(wavname, ".L") || foundin(wavname, ".R")) { + extension = string(""); + } else if (foundin(wavname, ".wav") || foundin(ext, "WAVE")) { extension = string(".wav"); - } else if (foundin(wavname, ".aif")) { + } else if (foundin(wavname, ".aif") || foundin(ext, "AIFF")) { extension = string(".aif"); } else { extension = string(""); @@ -707,6 +727,8 @@ PTFFormat::parseaudio5(void) { numberofwavs--; i += 7; } + resort(&actualwavs); + resort(&audiofiles); } void diff --git a/ptfformat.h b/ptfformat.h index ff21191..621bd45 100644 --- a/ptfformat.h +++ b/ptfformat.h @@ -16,6 +16,7 @@ #define PTFFORMAT_H #include <string> +#include <cstring> #include <algorithm> #include <vector> #include <stdint.h> @@ -37,6 +38,11 @@ public: int64_t posabsolute; int64_t length; + bool operator <(const struct wav& other) { + return (strcmp(this->filename.c_str(), + other.filename.c_str()) < 0); + } + bool operator ==(const struct wav& other) { return (this->filename == other.filename || this->index == other.index); @@ -123,6 +129,7 @@ private: void parserest10(void); void parseaudio5(void); void parseaudio(void); + void resort(std::vector<wav_t> *ws); std::vector<wav_t> actualwavs; float ratefactor; std::string extension; |