1 #pragma once
2 
3 #include <stdint.h>
4 
5 #define MAX_SONGS 8
6 #define MAX_TRACKS 32
7 
8 enum {
9     SONG_FADE_IN = 1,
10     SONG_FADE_OUT = 2,
11     SONG_FADE_OUT_STOP = 4
12 };
13 
14 #pragma pack(push, 1)
15 
16 struct HMIHeader {
17     char signature[32]; // HMIMIDIP013195
18     uint32_t branchoffset;
19     uint8_t _pad1[12];
20     uint32_t numtracks;
21     uint32_t tpqn;
22     uint32_t tempo;
23     uint32_t timetoplay;
24     uint32_t priority[16];
25     uint32_t trackdevice[32][5];
26     uint8_t ccrestore[128];
27     uint8_t _pad2[8];
28 };
29 
30 struct HMITrack {
31     uint32_t id;
32     uint32_t size;
33     uint32_t channel;
34 };
35 
36 struct HMIBranch {
37     uint32_t offset;
38     uint8_t id;
39     uint8_t patch;
40     uint8_t loopcount;
41     uint8_t cccount;
42     uint8_t _pad1[4];
43     uint32_t ccoffset;
44     uint32_t reserved1;
45     uint32_t reserved2;
46 };
47 
48 #pragma pack(pop)
49 
50 struct ChannelData {
51     uint8_t used;
52     uint8_t bend;
53     uint8_t volume;
54     uint8_t patch;
55     uint8_t sustain;
56 };
57 
58 struct InitSong {
59     uint8_t *songptr;
60     void (*callback)(uint32_t);
61 };
62 
63 struct TrackDevice {
64     uint32_t trackdevice[32];
65 };
66 
67 int FMSetBank(void *_bank);
68 
69 void HMIInit(int rate);
70 void HMIUnInit(void);
71 uint32_t HMIStopSong(uint32_t handle);
72 uint32_t HMIUnInitSong(uint32_t handle);
73 uint32_t HMISetMasterVolume(uint8_t volume);
74 uint32_t HMISongDone(uint32_t handle);
75 uint32_t HMIFadeSong(uint32_t handle, uint32_t flags, uint32_t speed, uint8_t vol1, uint8_t vol2, uint32_t speed2);
76 uint32_t HMIInitSong(InitSong *song, TrackDevice *trackmap, uint32_t *handleptr);
77 uint32_t HMIResetSong(uint32_t handle, InitSong *song);
78 uint32_t HMIStartSong(uint32_t handle);
79