"Fossies" - the Fresh Open Source Software Archive

Member "audacious-plugins-3.10.1/src/console/Spc_Emu.h" (26 Dec 2018, 2099 Bytes) of package /linux/misc/audacious-plugins-3.10.1.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Spc_Emu.h" see the Fossies "Dox" file reference documentation.

    1 // Super Nintendo SPC music file emulator
    2 
    3 // Game_Music_Emu 0.5.5
    4 #ifndef SPC_EMU_H
    5 #define SPC_EMU_H
    6 
    7 #include "Fir_Resampler.h"
    8 #include "Music_Emu.h"
    9 #include "Snes_Spc.h"
   10 #include "Spc_Filter.h"
   11 
   12 class Spc_Emu : public Music_Emu {
   13 public:
   14     // The Super Nintendo hardware samples at 32kHz. Other sample rates are
   15     // handled by resampling the 32kHz output; emulation accuracy is not affected.
   16     enum { native_sample_rate = 32000 };
   17 
   18     // SPC file header
   19     enum { header_size = 0x100 };
   20     struct header_t
   21     {
   22         char tag [35];
   23         byte format;
   24         byte version;
   25         byte pc [2];
   26         byte a, x, y, psw, sp;
   27         byte unused [2];
   28         char song [32];
   29         char game [32];
   30         char dumper [16];
   31         char comment [32];
   32         byte date [11];
   33         byte len_secs [3];
   34         byte fade_msec [4];
   35         char author [32]; // sometimes first char should be skipped (see official SPC spec)
   36         byte mute_mask;
   37         byte emulator;
   38         byte unused2 [46];
   39     };
   40 
   41     // Header for currently loaded file
   42     header_t const& header() const { return *(header_t const*) file_data; }
   43 
   44     // Prevents channels and global volumes from being phase-negated
   45     void disable_surround( bool disable = true );
   46 
   47     static gme_type_t static_type() { return gme_spc_type; }
   48 
   49 public:
   50     // deprecated
   51     using Music_Emu::load;
   52     blargg_err_t load( header_t const& h, Data_Reader& in ) // use Remaining_Reader
   53             { return load_remaining_( &h, sizeof h, in ); }
   54     byte const* trailer() const; // use track_info()
   55     long trailer_size() const;
   56 
   57 public:
   58     Spc_Emu();
   59     ~Spc_Emu();
   60 protected:
   61     blargg_err_t load_mem_( byte const*, long );
   62     blargg_err_t track_info_( track_info_t*, int track ) const;
   63     blargg_err_t set_sample_rate_( long );
   64     blargg_err_t start_track_( int );
   65     blargg_err_t play_( long, sample_t* );
   66     blargg_err_t skip_( long );
   67     void mute_voices_( int );
   68     void set_tempo_( double );
   69     void enable_accuracy_( bool );
   70 private:
   71     byte const* file_data;
   72     long        file_size;
   73     Fir_Resampler<24> resampler;
   74     SPC_Filter filter;
   75     Snes_Spc apu;
   76 
   77     blargg_err_t play_and_filter( long count, sample_t out [] );
   78 };
   79 
   80 inline void Spc_Emu::disable_surround( bool b ) { apu.disable_surround( b ); }
   81 
   82 #endif