-
Notifications
You must be signed in to change notification settings - Fork 2
/
sf2.hpp
84 lines (69 loc) · 2.76 KB
/
sf2.hpp
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
#ifndef SF2_HPP
#define SF2_HPP
#include <stdio.h>
#include <stdint.h>
#include "sf2_types.hpp"
class InfoListChunk;
class SdtaListChunk;
class HydraChunk;
class sfPresetHeader;
class sfBag;
class sfInst;
// This is our own type, not part of the specification
typedef enum
{
UNSIGNED_8,
SIGNED_8,
SIGNED_16,
GAMEBOY_CH3,
BDPCM
}
SampleType;
class SF2
{
uint32_t size;
// Instrument and samples objects
// SF2Instr& instruments;
// gba_samples& samples;
//All 3 chunks of the SF2 file
InfoListChunk *const infolist_chunk;
SdtaListChunk *const sdtalist_chunk;
HydraChunk *const pdtalist_chunk;
void add_terminals();
// Forbid copy and affectation
SF2(SF2&);
SF2& operator=(SF2&);
public:
//Target file, should be assigned to a valid opened FILE in "wb" mode by user before "write()" is called.
FILE *out;
unsigned int default_sample_rate;
SF2(unsigned int sample_rate = 22050);
~SF2();
void write(FILE *outfile);
void add_new_preset(const char *name, int Patch, int Bank);
void add_new_instrument(const char *name);
void add_new_inst_bag();
void add_new_preset_bag();
void add_new_preset_modulator();
void add_new_preset_modulator(SFModulator srcMod, SFModulator amtMod, uint16_t modAmount, SFGenerator destGen, SFTransform sfModTransOper=SFTransform::linear);
void add_new_preset_generator();
void add_new_preset_generator(SFGenerator operation, uint16_t value);
void add_new_preset_generator(SFGenerator operation, uint8_t lo, uint8_t hi);
void add_new_inst_modulator();
void add_new_inst_modulator(SFModulator srcMod, SFModulator amtMod, uint16_t modAmount, SFGenerator destGen, SFTransform sfModTransOper=SFTransform::linear);
void add_new_inst_generator();
void add_new_inst_generator(SFGenerator operation, uint16_t value);
void add_new_inst_generator(SFGenerator operation, uint8_t lo, uint8_t hi);
void add_new_sample_header(const char *name, int start, int end, int start_loop, int end_loop, int sample_rate, int original_pitch, int pitch_correction);
void add_new_sample(FILE *file, SampleType type, const char *name, uint32_t pointer, uint32_t size, bool loop_flag,
uint32_t loop_start, uint32_t loop_end, uint32_t original_pitch, uint32_t pitch_correction, uint32_t sample_rate);
void add_new_sample(void *mem, SampleType type, const char *name, uint32_t pointer, uint32_t size, bool loop_flag,
uint32_t loop_start, uint32_t loop_end, uint32_t original_pitch, uint32_t pitch_correction, uint32_t sample_rate);
uint16_t get_ibag_size();
uint16_t get_igen_size();
uint16_t get_imod_size();
uint16_t get_pbag_size();
uint16_t get_pgen_size();
uint16_t get_pmod_size();
};
#endif