-
Notifications
You must be signed in to change notification settings - Fork 0
/
kits.h
173 lines (115 loc) · 3.11 KB
/
kits.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
written at 2023 by Peter Semiletov
this code is the public domain
*/
#ifndef KITS_H
#define KITS_H
#include <vector>
#include <map>
#include <stdint.h>
#include <string.h>
#include "pugixml.hpp"
class CDrumLayer
{
public:
int session_samplerate; //uplink (session) samplerate
//for layer velo range
float min;
float max;
std::string file_name; //name of the loaded file
int channels;
int frames;
int samplerate;
uint32_t samples_count; //data size in samples (info.frames * info.channels)
float* data; //interleaved sample data from the file
uint32_t offset;
int dataoffset;
CDrumLayer (int sample_rate); //sample_rate is uplink (session) samplerate
~CDrumLayer();
void load (const char *fname); //loads the sample, sets internally info, data, file_name
void print();
float* load_whole_sample (const char *fname); //called from load_whole_sample_resampled
float* load_whole_sample_resampled (const char *fname, int sess_samplerate); //called from load
};
class CDrumSample
{
public:
std::string name;
int id;
int current_layer;
int midiOutNote;
int session_samplerate; //session srate, taken from the upper object
char active;
float velocity;
//bool hihat;
bool hihat_open;
bool hihat_close;
std::vector <CDrumLayer*> v_layers;
CDrumSample (int sample_rate);
~CDrumSample();
size_t map_velo_to_layer_number (float velo);
void add_layer();
void print();
void print_stats();
};
class CHydrogenKit
{
public:
bool scan_mode; //if false, we do not load kit' samples
std::string kit_name; //parsed from XML
std::string kit_filename; //full path to the kit xml, txt or sfz file
std::string kit_dir; //full path to the kit
std::string image_fname;
int samplerate; //session srate
bool layers_supported;
std::vector <CDrumSample*> v_samples;
std::vector <std::string> v_hat_open_signatures;
std::vector <std::string> v_hat_close_signatures;
void add_sample();
void load (const char *fname, int sample_rate);
void load_txt (std::string fname);
void load_sfz (std::string fname);
CHydrogenKit();
~CHydrogenKit();
void print();
void print_stats();
};
/*
class CHydrogenKits
{
public:
std::vector <std::string> v_kits_dirs;
std::vector <std::string> v_kits_names;
std::map <std::string, std::string> m_kits; //var=value i.e. name = full path
CHydrogenKits();
~CHydrogenKits();
std::string get_kit_name (const std::string full_path); //get kit name for full path
void scan();
void print();
};
*/
class CHydrogenKitsScanner
{
public:
std::vector <std::string> v_kits_dirs;
std::vector <std::string> v_kits_names;
std::vector <CHydrogenKit*> v_scanned_kits;
// std::map <std::string, std::string> m_kits; //name = full path
CHydrogenKitsScanner();
~CHydrogenKitsScanner();
void scan();
void print();
};
class CHydrogenXMLWalker: public pugi::xml_tree_walker
{
public:
CHydrogenKit *kit;
bool is_drumkit_info;
bool is_instrument;
bool is_layer;
bool drumkit_info_passed;
bool drumkitComponent_passed;
CHydrogenXMLWalker (CHydrogenKit *hkit);
bool for_each (pugi::xml_node& node);
};
#endif