1
0

Fix chorus dry-gain calculation, more compact layout for analyser

This commit is contained in:
Geraint 2025-07-06 14:47:45 +01:00
parent 995339d2a2
commit 16b2ba955c
3 changed files with 39 additions and 4 deletions

View File

@ -99,9 +99,10 @@ struct ChorusSTFX : public BaseEffect {
auto wetDryFn = [](double mix, double width, bool isWet){
// Equal-power wet/dry fade
double m = isWet ? std::sin(M_PI*mix/2) : std::cos(M_PI*mix/2);
double m = isWet ? std::sin(M_PI*mix/2)/std::sqrt(6) : std::cos(M_PI*mix/2);
// Compensate for extra energy from stereo
return m/std::sqrt(6*(1 + width*width/2));
double mw = mix*width;
return m/std::sqrt((1 + mw*mw/2));
};
auto dry = block.smooth(wetDryFn(mix.from(), stereo.from(), false), wetDryFn(mix.to(), stereo.to(), false));
auto wet = block.smooth(wetDryFn(mix.from(), stereo.from(), true), wetDryFn(mix.to(), stereo.to(), true));

View File

@ -12,9 +12,16 @@
#include "../../stfx/clap/stfx-clap.h"
template<class Effect>
struct AnalyserSTFX : public signalsmith::basics::AnalyserSTFX<Effect> {
AnalyserSTFX() {
this->webPage += "?compact&columns";
}
};
static stfx::clap::Plugins plugins;
bool clap_init(const char *path) {
plugins.add<signalsmith::basics::AnalyserSTFX>({
plugins.add<AnalyserSTFX>({
.clap_version = CLAP_VERSION,
.id = "uk.co.signalsmith.basics.analyser",
.name = "[Basics] Analyser",

View File

@ -3,6 +3,9 @@
<head>
<title>Generic STFX UI</title>
<style>
:root {
font-size:12pt;
}
* {
box-sizing: border-box;
}
@ -117,6 +120,25 @@
width: 100%;
height: 100%;
}
/* Alternative layouts */
/* compact: more compact, */
:root.compact {
font-size: 9pt;
}
:root.compact #params {
padding: 0.5rem;
}
/* columns: horizontal layout, not vertical */
:root.columns body {
flex-direction: row;
}
:root.columns #params {
flex-direction: column;
}
:root.columns #header {
display: none;
}
</style>
</head>
<body>
@ -203,6 +225,11 @@
</div>
</template>
<script>
// Query keys set CSS class on the root
new URL(location).searchParams.forEach((value, key) => {
document.body.parentNode.classList.add(key);
});
let plotColours = ['#8CF', '#FC8', '#8D8', '#F9B'];
function freqScale(width, lowHz, highHz) {
// let a = -289.614, b = 1176.76, c = 15.3385, d = -0.552833; // Bark
@ -335,7 +362,7 @@
}
});
window.parent.postMessage(CBOR.encode("ready"), '*');
if (window.parent !== window) window.parent.postMessage(CBOR.encode("ready"), '*');
// Monitor framerate and send every 200ms
let frameMs = 100, prevFrame = Date.now(), prevSent = 100;