/gme/Vgm_Emu_Impl.h

http://game-music-emu.googlecode.com/ · C++ Header · 71 lines · 55 code · 14 blank · 2 comment · 1 complexity · fa7cea56f8a93f4b4e8878031176e659 MD5 · raw file

  1. // Low-level parts of Vgm_Emu
  2. // Game_Music_Emu 0.5.5
  3. #ifndef VGM_EMU_IMPL_H
  4. #define VGM_EMU_IMPL_H
  5. #include "Dual_Resampler.h"
  6. #include "Classic_Emu.h"
  7. #include "Ym2413_Emu.h"
  8. #include "Ym2612_Emu.h"
  9. #include "Sms_Apu.h"
  10. template<class Emu>
  11. class Ym_Emu : public Emu {
  12. protected:
  13. int last_time;
  14. short* out;
  15. enum { disabled_time = -1 };
  16. public:
  17. Ym_Emu() : last_time( disabled_time ), out( NULL ) { }
  18. void enable( bool b ) { last_time = b ? 0 : disabled_time; }
  19. bool enabled() const { return last_time != disabled_time; }
  20. void begin_frame( short* p );
  21. int run_until( int time );
  22. };
  23. class Vgm_Emu_Impl : public Classic_Emu, private Dual_Resampler {
  24. public:
  25. typedef Classic_Emu::sample_t sample_t;
  26. protected:
  27. enum { stereo = 2 };
  28. typedef int vgm_time_t;
  29. enum { fm_time_bits = 12 };
  30. typedef int fm_time_t;
  31. long fm_time_offset;
  32. int fm_time_factor;
  33. fm_time_t to_fm_time( vgm_time_t ) const;
  34. enum { blip_time_bits = 12 };
  35. int blip_time_factor;
  36. blip_time_t to_blip_time( vgm_time_t ) const;
  37. byte const* data;
  38. byte const* loop_begin;
  39. byte const* data_end;
  40. void update_fm_rates( long* ym2413_rate, long* ym2612_rate ) const;
  41. vgm_time_t vgm_time;
  42. byte const* pos;
  43. blip_time_t run_commands( vgm_time_t );
  44. int play_frame( blip_time_t blip_time, int sample_count, sample_t* buf );
  45. byte const* pcm_data;
  46. byte const* pcm_pos;
  47. int dac_amp;
  48. int dac_disabled; // -1 if disabled
  49. void write_pcm( vgm_time_t, int amp );
  50. Ym_Emu<Ym2612_Emu> ym2612;
  51. Ym_Emu<Ym2413_Emu> ym2413;
  52. Blip_Buffer blip_buf;
  53. Sms_Apu psg;
  54. Blip_Synth<blip_med_quality,1> dac_synth;
  55. friend class Vgm_Emu;
  56. };
  57. #endif