comparison Plugins/Input/console/Spc_Emu.h @ 493:c04dff121e1d trunk

[svn] hostile merge, phase 2: reimport based on new plugin code
author nenolod
date Tue, 24 Jan 2006 20:19:01 -0800
parents
children 61d78065b630
comparison
equal deleted inserted replaced
492:ccb68bad47b2 493:c04dff121e1d
1
2 // Super Nintendo (SNES) SPC music file emulator
3
4 // Game_Music_Emu 0.3.0
5
6 #ifndef SPC_EMU_H
7 #define SPC_EMU_H
8
9 #include "Fir_Resampler.h"
10 #include "Music_Emu.h"
11 #include "Snes_Spc.h"
12
13 class Spc_Emu : public Music_Emu {
14 enum { trailer_offset = 0x10200 };
15 public:
16 // A gain of 1.0 results in almost no clamping. Default gain roughly
17 // matches volume of other emulators.
18 Spc_Emu( double gain = 1.4 );
19
20 // The Super Nintendo hardware samples at 32kHz. Other sample rates are
21 // handled by resampling the 32kHz output; emulation accuracy is not affected.
22 enum { native_sample_rate = 32000 };
23
24 // SPC file header
25 struct header_t
26 {
27 char tag [35];
28 byte format;
29 byte version;
30 byte pc [2];
31 byte a, x, y, psw, sp;
32 byte unused [2];
33 char song [32];
34 char game [32];
35 char dumper [16];
36 char comment [32];
37 byte date [11];
38 char len_secs [3];
39 byte fade_msec [5];
40 char author [32];
41 byte mute_mask;
42 byte emulator;
43 byte unused2 [45];
44
45 enum { track_count = 1 };
46 enum { copyright = 0 }; // no copyright field
47 };
48 BOOST_STATIC_ASSERT( sizeof (header_t) == 0x100 );
49
50 // Load SPC data
51 blargg_err_t load( Data_Reader& );
52
53 // Load SPC using already-loaded header and remaining data
54 blargg_err_t load( header_t const&, Data_Reader& );
55
56 // Header for currently loaded SPC
57 header_t const& header() const { return *(header_t*) spc_data.begin(); }
58
59 // Pointer and size for trailer data
60 byte const* trailer() const { return &spc_data [trailer_offset]; }
61 long trailer_size() const { return spc_data.size() - trailer_offset; }
62
63 // If true, prevents channels and global volumes from being phase-negated
64 void disable_surround( bool disable = true );
65
66 public:
67 ~Spc_Emu();
68 blargg_err_t set_sample_rate( long );
69 void mute_voices( int );
70 void start_track( int );
71 void play( long, sample_t* );
72 void skip( long );
73 const char** voice_names() const;
74 public:
75 // deprecated
76 blargg_err_t init( long r, double gain = 1.4 ) { return set_sample_rate( r ); }
77 private:
78 blargg_vector<byte> spc_data;
79 Fir_Resampler<24> resampler;
80 Snes_Spc apu;
81 };
82
83 inline void Spc_Emu::disable_surround( bool b ) { apu.disable_surround( b ); }
84
85 #endif
86