/
TechnikaSong.hpp
76 lines (63 loc) · 1.71 KB
/
TechnikaSong.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
#ifndef _TECHNIKA_SONG_HPP_
#define _TECHNIKA_SONG_HPP_
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include "SoundPool.hpp"
class TechnikaSong {
public:
TechnikaSong(const std::string &filename);
void play();
enum CommandType {
CommandTrackStart = 0,
CommandSound,
CommandUnknown,
CommandBPM
};
struct __attribute__((packed)) Command {
uint32_t position;
uint8_t type;
union {
struct {
uint32_t _num_commands; // num_commands * 16
uint32_t num_commands;
} start_params;
struct {
uint16_t index;
uint8_t volume;
uint8_t pan;
uint8_t type;
uint8_t _unknown;
uint16_t _unused;
} sound_params;
struct {
float bpm;
uint32_t _unknown;
} bpm_params;
};
};
struct __attribute__((packed)) SoundEntry {
uint16_t index;
uint8_t _unused;
char filename[0x40];
};
struct __attribute__((packed)) SongInfo {
uint16_t num_sounds;
uint16_t num_tracks;
uint16_t positions_per_measure;
float initial_bpm;
uint8_t _unknown[20];
};
static_assert(sizeof(Command) == 0xd, "command struct size");
static_assert(sizeof(SoundEntry) == 0x43, "sound_entry truct size");
private:
static const int SEPARATE_DIST = 0x3d;
void load_info(FILE *fp);
void load_sounds(FILE *fp);
void load_commands(FILE *fp);
SongInfo info_;
std::vector<std::pair<Command, int>> commands_;
SoundPool soundpool_;
};
#endif