Mercurial > audlegacy-plugins
comparison src/console/Gb_Oscs.h @ 12:3da1b8942b8b trunk
[svn] - remove src/Input src/Output src/Effect src/General src/Visualization src/Container
author | nenolod |
---|---|
date | Mon, 18 Sep 2006 03:14:20 -0700 |
parents | src/Input/console/Gb_Oscs.h@13389e613d67 |
children | fb513e10174e |
comparison
equal
deleted
inserted
replaced
11:cff1d04026ae | 12:3da1b8942b8b |
---|---|
1 | |
2 // Private oscillators used by Gb_Apu | |
3 | |
4 // Gb_Snd_Emu 0.1.4 | |
5 | |
6 #ifndef GB_OSCS_H | |
7 #define GB_OSCS_H | |
8 | |
9 #include "blargg_common.h" | |
10 #include "Blip_Buffer.h" | |
11 | |
12 struct Gb_Osc | |
13 { | |
14 enum { trigger = 0x80 }; | |
15 enum { len_enabled_mask = 0x40 }; | |
16 | |
17 Blip_Buffer* outputs [4]; // NULL, right, left, center | |
18 Blip_Buffer* output; | |
19 int output_select; | |
20 BOOST::uint8_t* regs; // osc's 5 registers | |
21 | |
22 int delay; | |
23 int last_amp; | |
24 int volume; | |
25 int length; | |
26 bool enabled; | |
27 | |
28 void reset(); | |
29 void clock_length(); | |
30 int frequency() const { return (regs [4] & 7) * 0x100 + regs [3]; } | |
31 }; | |
32 | |
33 struct Gb_Env : Gb_Osc | |
34 { | |
35 int env_delay; | |
36 | |
37 void reset(); | |
38 void clock_envelope(); | |
39 bool write_register( int, int ); | |
40 }; | |
41 | |
42 struct Gb_Square : Gb_Env | |
43 { | |
44 enum { period_mask = 0x70 }; | |
45 enum { shift_mask = 0x07 }; | |
46 | |
47 typedef Blip_Synth<blip_good_quality,1> Synth; | |
48 Synth const* synth; | |
49 int sweep_delay; | |
50 int sweep_freq; | |
51 int phase; | |
52 | |
53 void reset(); | |
54 void clock_sweep(); | |
55 void run( gb_time_t, gb_time_t, int playing ); | |
56 }; | |
57 | |
58 struct Gb_Noise : Gb_Env | |
59 { | |
60 typedef Blip_Synth<blip_med_quality,1> Synth; | |
61 Synth const* synth; | |
62 unsigned bits; | |
63 | |
64 void run( gb_time_t, gb_time_t, int playing ); | |
65 }; | |
66 | |
67 struct Gb_Wave : Gb_Osc | |
68 { | |
69 typedef Blip_Synth<blip_med_quality,1> Synth; | |
70 Synth const* synth; | |
71 int wave_pos; | |
72 enum { wave_size = 32 }; | |
73 BOOST::uint8_t wave [wave_size]; | |
74 | |
75 void write_register( int, int ); | |
76 void run( gb_time_t, gb_time_t, int playing ); | |
77 }; | |
78 | |
79 inline void Gb_Env::reset() | |
80 { | |
81 env_delay = 0; | |
82 Gb_Osc::reset(); | |
83 } | |
84 | |
85 #endif | |
86 |