2 * libptformat - a library to read ProTools sessions
4 * Copyright (C) 2015 Damien Zammit
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "ptformat/visibility.h"
31 class LIBPTFORMAT_API PTFFormat {
36 /* Return values: 0 success
37 -1 could not parse pt session
39 int load(std::string path, int64_t targetsr);
41 /* Return values: 0 success
42 -1 could not decrypt pt session
44 int unxor(std::string path);
53 bool operator <(const struct wav_t& other) const {
54 return (strcasecmp(this->filename.c_str(),
55 other.filename.c_str()) < 0);
58 bool operator ==(const struct wav_t& other) const {
59 return (this->filename == other.filename ||
60 this->index == other.index);
72 typedef struct region {
79 std::vector<midi_ev_t> midi;
81 bool operator ==(const struct region& other) {
82 return (this->index == other.index);
85 bool operator <(const struct region& other) const {
86 return (strcasecmp(this->name.c_str(),
87 other.name.c_str()) < 0);
91 typedef struct compound {
95 uint16_t ontopof_index;
100 typedef struct track {
106 bool operator ==(const struct track& other) {
107 return (this->name == other.name);
111 std::vector<wav_t> audiofiles;
112 std::vector<region_t> regions;
113 std::vector<region_t> midiregions;
114 std::vector<compound_t> compounds;
115 std::vector<track_t> tracks;
116 std::vector<track_t> miditracks;
118 static bool regionexistsin(std::vector<region_t> reg, uint16_t index) {
119 std::vector<region_t>::iterator begin = reg.begin();
120 std::vector<region_t>::iterator finish = reg.end();
121 std::vector<region_t>::iterator found;
123 wav_t w = { std::string(""), 0, 0, 0 };
124 std::vector<midi_ev_t> m;
125 region_t r = { std::string(""), index, 0, 0, 0, w, m};
127 if ((found = std::find(begin, finish, r)) != finish) {
133 static bool wavexistsin(std::vector<wav_t> wv, uint16_t index) {
134 std::vector<wav_t>::iterator begin = wv.begin();
135 std::vector<wav_t>::iterator finish = wv.end();
136 std::vector<wav_t>::iterator found;
138 wav_t w = { std::string(""), index, 0, 0 };
140 if ((found = std::find(begin, finish, w)) != finish) {
154 unsigned char *ptfunxored;
158 bool jumpback(uint32_t *currpos, unsigned char *buf, const uint32_t maxoffset, const unsigned char *needle, const uint32_t needlelen);
159 bool jumpto(uint32_t *currpos, unsigned char *buf, const uint32_t maxoffset, const unsigned char *needle, const uint32_t needlelen);
160 bool foundin(std::string haystack, std::string needle);
161 int64_t foundat(unsigned char *haystack, uint64_t n, const char *needle);
163 bool parse_version();
164 uint8_t gen_xor_delta(uint8_t xor_value, uint8_t mul, bool negative);
167 void parse5header(void);
168 void parse7header(void);
169 void parse8header(void);
170 void parse9header(void);
171 void parse10header(void);
172 void parserest5(void);
173 void parserest89(void);
174 void parserest12(void);
175 void parseaudio5(void);
176 void parseaudio(void);
177 void parsemidi(void);
178 void parsemidi12(void);
179 void resort(std::vector<wav_t>& ws);
180 void resort(std::vector<region_t>& rs);
181 void filter(std::vector<region_t>& rs);
182 std::vector<wav_t> actualwavs;
184 std::string extension;