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_t& other) const {
43 return (strcasecmp(this->filename.c_str(),
44 other.filename.c_str()) < 0);
47 bool operator ==(const struct wav_t& 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 {
73 bool operator ==(const struct track& other) {
74 return (this->name == other.name);
78 std::vector<wav_t> audiofiles;
79 std::vector<region_t> regions;
80 std::vector<track_t> tracks;
82 static bool regionexistsin(std::vector<region_t> reg, uint16_t index) {
83 std::vector<region_t>::iterator begin = reg.begin();
84 std::vector<region_t>::iterator finish = reg.end();
85 std::vector<region_t>::iterator found;
87 wav_t w = { std::string(""), 0, 0, 0 };
88 region_t r = { std::string(""), index, 0, 0, 0, w };
90 if ((found = std::find(begin, finish, r)) != finish) {
96 static bool wavexistsin(std::vector<wav_t> wv, uint16_t index) {
97 std::vector<wav_t>::iterator begin = wv.begin();
98 std::vector<wav_t>::iterator finish = wv.end();
99 std::vector<wav_t>::iterator found;
101 wav_t w = { std::string(""), index, 0, 0 };
103 if ((found = std::find(begin, finish, w)) != finish) {
115 unsigned char *ptfunxored;
119 bool foundin(std::string haystack, std::string needle);
123 void parse5header(void);
124 void parse7header(void);
125 void parse8header(void);
126 void parse9header(void);
127 void parse10header(void);
128 void parserest5(void);
129 void parserest89(void);
130 void parserest10(void);
131 void parseaudio5(void);
132 void parseaudio(void);
133 void resort(std::vector<wav_t>& ws);
134 uint8_t mostfrequent(uint32_t start, uint32_t stop);
135 std::vector<wav_t> actualwavs;
137 std::string extension;
138 unsigned char key10a;
139 unsigned char key10b;