-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBitBin.h
79 lines (54 loc) · 1.76 KB
/
BitBin.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
#ifndef __BITBIN_H__
#define __BITBIN_H__
#include "BitBinTables.h"
#include <stdint.h>
#include <stdbool.h>
#define MaximumBitBinChannels 8
typedef struct BitBinNote
{
uint8_t note,waveform,volume,effect,parameter;
} BitBinNote;
typedef struct BitBinChannel
{
int note;
int waveform;
int effect;
int parameter;
int currentvolume,requestedvolume,mastervolume;
uint32_t phase,phasedelta;
uint32_t unisonphase[4];
int vibrato,vibratophase;
int portadest;
uint8_t memory[26];
int64_t lastamp2;
int64_t lastamp;
BitBinNote *notes;
} BitBinChannel;
typedef struct BitBinSong
{
uint32_t currentsample,nexttick,samplespertick;
uint32_t currenttick,nextrow,ticksperrow;
uint32_t currentrow,numrows;
bool loops,stopped;
const uint32_t *phasetable;
int32_t nFilter_A0,nFilter_B0,nFilter_B1;
int32_t r,c,v0,v1;
int16_t delaybuf[1024];
int delaycounter;
int delaypos;
int numchannels;
BitBinChannel channels[MaximumBitBinChannels];
} BitBinSong;
void InitializeBitBinSong(BitBinSong *self,const uint32_t *phasetable,int numchannels,int numrows,BitBinNote **notes);
int16_t NextBitBinSample(BitBinSong *self);
void RenderBitBinSamples(BitBinSong *self,int numsamples,int16_t *samples);
static inline bool DoesBitBinSongLoop(BitBinSong *self) { return self->loops; }
static inline bool SetBitBinSongLoops(BitBinSong *self,bool loops) { self->loops=loops; }
static inline bool IsBitBinSongStopped(BitBinSong *self) { return self->stopped; }
static inline bool SetBitBinSongStopped(BitBinSong *self,bool stopped) { self->stopped=stopped; }
static inline int CurrentBitBinRow(BitBinSong *self) { return self->currentrow; }
static inline BitBinNote BitBinNoteAtRow(BitBinSong *self,int channel,int row)
{
return self->channels[channel].notes[row&127];
}
#endif