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