-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapu.h
37 lines (28 loc) · 886 Bytes
/
apu.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
/**
* Emulate the audio processing unit (APU) of the Game Boy.
* Based on MiniGBS: https://github.com/baines/MiniGBS
*/
#pragma once
#include <stdint.h>
#define AUDIO_SAMPLE_RATE 48000.0
#define DMG_CLOCK_FREQ 4194304.0
#define SCREEN_REFRESH_CYCLES 70224.0
#define VERTICAL_SYNC (DMG_CLOCK_FREQ / SCREEN_REFRESH_CYCLES)
#define AUDIO_SAMPLES ((unsigned) (AUDIO_SAMPLE_RATE / VERTICAL_SYNC))
/**
* Fill allocated buffer "data" with "len" number of 32-bit floating point
* samples (native endian order) in stereo interleaved format.
*/
void audio_callback(void *ptr, uint8_t *data, int len);
/**
* Read audio register at given address "addr".
*/
uint8_t audio_read(const uint16_t addr);
/**
* Write "val" to audio register at given address "addr".
*/
void audio_write(const uint16_t addr, const uint8_t val);
/**
* Initialize audio driver.
*/
void audio_init(void);