diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index 7cd30cfd..03bc23ca 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -524,6 +524,11 @@ class DivDispatch { // this is a special case definition. only use it for f-num/block-based chips. #define NOTE_FNUM_BLOCK(x,bits) parent->calcBaseFreqFNumBlock(chipClock,CHIP_FREQBASE,x,bits) +// this is for volume scaling calculation. +#define VOL_SCALE_LINEAR_BROKEN(x,y,range) ((parent->song.newVolumeScaling)?(((x)*(y))/(range)):(CLAMP(((x)+(y))-(range),0,(range)))) +#define VOL_SCALE_LINEAR(x,y,range) (((x)*(y))/(range)) +#define VOL_SCALE_LOG(x,y,range) ((parent->song.newVolumeScaling)?(CLAMP(((x)+(y))-(range),0,(range))):(((x)*(y))/(range))) + // these are here for convenience. // it is encouraged to use these, since you get an exact value this way. // - NTSC colorburst: 3.58MHz diff --git a/src/ta-utils.h b/src/ta-utils.h index 3a619248..feddbc1e 100644 --- a/src/ta-utils.h +++ b/src/ta-utils.h @@ -40,6 +40,7 @@ typedef std::string String; #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) +#define CLAMP(x,xMin,xMax) (MIN(MAX((x),(xMin)),(xMax))) typedef std::wstring WString;