diff options
author | Damien Zammit <damien@zamaudio.com> | 2015-08-08 22:43:09 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2015-08-08 22:43:09 +1000 |
commit | 57be0538eb85c8c8c5ea4551f3da0c9e86458518 (patch) | |
tree | 152e76de2b5cdf5dfcc6145394f591f503c4452c | |
parent | 042b40b07b548a6e32abe788eb6736535d465ccb (diff) |
Added PT5 support
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r-- | ptfformat.cc | 39 | ||||
-rw-r--r-- | ptfformat.h | 9 |
2 files changed, 32 insertions, 16 deletions
diff --git a/ptfformat.cc b/ptfformat.cc index 9befc07..dc3846e 100644 --- a/ptfformat.cc +++ b/ptfformat.cc @@ -472,7 +472,6 @@ PTFFormat::parserest5(void) { k++; rindex = 0; - tracknumber = 0; while (k < len) { if ( (ptfunxored[k ] == 0xff) && (ptfunxored[k+1] == 0xff)) { @@ -488,7 +487,7 @@ PTFFormat::parserest5(void) { } lengthofname = ptfunxored[k+12]; - if (lengthofname <= 4 && ptfunxored[k+13] == 0x5a) { + if (ptfunxored[k+13] == 0x5a) { k++; break; } @@ -562,7 +561,7 @@ PTFFormat::parserest5(void) { } j+=offsetbytes; - //printf("name=`%s` start=%04x length=%04x offset=%04x findex=%d\n", name,start,length,sampleoffset,findex); + printf("name=`%s` start=%04x length=%04x offset=%04x findex=%d\n", name,start,length,sampleoffset,findex); std::string filename = string(name) + extension; wav_t f = { @@ -572,25 +571,33 @@ PTFFormat::parserest5(void) { (int64_t)(length*ratefactor), }; - vector<wav_t>::iterator begin = actualwavs.begin(); - vector<wav_t>::iterator finish = actualwavs.end(); + vector<wav_t>::iterator begin = audiofiles.begin(); + vector<wav_t>::iterator finish = audiofiles.end(); vector<wav_t>::iterator found; - // Add file to list only if it is an actual wav + // Add file to list only if isn't found before if ((found = std::find(begin, finish, f)) != finish) { - audiofiles.push_back(f); - // Also add plain wav as region + if (foundin(filename, string(".grp"))) { + continue; + } region_t r = { "", rindex, (int64_t)(start*ratefactor), (int64_t)(sampleoffset*ratefactor), (int64_t)(length*ratefactor), - f + *found, }; regions.push_back(r); - actualwavs.erase(found); - // Region only + track_t tr = { + name, + (uint16_t)tracknumber, + uint8_t(0), + r + }; + tracks.push_back(tr); + tracknumber++; } else { + audiofiles.push_back(f); if (foundin(filename, string(".grp"))) { continue; } @@ -600,9 +607,17 @@ PTFFormat::parserest5(void) { (int64_t)(start*ratefactor), (int64_t)(sampleoffset*ratefactor), (int64_t)(length*ratefactor), - f + f, }; regions.push_back(r); + track_t tr = { + name, + (uint16_t)tracknumber, + uint8_t(0), + r + }; + tracks.push_back(tr); + tracknumber++; } rindex++; k++; diff --git a/ptfformat.h b/ptfformat.h index a4d5685..d57e8b1 100644 --- a/ptfformat.h +++ b/ptfformat.h @@ -38,7 +38,8 @@ public: int64_t length; bool operator ==(const struct wav& other) { - return (this->index == other.index); + return (this->filename != std::string("") && + this->index == other.index); } } wav_t; @@ -63,7 +64,7 @@ public: region_t reg; bool operator ==(const struct track& other) { - return (this->index == other.index); + return (this->name == other.name); } } track_t; @@ -71,14 +72,14 @@ public: std::vector<region_t> regions; std::vector<track_t> tracks; - static bool trackexistsin(std::vector<track_t> tr, uint16_t index) { + static bool trackexistsin(std::vector<track_t> tr, std::string name) { std::vector<track_t>::iterator begin = tr.begin(); std::vector<track_t>::iterator finish = tr.end(); std::vector<track_t>::iterator found; wav_t w = { std::string(""), 0, 0, 0 }; region_t r = { std::string(""), 0, 0, 0, 0, w }; - track_t f = { std::string(""), index, 0, r }; + track_t f = { name, 0, 0, r }; if ((found = std::find(begin, finish, f)) != finish) { return true; |