SoundParser.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef SOUND_PARSER_H
  2. #define SOUND_PARSER_H
  3. #include <Ogre.h>
  4. #include "common/File.h"
  5. #include "common/TypeDefine.h"
  6. class SoundParser
  7. {
  8. public:
  9. SoundParser();
  10. virtual ~SoundParser();
  11. void Update();
  12. // debug routines
  13. void DumpSequenceData( const Ogre::String& file );
  14. private:
  15. enum SpuParameter
  16. {
  17. SPU_VOLUME = 1 << 0, // 0x0001
  18. SPU_PITCH = 1 << 2, // 0x0004
  19. SPU_OFFSET = 1 << 3, // 0x0008
  20. SPU_ATTACK = 1 << 4, // 0x0010
  21. SPU_DECAY_RATE = 1 << 5, // 0x0020
  22. SPU_SUSTAIN = 1 << 6, // 0x0040
  23. SPU_RELEASE = 1 << 7, // 0x0080
  24. SPU_SUSTAIN_LEVEL = 1 << 8, // 0x0100
  25. SPU_FM_MODE = 1 << 12, // 0x1000
  26. SPU_NOISE_MODE = 1 << 13, // 0x2000
  27. SPU_REVERB_MODE = 1 << 14, // 0x4000
  28. };
  29. struct ChannelData
  30. {
  31. // 0xc4 PART
  32. // 0x06
  33. u16 spu_update_flags;
  34. // 0x08
  35. u16 left_volume;
  36. // 0x0a
  37. u16 right_volume;
  38. // 0x14
  39. u16 pitch;
  40. // 0x1c
  41. u32 start_offset;
  42. // 0x20
  43. u32 loop_offset;
  44. // 0x24
  45. u8 attack_mode;
  46. // 0x27
  47. u8 attack_rate;
  48. // 0xf0 [][][][]
  49. u32 sustain_mode;
  50. // 0xf4 [][][][]
  51. u32 release_mode;
  52. // 0xfc [][]
  53. u16 decay_rate;
  54. // 0xfe [][]
  55. u16 sustain_level;
  56. // 0x100 [][]
  57. u16 sustain_rate;
  58. // 0x102 [][]
  59. u16 release_rate;
  60. };
  61. ChannelData m_ChannelData[ 24 ];
  62. private:
  63. void UpdateSpu();
  64. };
  65. extern SoundParser *SOUND_PARSER;
  66. #endif // SOUND_PARSER_H