![]() |
Mixxx
|
00001 #include "defs.h" 00002 #include "enginexfader.h" 00003 00004 float EngineXfader::getCalibration(float transform) 00005 { 00006 //get the transform_root of -3db (.5) 00007 return pow(.5, 1./transform); 00008 } 00009 00010 void EngineXfader::getXfadeGains(float &gain1, float &gain2, float xfadePosition, float transform, float calibration) 00011 { 00012 //Apply Calibration 00013 if(calibration != 0.) 00014 xfadePosition *= calibration; 00015 00016 float xfadePositionLeft = xfadePosition - calibration; 00017 float xfadePositionRight = xfadePosition + calibration; 00018 00019 if(xfadePositionLeft < 0) //on left side 00020 { 00021 xfadePositionLeft *= -1; 00022 gain2 = (1. - (1. * pow(xfadePositionLeft, transform))); 00023 } 00024 else 00025 gain2 = 1.; 00026 if(xfadePositionRight > 0) //right side 00027 { 00028 gain1 = (1. - (1. * pow(xfadePositionRight, transform))); 00029 } 00030 else 00031 gain1 = 1.; 00032 00033 //prevent phase reversal 00034 if(gain1 < 0.) 00035 gain1 = 0.; 00036 if(gain2 < 0.) 00037 gain2 = 0.; 00038 00039 }