Fix pan law for Mix split.

This commit is contained in:
Robin E. R. Davies
2026-01-15 11:46:56 -05:00
parent 6a724a092d
commit 474a5de9aa
2 changed files with 40 additions and 6 deletions
+16
View File
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "CMake: clean rebuild",
"command": "cleanRebuild",
"targets": [
"all"
],
"group": "build",
"problemMatcher": [],
"detail": "CMake template clean rebuild task"
}
]
}
+24 -6
View File
@@ -327,6 +327,21 @@ void SplitEffect::mixTo(float value)
this->targetBlendLBottom = this->targetBlendRBottom = blend; this->targetBlendLBottom = this->targetBlendRBottom = blend;
mixToTarget(); mixToTarget();
} }
static inline float applyPan(float pan, float*left, float*right) {
float panClipped = pan;
if (panClipped < -1) panClipped = -1;
if (panClipped > 1) panClipped = 1;
if (pan <= 0) {
*left = 1.0f;
*right = 1.0f + panClipped;
} else {
*left = 1.0f - panClipped;
*right = 1.0f;
}
return panClipped;
}
void SplitEffect::mixTo(float panL, float volL, float panR, float volR) void SplitEffect::mixTo(float panL, float volL, float panR, float volR)
{ {
float aTop = (volL <= SPLIT_DB_MIN) ? 0 : db2a(volL); float aTop = (volL <= SPLIT_DB_MIN) ? 0 : db2a(volL);
@@ -339,12 +354,15 @@ void SplitEffect::mixTo(float panL, float volL, float panR, float volR)
} }
else else
{ {
float blendTop = (panL + 1) * 0.5; float panTopL, panTopR;
float blendBottom = (panR + 1) * 0.5; applyPan(panL,&panTopL, &panTopR);
this->targetBlendLTop = (1 - blendTop) * aTop; float panBottomL, panBottomR;
this->targetBlendRTop = (blendTop)*aTop; applyPan(panR,&panBottomL, &panBottomR);
this->targetBlendLBottom = (1 - blendBottom) * aBottom;
this->targetBlendRBottom = (blendBottom)*aBottom; this->targetBlendLTop = panTopL * aTop;
this->targetBlendRTop = panTopR*aTop;
this->targetBlendLBottom = panBottomL * aBottom;
this->targetBlendRBottom = panBottomR * aBottom;
} }
mixToTarget(); mixToTarget();
} }