-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.hpp
More file actions
56 lines (41 loc) · 978 Bytes
/
audio.hpp
File metadata and controls
56 lines (41 loc) · 978 Bytes
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
#ifndef AUDIO_H
#define AUDIO_H
#include <cstdlib>
#include <string>
#include <vector>
#include "portaudio.h"
#include "cpu.hpp"
#include "PulseUnit.hpp"
#include "CustomWaveUnit.hpp"
const int N_PULSE_UNITS = 2;
const int N_UNITS = 3;
const float SAMPLE_RATE = 44100.0;
// SO1 is right, SO2 is left
const uint8_t CHANNEL_1_RIGHT = 1<<0;
const uint8_t CHANNEL_2_RIGHT = 1<<1;
const uint8_t CHANNEL_3_RIGHT = 1<<2;
const uint8_t CHANNEL_4_RIGHT = 1<<3;
const uint8_t CHANNEL_1_LEFT = 1<<4;
const uint8_t CHANNEL_2_LEFT = 1<<5;
const uint8_t CHANNEL_3_LEFT = 1<<6;
const uint8_t CHANNEL_4_LEFT = 1<<7;
class CPU;
class Audio {
public:
Audio(CPU *cpu, float sampleRate = SAMPLE_RATE);
~Audio();
void apuInit();
void tick();
void frameTick();
float lastSampleLeft;
float lastSampleRight;
std::vector<PulseUnit> pulses;
CustomWaveUnit custom;
private:
CPU *cpu;
float time;
float sampleRate;
float timeStep;
PaStream *stream;
};
#endif