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) {
43 return (this->filename == other.filename ||
44 this->index == other.index);
49 typedef struct region {
57 bool operator ==(const struct region& other) {
58 return (this->index == other.index);
62 typedef struct track {
68 bool operator ==(const struct track& other) {
69 return (this->name == other.name);
73 std::vector<wav_t> audiofiles;
74 std::vector<region_t> regions;
75 std::vector<track_t> tracks;
77 static bool regionexistsin(std::vector<region_t> reg, uint16_t index) {
78 std::vector<region_t>::iterator begin = reg.begin();
79 std::vector<region_t>::iterator finish = reg.end();
80 std::vector<region_t>::iterator found;
82 wav_t w = { std::string(""), 0, 0, 0 };
83 region_t r = { std::string(""), index, 0, 0, 0, w };
85 if ((found = std::find(begin, finish, r)) != finish) {
91 static bool wavexistsin(std::vector<wav_t> wv, uint16_t index) {
92 std::vector<wav_t>::iterator begin = wv.begin();
93 std::vector<wav_t>::iterator finish = wv.end();
94 std::vector<wav_t>::iterator found;
96 wav_t w = { std::string(""), index, 0, 0 };
98 if ((found = std::find(begin, finish, w)) != finish) {
110 unsigned char *ptfunxored;
114 bool foundin(std::string haystack, std::string needle);
118 void parse5header(void);
119 void parse7header(void);
120 void parse8header(void);
121 void parse9header(void);
122 void parse10header(void);
123 void parserest5(void);
124 void parserest89(void);
125 void parserest10(void);
126 void parseaudio5(void);
127 void parseaudio(void);
128 std::vector<wav_t> actualwavs;
130 std::string extension;
131 unsigned char key10a;
132 unsigned char key10b;