OSDN Git Service

[VM][COMMON_VM] Include IO:: class to common_vm.
[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         bool before_on;
35         bool use_lpf;
36         bool use_hpf;
37         int32_t lpf_freq;
38         int32_t hpf_freq;
39         float before_filter_l;
40         float before_filter_r;
41         float hpf_alpha;
42         float hpf_ialpha;
43         float lpf_alpha;
44         float lpf_ialpha;
45         
46         int sample_rate;
47         void calc_low_pass_filter(int32_t* dst, int32_t* src, int samples, int is_set_val);
48         void calc_high_pass_filter(int32_t* dst, int32_t* src, int samples, int is_set_val);
49         
50 public:
51         PCM1BIT(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
52         {
53                 volume_l = volume_r = 1024;
54                 set_device_name(_T("1BIT PCM SOUND"));
55         }
56         ~PCM1BIT() {}
57         
58         // common functions
59         void initialize();
60         void reset();
61         void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
62         void event_frame();
63         void mix(int32_t* buffer, int cnt);
64         void set_volume(int ch, int decibel_l, int decibel_r);
65         void set_high_pass_filter_freq(int freq, double quality = 1.0);
66         void set_low_pass_filter_freq(int freq, double quality = 1.0);
67         bool get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
68         bool is_debugger_available()
69         {
70                 return true;
71         }
72         
73         bool process_state(FILEIO* state_fio, bool loading);
74         
75         // unique function
76         void initialize_sound(int rate, int volume);
77         
78 };
79
80 #endif
81