SVG of thorsten's editor track/bus list icons
[ardour2.git] / tools / omf / omftool.h
blobb6e291ca5870407d7ea3b305b8b2d9f8911299bc
1 #ifndef __ardour_omftool__
2 #define __ardour_omftool__
4 #include <vector>
5 #include <string>
6 #include <cstdio>
8 #include <stdint.h>
9 #include <sqlite3.h>
11 class XMLNode;
13 class OMF {
14 public:
15 OMF ();
16 ~OMF ();
18 int init ();
19 int load (const std::string&);
20 int create_xml ();
22 void set_version (int);
23 void set_session_name (const std::string&);
24 void set_sample_rate (int);
26 struct SourceInfo {
27 int channels;
28 int sample_rate;
29 uint64_t length;
30 XMLNode* node;
32 SourceInfo (int chn, int sr, uint64_t l, XMLNode* n)
33 : channels (chn), sample_rate (sr), length (l), node (n) {}
36 private:
37 bool bigEndian;
38 int64_t id_counter;
39 FILE* file;
40 sqlite3* db;
41 int version;
42 std::string base_dir;
43 std::string session_name;
44 std::vector<std::string> audiofile_path_vector;
45 int sample_rate; /* audio samples per second */
46 double frame_rate; /* time per video frame */
47 XMLNode* session;
48 XMLNode* sources;
49 XMLNode* routes;
50 XMLNode* regions;
51 XMLNode* playlists;
52 XMLNode* diskstreams;
53 XMLNode* locations;
54 XMLNode* options;
56 XMLNode* new_region_node ();
57 XMLNode* new_source_node ();
58 XMLNode* new_route_node ();
59 XMLNode* new_playlist_node ();
60 XMLNode* new_diskstream_node ();
62 typedef std::map<std::string,SourceInfo*> KnownSources;
63 KnownSources known_sources;
65 SourceInfo* get_known_source (const char*);
66 char* read_name (size_t offset, size_t length);
67 bool get_offset_and_length (const char* offstr, const char* lenstr, uint32_t& offset, uint32_t& len);
68 void name_types ();
69 void add_id (XMLNode*);
70 void set_route_node_channels (XMLNode* route, int in, int out, bool send_to_master);
71 bool get_audio_info (const std::string& path);
72 void set_region_sources (XMLNode*, SourceInfo*);
73 void legalize_name (std::string&);
75 uint16_t e16(uint16_t x)
77 if (bigEndian)
78 return (x>>8)
79 | (x<<8);
80 else
81 return x;
84 uint32_t e32(uint32_t x)
86 if (bigEndian)
87 return (x>>24) |
88 ((x<<8) & 0x00FF0000) |
89 ((x>>8) & 0x0000FF00) |
90 (x<<24);
91 else
92 return x;
95 uint64_t e64(uint64_t x)
97 if (bigEndian)
98 return (x>>56) |
99 ((x<<40) & 0x00FF000000000000) |
100 ((x<<24) & 0x0000FF0000000000) |
101 ((x<<8) & 0x000000FF00000000) |
102 ((x>>8) & 0x00000000FF000000) |
103 ((x>>24) & 0x0000000000FF0000) |
104 ((x>>40) & 0x000000000000FF00) |
105 (x<<56);
106 else
107 return x;
112 #endif /* __ardour_omftool__ */