cog/Frameworks/GME/gme/Spc_Sfm.h

87 lines
2.7 KiB
C
Raw Normal View History

2013-09-28 03:24:46 +00:00
// Super Nintendo SFM music file emulator
// Game_Music_Emu $vers
#ifndef SPC_SFM_H
#define SPC_SFM_H
#include "Music_Emu.h"
#include "higan/smp/smp.hpp"
2013-09-28 03:24:46 +00:00
#include "Spc_Filter.h"
#include "Bml_Parser.h"
#if GME_SPC_FAST_RESAMPLER
#include "Upsampler.h"
typedef Upsampler Spc_Emu_Resampler;
#else
#include "Fir_Resampler.h"
typedef Fir_Resampler<24> Spc_Emu_Resampler;
#endif
class Sfm_Emu : public Music_Emu {
public:
// Minimum allowed file size
enum { sfm_min_file_size = 8 + 65536 + 128 };
// The Super Nintendo hardware samples at 32kHz. Other sample rates are
// handled by resampling the 32kHz output; emulation accuracy is not affected.
enum { native_sample_rate = 32000 };
// This will serialize the current state of the emulator into a new SFM file
blargg_err_t serialize( std::vector<uint8_t> & out );
2013-09-28 03:24:46 +00:00
// Disables annoying pseudo-surround effect some music uses
void disable_surround( bool disable = true ) { smp.dsp.disable_surround( disable ); }
2013-09-28 03:24:46 +00:00
// Enables gaussian, cubic or sinc interpolation
2013-10-26 10:18:31 +00:00
void interpolation_level( int level = 0 ) { smp.dsp.spc_dsp.interpolation_level( level ); }
2013-09-28 03:24:46 +00:00
// Enables an analog signal simulation filter
void enable_filter( bool enable = true ) { _enable_filter = enable; if (enable) filter.clear(); }
// Enables native echo
void enable_echo(bool enable = true) { smp.dsp.spc_dsp.enable_echo(enable); }
virtual void mute_effects(bool mute) { enable_echo(!mute); }
SuperFamicom::SMP const* get_smp() const;
SuperFamicom::SMP * get_smp();
2013-09-28 03:24:46 +00:00
blargg_err_t hash_( Hash_Function& ) const;
static gme_type_t static_type() { return gme_sfm_type; }
2013-09-28 03:24:46 +00:00
// Implementation
public:
Sfm_Emu();
~Sfm_Emu();
protected:
virtual blargg_err_t load_mem_( byte const [], int );
virtual blargg_err_t track_info_( track_info_t*, int track ) const;
virtual blargg_err_t set_track_info_( const track_info_t*, int track );
2013-09-28 03:24:46 +00:00
virtual blargg_err_t set_sample_rate_( int );
virtual blargg_err_t start_track_( int );
virtual blargg_err_t play_( int, sample_t [] );
virtual blargg_err_t skip_( int );
virtual void mute_voices_( int );
virtual void set_tempo_( double );
virtual blargg_err_t save_( gme_writer_t, void* ) const;
2013-09-28 03:24:46 +00:00
private:
Spc_Emu_Resampler resampler;
Spc_Filter filter;
SuperFamicom::SMP smp;
2013-09-28 03:24:46 +00:00
bool _enable_filter;
2013-09-28 03:24:46 +00:00
Bml_Parser metadata;
void create_updated_metadata(Bml_Parser &out) const;
2013-09-28 03:24:46 +00:00
blargg_err_t play_and_filter( int count, sample_t out [] );
};
inline SuperFamicom::SMP const* Sfm_Emu::get_smp() const { return &smp; }
inline SuperFamicom::SMP * Sfm_Emu::get_smp() { return &smp; }
2013-10-26 10:18:31 +00:00
2013-09-28 03:24:46 +00:00
#endif // SPC_SFM_H