Add Pianokeyboard + Velocity Control to PC Dialog
[ardour.git] / libs / ptformat / ptfformat.h
index 8b2f58de73845046abe0ac7ca9b6f66c77715229..e5f4ed94bdb3fa8f0e99fefcaa40cb35a8bd2742 100644 (file)
@@ -32,24 +32,31 @@ public:
        */
        int load(std::string path, int64_t targetsr);
 
-       typedef struct wav {
+       struct wav_t {
                std::string filename;
                uint16_t    index;
 
                int64_t     posabsolute;
                int64_t     length;
 
-               bool operator <(const struct wav& other) const {
+               bool operator <(const struct wav_t& other) const {
                        return (strcasecmp(this->filename.c_str(),
                                        other.filename.c_str()) < 0);
                }
 
-               bool operator ==(const struct wav& other) const {
+               bool operator ==(const struct wav_t& other) const {
                        return (this->filename == other.filename ||
                                this->index == other.index);
                }
 
-       } wav_t;
+       };
+
+       struct midi_ev_t {
+               uint64_t pos;
+               uint64_t length;
+               uint8_t note;
+               uint8_t velocity;
+       };
 
        typedef struct region {
                std::string name;
@@ -58,6 +65,7 @@ public:
                int64_t     sampleoffset;
                int64_t     length;
                wav_t       wave;
+               std::vector<midi_ev_t> midi;
 
                bool operator ==(const struct region& other) {
                        return (this->index == other.index);
@@ -65,25 +73,6 @@ public:
        } region_t;
 
        typedef struct track {
-               track ()
-                       : index (0)
-                       , playlist (0)
-               {
-                       memset ((void*)&reg, 0, sizeof(region_t));
-               }
-
-               track (std::string n, uint16_t i, uint8_t p, region_t *r)
-                       : name (n)
-                       , index (i)
-                       , playlist (p)
-               {
-                       set_region (r);
-               }
-
-               void set_region (region_t *r) {
-                       memcpy ((void*)&reg, (void*)r, sizeof(region_t));
-               }
-
                std::string name;
                uint16_t    index;
                uint8_t     playlist;
@@ -104,7 +93,8 @@ public:
                std::vector<region_t>::iterator found;
 
                wav_t w = { std::string(""), 0, 0, 0 };
-               region_t r = { std::string(""), index, 0, 0, 0, w };
+               std::vector<midi_ev_t> m;
+               region_t r = { std::string(""), index, 0, 0, 0, w, m};
 
                if ((found = std::find(begin, finish, r)) != finish) {
                        return true;
@@ -128,6 +118,8 @@ public:
        int64_t sessionrate;
        int64_t targetrate;
        uint8_t version;
+       uint8_t *product;
+
 
        unsigned char c0;
        unsigned char c1;
@@ -136,8 +128,9 @@ public:
 
 private:
        bool foundin(std::string haystack, std::string needle);
-       void parse(void);
-       void unxor10(void);
+       int parse(void);
+       bool parse_version();
+       uint8_t gen_xor_delta(uint8_t xor_value, uint8_t mul, bool negative);
        void setrates(void);
        void parse5header(void);
        void parse7header(void);
@@ -149,8 +142,8 @@ private:
        void parserest10(void);
        void parseaudio5(void);
        void parseaudio(void);
-       void resort(std::vector<wav_t> *ws);
-       uint8_t mostfrequent(uint32_t start, uint32_t stop);
+       void parsemidi(void);
+       void resort(std::vector<wav_t>& ws);
        std::vector<wav_t> actualwavs;
        float ratefactor;
        std::string extension;