-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
pcm.h
53 lines (43 loc) · 1.01 KB
/
pcm.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
#ifndef PCM_H
#define PCM_H
#include <stddef.h>
#include "clowncommon/clowncommon.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct PCM_Configuration
{
cc_bool channels_disabled[8];
} PCM_Configuration;
typedef struct PCM_ChannelState
{
cc_bool disabled;
cc_u8l volume;
cc_u8l panning[2];
cc_u16l frequency;
cc_u16l loop_address;
cc_u8l start_address;
cc_u32l address;
} PCM_ChannelState;
typedef struct PCM_State
{
PCM_ChannelState channels[8];
cc_u8l wave_ram[0x10000];
cc_bool sounding;
cc_u8l current_wave_bank;
cc_u8l current_channel;
} PCM_State;
typedef struct PCM
{
const PCM_Configuration *configuration;
PCM_State *state;
} PCM;
void PCM_State_Initialise(PCM_State *state);
void PCM_WriteRegister(const PCM *pcm, cc_u16f reg, cc_u8f value);
cc_u8f PCM_ReadRegister(const PCM *pcm, cc_u8f reg);
void PCM_WriteWaveRAM(const PCM *pcm, cc_u16f address, cc_u8f value);
void PCM_Update(const PCM *pcm, cc_s16l *sample_buffer, size_t total_frames);
#ifdef __cplusplus
}
#endif
#endif /* PCM_H */