-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpaula.h
79 lines (61 loc) · 2.17 KB
/
paula.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
#pragma once
#include <stdint.h>
#include <stdbool.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
// main crystal oscillator for PAL Amiga systems
#define AMIGA_PAL_XTAL_HZ 28375160
#define AMIGA_PAL_CCK_HZ (AMIGA_PAL_XTAL_HZ / 8.0)
#define PAULA_PAL_CLK AMIGA_PAL_CCK_HZ
#define CIA_PAL_CLK (AMIGA_PAL_CCK_HZ / 5.0)
#define PAULA_VOICES 4
typedef struct audio_t
{
volatile bool playing, pause;
bool oversamplingFlag;
int32_t outputFreq, masterVol, stereoSeparation;
int64_t tickSampleCounter64, samplesPerTick64;
} audio_t;
typedef struct voice_t
{
volatile bool DMA_active;
// internal values (don't modify directly!)
bool DMATriggerFlag, nextSampleStage;
int8_t AUD_DAT[2]; // DMA data buffer
const int8_t *location; // current location
uint16_t lengthCounter; // current length
int32_t sampleCounter; // how many bytes left in AUD_DAT
double dSample; // current sample point
// registers modified by Paula functions
const int8_t *AUD_LC; // location
uint16_t AUD_LEN; // length (in words)
double AUD_PER_delta, AUD_PER_deltamul; // delta
double AUD_VOL; // volume
double dDelta, dPhase;
// for BLEP synthesis
double dLastDelta, dLastPhase, dLastDeltaMul, dBlepOffset, dDeltaMul;
} paulaVoice_t;
void paulaClearFilterState(void);
void resetAudioDithering(void);
double amigaCIAPeriod2Hz(uint16_t period);
bool amigaSetCIAPeriod(uint16_t period); // replayer ticker speed
bool paulaInit(int32_t audioFrequency);
void paulaClose(void);
void paulaSetMasterVolume(int32_t vol);
void paulaSetStereoSeparation(int32_t percentage); // 0..100 (percentage)
void paulaTogglePause(void);
void paulaOutputSamples(int16_t *stream, int32_t numSamples);
void paulaSetDMACON(uint16_t bits);
void paulaSetPeriod(int32_t ch, uint16_t period);
void paulaSetVolume(int32_t ch, uint16_t vol);
void paulaSetLength(int32_t ch, uint16_t len);
void paulaSetData(int32_t ch, const int8_t *src);
void paulaMixSamples(int16_t *target, uint32_t numSamples);
extern audio_t audio; // paula.c
extern paulaVoice_t paula[PAULA_VOICES]; // paula.c