diff options
Diffstat (limited to 'apps/codecs/libgme/ay_emu.h')
-rw-r--r-- | apps/codecs/libgme/ay_emu.h | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/apps/codecs/libgme/ay_emu.h b/apps/codecs/libgme/ay_emu.h index b320e69653..7334167876 100644 --- a/apps/codecs/libgme/ay_emu.h +++ b/apps/codecs/libgme/ay_emu.h | |||
@@ -10,14 +10,12 @@ | |||
10 | #include "z80_cpu.h" | 10 | #include "z80_cpu.h" |
11 | #include "ay_apu.h" | 11 | #include "ay_apu.h" |
12 | #include "m3u_playlist.h" | 12 | #include "m3u_playlist.h" |
13 | 13 | #include "track_filter.h" | |
14 | typedef short sample_t; | ||
15 | 14 | ||
16 | // 64K memory to load code and data into before starting track. Caller | 15 | // 64K memory to load code and data into before starting track. Caller |
17 | // must parse the AY file. | 16 | // must parse the AY file. |
18 | enum { mem_size = 0x10000 }; | 17 | enum { mem_size = 0x10000 }; |
19 | enum { ram_addr = 0x4000 }; // where official RAM starts | 18 | enum { ram_addr = 0x4000 }; // where official RAM starts |
20 | enum { buf_size = 2048 }; | ||
21 | 19 | ||
22 | // AY file header | 20 | // AY file header |
23 | enum { header_size = 0x14 }; | 21 | enum { header_size = 0x14 }; |
@@ -62,43 +60,30 @@ struct Ay_Emu { | |||
62 | bool cpc_mode; | 60 | bool cpc_mode; |
63 | 61 | ||
64 | // general | 62 | // general |
65 | int max_initial_silence; | ||
66 | int voice_count; | 63 | int voice_count; |
64 | int const* voice_types; | ||
67 | int mute_mask_; | 65 | int mute_mask_; |
68 | int tempo; | 66 | int tempo; |
69 | int gain; | 67 | int gain; |
70 | 68 | ||
71 | long sample_rate; | 69 | int sample_rate; |
72 | 70 | ||
73 | // track-specific | 71 | // track-specific |
74 | int current_track; | 72 | int current_track; |
75 | int track_count; | 73 | int track_count; |
76 | blargg_long out_time; // number of samples played since start of track | 74 | |
77 | blargg_long emu_time; // number of samples emulator has generated since start of track | 75 | int clock_rate_; |
78 | volatile bool track_ended; | ||
79 | bool emu_track_ended_; // emulator has reached end of track | ||
80 | |||
81 | // fading | ||
82 | blargg_long fade_start; | ||
83 | int fade_step; | ||
84 | |||
85 | // silence detection | ||
86 | bool ignore_silence; | ||
87 | int silence_lookahead; // speed to run emulator when looking ahead for silence | ||
88 | long silence_time; // number of samples where most recent silence began | ||
89 | long silence_count; // number of samples of silence to play before using buf | ||
90 | long buf_remain; // number of samples left in silence buffer | ||
91 | |||
92 | long clock_rate_; | ||
93 | unsigned buf_changed_count; | 76 | unsigned buf_changed_count; |
94 | 77 | ||
95 | // M3u Playlist | 78 | // M3u Playlist |
96 | struct M3u_Playlist m3u; | 79 | struct M3u_Playlist m3u; |
97 | 80 | ||
98 | // large items | 81 | // large items |
82 | struct setup_t tfilter; | ||
83 | struct Track_Filter track_filter; | ||
84 | |||
99 | struct Ay_Apu apu; | 85 | struct Ay_Apu apu; |
100 | sample_t buf [buf_size]; | 86 | struct Multi_Buffer stereo_buf; // NULL if using custom buffer |
101 | struct Stereo_Buffer stereo_buf; // NULL if using custom buffer | ||
102 | struct Z80_Cpu cpu; | 87 | struct Z80_Cpu cpu; |
103 | struct mem_t mem; | 88 | struct mem_t mem; |
104 | }; | 89 | }; |
@@ -106,46 +91,58 @@ struct Ay_Emu { | |||
106 | // Basic functionality (see Gme_File.h for file loading/track info functions) | 91 | // Basic functionality (see Gme_File.h for file loading/track info functions) |
107 | void Ay_init( struct Ay_Emu* this ); | 92 | void Ay_init( struct Ay_Emu* this ); |
108 | 93 | ||
109 | blargg_err_t Ay_load_mem( struct Ay_Emu* this, byte const in [], int size ); | 94 | blargg_err_t Ay_load_mem( struct Ay_Emu* this, byte const in [], long size ); |
110 | 95 | ||
111 | // Set output sample rate. Must be called only once before loading file. | 96 | // Set output sample rate. Must be called only once before loading file. |
112 | blargg_err_t Ay_set_sample_rate( struct Ay_Emu* this, long sample_rate ); | 97 | blargg_err_t Ay_set_sample_rate( struct Ay_Emu* this, int sample_rate ); |
113 | 98 | ||
114 | // Start a track, where 0 is the first track. Also clears warning string. | 99 | // Start a track, where 0 is the first track. Also clears warning string. |
115 | blargg_err_t Ay_start_track( struct Ay_Emu* this, int track ); | 100 | blargg_err_t Ay_start_track( struct Ay_Emu* this, int track ); |
116 | 101 | ||
117 | // Generate 'count' samples info 'buf'. Output is in stereo. Any emulation | 102 | // Generate 'count' samples info 'buf'. Output is in stereo. Any emulation |
118 | // errors set warning string, and major errors also end track. | 103 | // errors set warning string, and major errors also end track. |
119 | blargg_err_t Ay_play( struct Ay_Emu* this, long count, sample_t* buf ); | 104 | blargg_err_t Ay_play( struct Ay_Emu* this, int count, sample_t* buf ); |
120 | 105 | ||
121 | 106 | ||
122 | // Track status/control | 107 | // Track status/control |
123 | 108 | ||
124 | // Number of milliseconds (1000 msec = 1 second) played since beginning of track | 109 | // Number of milliseconds (1000 msec = 1 second) played since beginning of track |
125 | long Track_tell( struct Ay_Emu* this ); | 110 | int Track_tell( struct Ay_Emu* this ); |
126 | 111 | ||
127 | // Seek to new time in track. Seeking backwards or far forward can take a while. | 112 | // Seek to new time in track. Seeking backwards or far forward can take a while. |
128 | blargg_err_t Track_seek( struct Ay_Emu* this, long msec ); | 113 | blargg_err_t Track_seek( struct Ay_Emu* this, int msec ); |
129 | 114 | ||
130 | // Skip n samples | 115 | // Skip n samples |
131 | blargg_err_t Track_skip( struct Ay_Emu* this, long n ); | 116 | blargg_err_t Track_skip( struct Ay_Emu* this, int n ); |
132 | 117 | ||
133 | // Set start time and length of track fade out. Once fade ends track_ended() returns | 118 | // Set start time and length of track fade out. Once fade ends track_ended() returns |
134 | // true. Fade time can be changed while track is playing. | 119 | // true. Fade time can be changed while track is playing. |
135 | void Track_set_fade( struct Ay_Emu* this, long start_msec, long length_msec ); | 120 | void Track_set_fade( struct Ay_Emu* this, int start_msec, int length_msec ); |
121 | |||
122 | // True if a track has reached its end | ||
123 | static inline bool Track_ended( struct Ay_Emu* this ) | ||
124 | { | ||
125 | return track_ended( &this->track_filter ); | ||
126 | } | ||
127 | |||
128 | // Disables automatic end-of-track detection and skipping of silence at beginning | ||
129 | static inline void Track_ignore_silence( struct Ay_Emu* this, bool disable ) | ||
130 | { | ||
131 | this->track_filter.silence_ignored_ = disable; | ||
132 | } | ||
136 | 133 | ||
137 | // Get track length in milliseconds | 134 | // Get track length in milliseconds |
138 | long Track_get_length( struct Ay_Emu* this, int n ); | 135 | int Track_get_length( struct Ay_Emu* this, int n ); |
139 | 136 | ||
140 | // Sound customization | 137 | // Sound customization |
141 | 138 | ||
142 | // Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. | 139 | // Adjust song tempo, where 1.0 = normal, 0.5 = half speed, 2.0 = double speed. |
143 | // Track length as returned by track_info() assumes a tempo of 1.0. | 140 | // Track length as returned by track_info() assumes a tempo of 1.0. |
144 | void Sound_set_tempo( struct Ay_Emu* this, int t ); | 141 | void Sound_set_tempo( struct Ay_Emu* this, int t ); |
145 | 142 | ||
146 | // Mute/unmute voice i, where voice 0 is first voice | 143 | // Mute/unmute voice i, where voice 0 is first voice |
147 | void Sound_mute_voice( struct Ay_Emu* this, int index, bool mute ); | 144 | void Sound_mute_voice( struct Ay_Emu* this, int index, bool mute ); |
148 | 145 | ||
149 | // Set muting state of all voices at once using a bit mask, where -1 mutes them all, | 146 | // Set muting state of all voices at once using a bit mask, where -1 mutes them all, |
150 | // 0 unmutes them all, 0x01 mutes just the first voice, etc. | 147 | // 0 unmutes them all, 0x01 mutes just the first voice, etc. |
151 | void Sound_mute_voices( struct Ay_Emu* this, int mask ); | 148 | void Sound_mute_voices( struct Ay_Emu* this, int mask ); |
@@ -168,5 +165,5 @@ static inline void disable_beeper( struct Ay_Emu *this ) | |||
168 | this->beeper_mask = 0; | 165 | this->beeper_mask = 0; |
169 | this->last_beeper = 0; | 166 | this->last_beeper = 0; |
170 | } | 167 | } |
171 | 168 | ||
172 | #endif | 169 | #endif |