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 / noise.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2017.03.08-
6
7         [ noise player ]
8 */
9
10 #ifndef _NOISE_H_
11 #define _NOISE_H_
12
13 //#include "vm.h"
14 //#include "../emu.h"
15 #include "device.h"
16
17 class NOISE : public DEVICE
18 {
19 private:
20         int16_t *buffer_l;
21         int16_t *buffer_r;
22         int samples;
23         int sample_rate;
24         int register_id;
25         int ptr;
26         int sample_l, sample_r;
27         int volume_l, volume_r;
28         bool loop;
29         bool mute;
30         
31         void get_sample();
32         
33 public:
34         NOISE(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
35         {
36                 buffer_l = buffer_r = NULL;
37                 samples = 0;
38                 volume_l = volume_r = 1024;
39                 loop = false;
40                 mute = false;
41                 set_device_name(_T("Noise Player"));
42         }
43         ~NOISE() {}
44         
45         // common functions
46         void initialize();
47         void release();
48         void reset();
49         void event_callback(int event_id, int err);
50         void mix(int32_t* buffer, int cnt);
51         void set_volume(int ch, int decibel_l, int decibel_r);
52         bool process_state(FILEIO* state_fio, bool loading);
53         
54         // unique functions
55         bool load_wav_file(const _TCHAR *file_name);
56         void play();
57         void stop();
58         void set_loop(bool value)
59         {
60                 loop = value;
61         }
62         void set_mute(bool value)
63         {
64                 mute = value;
65         }
66 };
67
68 #endif
69