SoundFilePlayConfig.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * SoundFilePlayConfig.cpp
  3. * -----------------------
  4. * Purpose: Configuration of sound levels, pan laws, etc... for various mix configurations.
  5. * Notes : (currently none)
  6. * Authors: Olivier Lapicque
  7. * OpenMPT Devs
  8. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  9. */
  10. #include "stdafx.h"
  11. #include "Mixer.h"
  12. #include "SoundFilePlayConfig.h"
  13. OPENMPT_NAMESPACE_BEGIN
  14. CSoundFilePlayConfig::CSoundFilePlayConfig()
  15. {
  16. setVSTiVolume(1.0f);
  17. SetMixLevels(MixLevels::Compatible);
  18. }
  19. void CSoundFilePlayConfig::SetMixLevels(MixLevels mixLevelType)
  20. {
  21. switch (mixLevelType)
  22. {
  23. // Olivier's version gives us floats in [-0.5; 0.5] and slightly saturates VSTis.
  24. case MixLevels::Original:
  25. setVSTiAttenuation(1.0f); // no attenuation
  26. setIntToFloat(1.0f/static_cast<float>(1<<28));
  27. setFloatToInt(static_cast<float>(1<<28));
  28. setGlobalVolumeAppliesToMaster(false);
  29. setUseGlobalPreAmp(true);
  30. setPanningMode(PanningMode::Undetermined);
  31. setDisplayDBValues(false);
  32. setNormalSamplePreAmp(256.0f);
  33. setNormalVSTiVol(100.0f);
  34. setNormalGlobalVol(128.0f);
  35. setExtraSampleAttenuation(MIXING_ATTENUATION);
  36. break;
  37. // Ericus' version gives us floats in [-0.06;0.06] and requires attenuation to
  38. // avoid massive VSTi saturation.
  39. case MixLevels::v1_17RC1:
  40. setVSTiAttenuation(32.0f);
  41. setIntToFloat(1.0f/static_cast<float>(0x07FFFFFFF));
  42. setFloatToInt(static_cast<float>(0x07FFFFFFF));
  43. setGlobalVolumeAppliesToMaster(false);
  44. setUseGlobalPreAmp(true);
  45. setPanningMode(PanningMode::Undetermined);
  46. setDisplayDBValues(false);
  47. setNormalSamplePreAmp(256.0f);
  48. setNormalVSTiVol(100.0f);
  49. setNormalGlobalVol(128.0f);
  50. setExtraSampleAttenuation(MIXING_ATTENUATION);
  51. break;
  52. // 1.17RC2 gives us floats in [-1.0; 1.0] and hopefully plays VSTis at
  53. // the right volume... but we attenuate by 2x to approx. match sample volume.
  54. case MixLevels::v1_17RC2:
  55. setVSTiAttenuation(2.0f);
  56. setIntToFloat(1.0f/MIXING_SCALEF);
  57. setFloatToInt(MIXING_SCALEF);
  58. setGlobalVolumeAppliesToMaster(true);
  59. setUseGlobalPreAmp(true);
  60. setPanningMode(PanningMode::Undetermined);
  61. setDisplayDBValues(false);
  62. setNormalSamplePreAmp(256.0f);
  63. setNormalVSTiVol(100.0f);
  64. setNormalGlobalVol(128.0f);
  65. setExtraSampleAttenuation(MIXING_ATTENUATION);
  66. break;
  67. // 1.17RC3 ignores the horrible global, system-specific pre-amp,
  68. // treats panning as balance to avoid saturation on loud sample (and because I think it's better :),
  69. // and allows display of attenuation in decibels.
  70. default:
  71. case MixLevels::v1_17RC3:
  72. setVSTiAttenuation(1.0f);
  73. setIntToFloat(1.0f/MIXING_SCALEF);
  74. setFloatToInt(MIXING_SCALEF);
  75. setGlobalVolumeAppliesToMaster(true);
  76. setUseGlobalPreAmp(false);
  77. setPanningMode(PanningMode::SoftPanning);
  78. setDisplayDBValues(true);
  79. setNormalSamplePreAmp(128.0f);
  80. setNormalVSTiVol(128.0f);
  81. setNormalGlobalVol(256.0f);
  82. setExtraSampleAttenuation(0);
  83. break;
  84. // A mixmode that is intended to be compatible to legacy trackers (IT/FT2/etc).
  85. // This is basically derived from mixmode 1.17 RC3, with panning mode and volume levels changed.
  86. // Sample attenuation is the same as in Schism Tracker (more attenuation than with RC3, thus VSTi attenuation is also higher).
  87. case MixLevels::Compatible:
  88. case MixLevels::CompatibleFT2:
  89. setVSTiAttenuation(0.75f);
  90. setIntToFloat(1.0f/MIXING_SCALEF);
  91. setFloatToInt(MIXING_SCALEF);
  92. setGlobalVolumeAppliesToMaster(true);
  93. setUseGlobalPreAmp(false);
  94. setPanningMode(mixLevelType == MixLevels::Compatible ? PanningMode::NoSoftPanning : PanningMode::FT2Panning);
  95. setDisplayDBValues(true);
  96. setNormalSamplePreAmp(mixLevelType == MixLevels::Compatible ? 256.0f : 192.0f);
  97. setNormalVSTiVol(mixLevelType == MixLevels::Compatible ? 256.0f : 192.0f);
  98. setNormalGlobalVol(256.0f);
  99. setExtraSampleAttenuation(1);
  100. break;
  101. }
  102. }
  103. OPENMPT_NAMESPACE_END