SoundParser.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #include "SoundParser.h"
  2. #include "engine/SoundManager.h"
  3. #include "../../common/Logger.h"
  4. SoundParser *SOUND_PARSER = NULL;
  5. SoundParser::SoundParser()
  6. {
  7. }
  8. SoundParser::~SoundParser()
  9. {
  10. }
  11. void
  12. SoundParser::Update()
  13. {
  14. }
  15. void
  16. SoundParser::UpdateSpu()
  17. {
  18. /*
  19. spu = w[8004ff84];
  20. T2 = 0;
  21. T6 = 0;
  22. T5 = 0;
  23. T4 = 0;
  24. for( int channel_id = 0; channel_id < 24; ++channel_id )
  25. {
  26. u16 spu_update_flags = m_ChannelData[ channel_id ].spu_update_flags;
  27. if( spu_update_flags & SPU_VOLUME )
  28. {
  29. LOGGER->Log( "UpdateSpu::SPU_VOLUME channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].left_volume ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].right_volume ) + ".\n" );
  30. SOUNDMAN->SetVoiceVolume( channel_id, m_ChannelData[ channel_id ].left_volume, m_ChannelData[ channel_id ].right_volume );
  31. }
  32. if( spu_update_flags & SPU_PITCH )
  33. {
  34. LOGGER->Log( "UpdateSpu::SPU_PITCH channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].pitch ) + ".\n" );
  35. SOUNDMAN->SetVoicePitch( channel_id, m_ChannelData[ channel_id ].pitch );
  36. }
  37. if( spu_update_flags & SPU_OFFSET )
  38. {
  39. LOGGER->Log( "UpdateSpu::SPU_OFFSET channel start " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].start_offset ) + " >>> 8 loop " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].loop_offset ) + " >>> 8.\n" );
  40. SOUNDMAN->SetVoiceStartAddress( channel_id, m_ChannelData[ channel_id ].start_offset >>> 8 );
  41. SOUNDMAN->SetVoiceLoopAddress( channel_id, m_ChannelData[ channel_id ].loop_offset >>> 8 );
  42. }
  43. if( spu_update_flags & SPU_ATTACK )
  44. {
  45. // +24 >> 2 attack mode
  46. // +27 attack rate
  47. //LOGGER->Log( "UpdateSpu::SPU_ATTACK_RATE|SPU_ATTACK_MODE channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].attack_rate ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].attack_mode ) + ".\n" );
  48. SOUNDMAN->SetVoiceAttackRate( channel_id, channel_data[ channel_id ].attack_rate, ( SoundManager::SpuRateMode )( channel_data[ channel_id ].attack_mode >> 2) );
  49. }
  50. if (spu_update_flags & 0020)
  51. {
  52. [spu + channel_id * 10 + 8] = h((hu[spu + channel_id * 10 + 8] & ff0f) + (bu[channel_data + 28] << 4)); // decay rate
  53. }
  54. if (spu_update_flags & 0040)
  55. {
  56. // +25 >> 1 sustain mode
  57. // +29 sustain rate
  58. [spu + channel_id * 10 + a] = h((hu[spu + channel_id * 10 + a] & 003f) + (bu[channel_data + 29] << 6) + ((bu[channel_data + 25] >> 1) << e)); // sustain mode and rate
  59. }
  60. if (spu_update_flags & 0080)
  61. {
  62. [spu + channel_id * 10 + a] = h((hu[spu + channel_id * 10 + a] & ffc0) + bu[channel_data + 2a] + ((bu[channel_data + 26] >> 2) << 5)); // release mode and rate
  63. }
  64. if (spu_update_flags & 0100)
  65. {
  66. [spu + channel_id * 10 + 8] = h((hu[spu + channel_id * 10 + 8] & fff0) + bu[channel_data + 2b]); // sustain level
  67. }
  68. T2 = T2 | spu_update_flags & 7000;
  69. [channel_data + 6] = h(0);
  70. V0 = hu[channel_data + 2];
  71. T4 = T4 | (((V0 >> 4) & 1) << channel_id);
  72. T5 = T5 | (((V0 >> 5) & 1) << channel_id);
  73. T6 = T6 | (((V0 >> 6) & 1) << channel_id);
  74. }
  75. if (T2 & ffff)
  76. {
  77. if (T2 & 1000)
  78. {
  79. [spu + 190] = h(T4); // Channel FM (pitch lfo) mode (0-15)
  80. [spu + 192] = h(T4 >> 10); // Channel FM (pitch lfo) mode (16-23)
  81. }
  82. if (T2 & 2000)
  83. {
  84. [spu + 194] = h(T5); // Channel Noise mode (0-15)
  85. [spu + 196] = h(T5 >> 10); // Channel Noise mode (16-23)
  86. }
  87. if (T2 & 4000)
  88. {
  89. [spu + 198] = h(T6); // Channel Reverb mode (0-15)
  90. [spu + 19a] = h(T6 >> 10); // Channel Reverb mode (16-23)
  91. }
  92. }
  93. V0 = w[80058b98];
  94. if (V0 != 0)
  95. {
  96. [spu + 188] = h(V0); // Voice ON (0-15)
  97. [spu + 18a] = h(V0 >> 10); // Voice ON (16-23)
  98. [80058b98] = w(0);
  99. }*/
  100. }