-
Notifications
You must be signed in to change notification settings - Fork 2
/
it_music.h
104 lines (89 loc) · 3.42 KB
/
it_music.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
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "it_structs.h"
// AUDIO DRIVERS
#if defined AUDIODRIVER_SDL
#include "audiodrivers/sdl/sdldriver.h"
#elif defined AUDIODRIVER_WINMM
#include "audiodrivers/winmm/winmm.h"
#else
// Read "audiodrivers/how_to_write_drivers.txt"
#endif
enum
{
MIDICOMMAND_START = 0x0000,
MIDICOMMAND_STOP = 0x0020,
MIDICOMMAND_TICK = 0x0040,
MIDICOMMAND_PLAYNOTE = 0x0060,
MIDICOMMAND_STOPNOTE = 0x0080,
MIDICOMMAND_CHANGEVOLUME = 0x00A0,
MIDICOMMAND_CHANGEPAN = 0x00C0,
MIDICOMMAND_BANKSELECT = 0x00E0,
MIDICOMMAND_PROGRAMSELECT = 0x0100,
MIDICOMMAND_CHANGEPITCH = 0xFFFF
};
// 8bb: 31 is possible through initial tempo (but 32 is general minimum)
#define LOWEST_BPM_POSSIBLE 31
#define MIX_FRAC_BITS 16
#define MIX_FRAC_MASK ((1 << MIX_FRAC_BITS)-1)
/* 8bb:
** Amount of extra bytes to allocate for every instrument sample,
** this is used for a hack for resampling interpolation to be
** branchless in the inner channel mixer loop.
** Warning: Do not change this!
*/
#define SMP_DAT_OFFSET 16
#define SAMPLE_PAD_LENGTH (SMP_DAT_OFFSET+16)
// IT2 AUDIO DRIVERS
enum
{
DRIVER_HQ = 0, // high-quality custom driver by 8bitbubsy
DRIVER_SB16MMX = 1,
DRIVER_SB16 = 2,
DRIVER_WAVWRITER = 3
};
// 8bb: globalized
extern void (*DriverClose)(void);
extern void (*DriverMix)(int32_t, int16_t *);
extern void (*DriverResetMixer)(void);
extern int32_t (*DriverPostMix)(int16_t *, int32_t);
extern void (*DriverMixSamples)(void);
extern void (*DriverSetTempo)(uint8_t);
extern void (*DriverSetMixVolume)(uint8_t);
extern void (*DriverFixSamples)(void);
// --------------------------------------------
void Music_SetDefaultMIDIDataArea(void); // 8bb: added this
char *Music_GetMIDIDataArea(void);
void RecalculateAllVolumes(void);
void MIDITranslate(hostChn_t *hc, slaveChn_t *sc, uint16_t Input);
void InitPlayInstrument(hostChn_t *hc, slaveChn_t *sc, instrument_t *ins);
slaveChn_t *AllocateChannel(hostChn_t *hc, uint8_t *hcFlags);
uint8_t Random(void);
void GetLoopInformation(slaveChn_t *sc);
void ApplyRandomValues(hostChn_t *hc);
void PitchSlideUpLinear(hostChn_t *hc, slaveChn_t *sc, int16_t SlideValue);
void PitchSlideUp(hostChn_t *hc, slaveChn_t *sc, int16_t SlideValue);
void PitchSlideDown(hostChn_t *hc, slaveChn_t *sc, int16_t SlideValue);
void Update(void);
void Music_FillAudioBuffer(int16_t *buffer, int32_t numSamples);
bool Music_Init(int32_t mixingFrequency, int32_t mixingBufferSize, int32_t DriverType);
void Music_Close(void); // 8bb: added this
void Music_Stop(void);
void Music_StopChannels(void);
void Music_PreviousOrder(void);
void Music_NextOrder(void);
void Music_PlaySong(uint16_t order);
void Music_PrepareWAVRender(void); // 8bb: added this
void Music_InitTempo(void);
bool Music_AllocateSample(uint32_t sample, uint32_t length);
bool Music_AllocateRightSample(uint32_t sample, uint32_t length); // 8bb: added this
void Music_ReleaseSample(uint32_t sample);
void Music_ReleaseAllSamples(void);
bool Music_AllocatePattern(uint32_t pattern, uint32_t length);
void Music_ReleasePattern(uint32_t pattern);
void Music_ReleaseAllPatterns(void);
int32_t Music_GetActiveVoices(void); // 8bb: added this
bool Music_RenderToWAV(const char *filenameOut); // 8bb: added this
void Music_FreeSong(void); // 8bb: added this
extern bool WAVRender_Flag; // 8bb: added this