1
// Sega Master System/Mark III, Sega Genesis/Mega Drive, BBC Micro VGM music file emulator
3
// Game_Music_Emu 0.5.2
7
#include "Vgm_Emu_Impl.h"
9
// Emulates VGM music using SN76489/SN76496 PSG, YM2612, and YM2413 FM sound chips.
10
// Supports custom sound buffer and frequency equalization when VGM uses just the PSG.
11
// FM sound chips can be run at their proper rates, or slightly higher to reduce
12
// aliasing on high notes. Currently YM2413 support requires that you supply a
13
// YM2413 sound chip emulator. I can provide one I've modified to work with the library.
14
class Vgm_Emu : public Vgm_Emu_Impl {
16
// True if custom buffer and custom equalization are supported
17
// TODO: move into Music_Emu and rename to something like supports_custom_buffer()
18
bool is_classic_emu() const { return !uses_fm; }
20
// Disable running FM chips at higher than normal rate. Will result in slightly
21
// more aliasing of high notes.
22
void disable_oversampling( bool disable = true ) { disable_oversampling_ = disable; }
25
enum { header_size = 0x40 };
34
byte track_duration [4];
36
byte loop_duration [4];
38
byte noise_feedback [2];
47
// Header for currently loaded file
48
header_t const& header() const { return *(header_t const*) data; }
50
static gme_type_t static_type() { return gme_vgm_type; }
55
blargg_err_t load( header_t const& h, Data_Reader& in ) // use Remaining_Reader
56
{ return load_remaining_( &h, sizeof h, in ); }
57
byte const* gd3_data( int* size_out = 0 ) const; // use track_info()
63
blargg_err_t track_info_( track_info_t*, int track ) const;
64
blargg_err_t load_mem_( byte const*, long );
65
blargg_err_t set_sample_rate_( long sample_rate );
66
blargg_err_t start_track_( int );
67
blargg_err_t play_( long count, sample_t* );
68
blargg_err_t run_clocks( blip_time_t&, int );
69
void set_tempo_( double );
70
void mute_voices_( int mask );
71
void set_voice( int, Blip_Buffer*, Blip_Buffer*, Blip_Buffer* );
72
void update_eq( blip_eq_t const& );
74
// removed; use disable_oversampling() and set_tempo() instead
75
Vgm_Emu( bool oversample, double tempo = 1.0 );
79
bool disable_oversampling_;
81
blargg_err_t setup_fm();