2 Copyright (C) 2015 Damien Zammit
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
23 #include "ptformat/visibility.h"
25 class LIBPTFORMAT_API PTFFormat {
30 /* Return values: 0 success
31 -1 could not open file as ptf
33 int load(std::string path, int64_t targetsr);
42 bool operator <(const struct wav& other) const {
43 return (strcasecmp(this->filename.c_str(),
44 other.filename.c_str()) < 0);
47 bool operator ==(const struct wav& other) const {
48 return (this->filename == other.filename ||
49 this->index == other.index);
54 typedef struct region {
62 bool operator ==(const struct region& other) {
63 return (this->index == other.index);
67 typedef struct track {
72 memset ((void*)®, 0, sizeof(region_t));
75 track (std::string n, uint16_t i, uint8_t p, region_t *r)
83 void set_region (region_t *r) {
84 memcpy ((void*)®, (void*)r, sizeof(region_t));
92 bool operator ==(const struct track& other) {
93 return (this->name == other.name);
97 std::vector<wav_t> audiofiles;
98 std::vector<region_t> regions;
99 std::vector<track_t> tracks;
101 static bool regionexistsin(std::vector<region_t> reg, uint16_t index) {
102 std::vector<region_t>::iterator begin = reg.begin();
103 std::vector<region_t>::iterator finish = reg.end();
104 std::vector<region_t>::iterator found;
106 wav_t w = { std::string(""), 0, 0, 0 };
107 region_t r = { std::string(""), index, 0, 0, 0, w };
109 if ((found = std::find(begin, finish, r)) != finish) {
115 static bool wavexistsin(std::vector<wav_t> wv, uint16_t index) {
116 std::vector<wav_t>::iterator begin = wv.begin();
117 std::vector<wav_t>::iterator finish = wv.end();
118 std::vector<wav_t>::iterator found;
120 wav_t w = { std::string(""), index, 0, 0 };
122 if ((found = std::find(begin, finish, w)) != finish) {
134 unsigned char *ptfunxored;
138 bool foundin(std::string haystack, std::string needle);
142 void parse5header(void);
143 void parse7header(void);
144 void parse8header(void);
145 void parse9header(void);
146 void parse10header(void);
147 void parserest5(void);
148 void parserest89(void);
149 void parserest10(void);
150 void parseaudio5(void);
151 void parseaudio(void);
152 void resort(std::vector<wav_t> *ws);
153 uint8_t mostfrequent(uint32_t start, uint32_t stop);
154 std::vector<wav_t> actualwavs;
156 std::string extension;
157 unsigned char key10a;
158 unsigned char key10b;