OSDN Git Service

[VM][WIP] Apply some devices merging upstream 2018-10-05.This still not build.WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pcm1bit.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2007.02.09 -
6
7         [ 1bit PCM ]
8 */
9
10 #ifndef _PCM1BIT_H_
11 #define _PCM1BIT_H_
12
13 //#include "vm.h"
14 //#include "../emu.h"
15 #include "device.h"
16
17 #define SIG_PCM1BIT_SIGNAL      0
18 #define SIG_PCM1BIT_ON          1
19 #define SIG_PCM1BIT_MUTE        2
20
21 class VM;
22 class EMU;
23 class PCM1BIT : public DEVICE
24 {
25 private:
26         bool signal, on, mute;
27         int changed;
28         uint32_t prev_clock;
29         int positive_clocks, negative_clocks;
30         int max_vol, last_vol_l, last_vol_r;
31         int volume_l, volume_r;
32         bool realtime;
33         
34 public:
35         PCM1BIT(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
36         {
37                 volume_l = volume_r = 1024;
38                 set_device_name(_T("1BIT PCM SOUND"));
39         }
40         ~PCM1BIT() {}
41         
42         // common functions
43         void initialize();
44         void reset();
45         void write_signal(int id, uint32_t data, uint32_t mask);
46         void event_frame();
47         void mix(int32_t* buffer, int cnt);
48         void set_volume(int ch, int decibel_l, int decibel_r);
49         bool process_state(FILEIO* state_fio, bool loading);
50         
51         // unique function
52         void initialize_sound(int rate, int volume);
53 };
54
55 #endif
56