Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/bank.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ struct Bank {
}

// Highest index that is playable right now. Returns -1 when nothing is ready yet, which the
// audio thread answers with ramped silence rather than with dry signal.
// audio thread answers with ramped silence rather than with dry signal — unless the bank is
// empty (count 0), where nothing will ever be ready and the input passes through dry.
int highestReady() const
{
int highest = -1;
Expand Down
25 changes: 22 additions & 3 deletions core/crossfadeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,19 @@ void CrossfadeEngine::processNative(NAM_SAMPLE **in, NAM_SAMPLE **out, int numFr
const int highest = mBank ? mBank->highestReady() : -1;
mHaveReady = highest >= 0;
if (!mHaveReady) {
// Ramp to silence, never to dry signal: dry would be the wrong level and would jump the
// moment a model landed.
// Two different states arrive here. With no capture assigned at all — no bank, or the
// empty bank a Clear publishes — nothing is ever going to land, so the input passes
// through dry, as the parent plug-in does with no model loaded. That is what lets an
// instance be used for its cabinet alone. With a capture assigned but not yet built,
// ramp to silence instead: dry would be the wrong level and would jump the moment the
// model landed. Either way the dry gate is ramped, so neither change clicks.
const bool assigned = mBank && mBank->count > 0;
const double dryTarget = assigned ? 0.0 : 1.0;
for (int i = 0; i < numFrames; ++i) {
mReadyMix = std::max(0.0, mReadyMix - mReadyStep);
dst[i] = src[i] * mReadyMix;
mDryMix = dryTarget > mDryMix ? std::min(dryTarget, mDryMix + mReadyStep)
: std::max(dryTarget, mDryMix - mReadyStep);
dst[i] = src[i] * mDryMix;
}
return;
}
Expand Down Expand Up @@ -532,6 +540,17 @@ void CrossfadeEngine::processNative(NAM_SAMPLE **in, NAM_SAMPLE **out, int numFr
chunkOut[i] *= mReadyMix;
}

// A capture landed while dry signal was still sounding — a bank whose first entry was
// already built by the time it was polled. Fade the dry signal out underneath the ready
// gate rather than cutting it. chunkIn is still intact here: the engine is never handed
// the same buffer for input and output. Zero in steady state, so this costs nothing then.
if (mDryMix > 0.0) {
for (int i = 0; i < n; ++i) {
mDryMix = std::max(0.0, mDryMix - mReadyStep);
chunkOut[i] += chunkIn[i] * mDryMix;
}
}

// --- advance the position -------------------------------------------------------------
pos = mPos;
if (std::fabs(delta) <= step * n) {
Expand Down
22 changes: 14 additions & 8 deletions core/crossfadeengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,22 @@ class CrossfadeEngine : public NativeBlockProcessor
}
// Normalized index of the capture that is actually sounding — the nearer branch, not the knob.
double activeIndexNorm() const;
// True once at least one entry is playable. Until then the engine outputs ramped silence, not
// dry signal: passing the input through and then dropping a model on top of it would jump in
// level the instant the first entry landed.
// True once at least one entry is playable. Until then an engine with a capture assigned
// outputs ramped silence, not dry signal: passing the input through and then dropping a model
// on top of it would jump in level the instant the first entry landed. An engine with NO
// capture assigned passes its input through dry instead, as the parent plug-in does with no
// model loaded; that is not "playable" in this sense, because no model is running.
bool playable() const
{
return mReadyMix > 0.0 || mHaveReady;
}
// True once this engine has actually put a sample into the output. Distinct from playable():
// the rack uses it to tell "nothing is being heard yet" from "something is", because adopting
// a channel outright is only free while nothing is audible.
// True once this engine has actually put a sample into the output: a model's, or the dry
// pass-through of an engine with nothing assigned. Distinct from playable(): the rack uses it
// to tell "nothing is being heard yet" from "something is", because adopting a channel
// outright is only free while nothing is audible, and dry signal is audible.
bool sounding() const
{
return mReadyMix > 0.0;
return mReadyMix > 0.0 || mDryMix > 0.0;
}
// True when the ready gate is fully open, so this engine's output is its models' output and
// not a ramp of it. The channel fade must not start before this: a fade into a signal that is
Expand Down Expand Up @@ -188,7 +191,10 @@ class CrossfadeEngine : public NativeBlockProcessor

double mSlewStep = 0.0; // position units per sample while following the knob
double mReadyMix = 0.0; // ramped 0 .. 1 gate over "a playable entry exists"
double mReadyStep = 1.0;
// Ramped 0 .. 1 gate over "no capture is assigned, so pass the input through". Starts closed,
// so a restored project that is still building never lets a dry blip through first.
double mDryMix = 0.0;
double mReadyStep = 1.0; // shared by both gates
bool mHaveReady = false;

int mOutputMode = 0;
Expand Down
57 changes: 54 additions & 3 deletions core/tools/rations_ircheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ int main(int argc, char **argv)
}

// The cabinet stage is what this tool measures, but it measures it through the whole chain, so
// the channels still have to be sounding something: with no captures loaded the rack outputs
// ramped silence and every blend measurement would be taken on nothing.
// the channels still have to be sounding an amp: with no captures loaded the rack passes the
// DI through dry and every blend measurement would be taken on that instead.
opt.captures = RationsTools::captureRoot(opt.captures);
if (opt.captures.empty()) {
RationsTools::printCaptureUsage("rations_ircheck");
Expand Down Expand Up @@ -519,13 +519,64 @@ int main(int argc, char **argv)
++failures;
}

// --- the cabinet on its own, with no capture loaded anywhere ---------------------------------
// The parent plug-in passes its input through when no model is loaded, so one instance can be
// a cabinet and nothing else in a chain of other plug-ins. That only works if a channel with
// no capture assigned passes its input through dry instead of gating to silence: the IR then
// convolves the DI rather than nothing. Every channel is cleared the way the settings page
// clears one, and the clear is given time to reach the audio thread, which polls for it.
{
printf("== no capture loaded\n");
bool cleared = true;
for (int c = 0; c < Rations::kChannelCount; ++c)
cleared =
RationsTools::sendCaptureLoad(hostContext, component, c, "", false) && cleared;
cleared = sendIr(hostContext, component, 0, "") && cleared;
cleared = sendIr(hostContext, component, 1, "") && cleared;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
renderer.run(0.0); // settle the dry gate's ramp before measuring

const std::vector<float> dry = renderer.run(0.0);
const double inRms = rms(renderer.signal, renderer.flushSamples);
const double dryRms = rms(dry, 0);
// Not bit-exact: the tone stack is still in, at its defaults. It is close to flat there,
// so a few dB is the margin against "the amp gated to silence" (hundreds of dB), not a
// claim about the tone stack.
const bool passes = cleared && std::fabs(toDb(dryRms) - toDb(inRms)) < 3.0;
printf(" %s nothing loaded passes the input through (in %+.2f dB, out %+.2f dB)\n",
passes ? "ok " : "FAIL", toDb(inRms), toDb(dryRms));
if (!passes)
++failures;

const std::string &ir = opt.pairs.front().first;
const bool loaded = sendIr(hostContext, component, 0, ir);
renderer.run(0.0);
const std::vector<float> cab = renderer.run(0.0);
const double cabRms = rms(cab, 0);
// Audible, and the cabinet's sound rather than the dry signal's: an IR is a filter, so it
// must change the samples.
const bool sounds = loaded && toDb(cabRms) > -60.0 && !identical(cab, dry);
printf(" %s %s alone, no capture: %s (out %+.2f dB)\n", sounds ? "ok " : "FAIL",
baseName(ir),
!loaded ? "THE PLUG-IN REFUSED THE IR"
: toDb(cabRms) <= -60.0 ? "SILENT"
: identical(cab, dry) ? "THE IR DID NOT CHANGE THE AUDIO"
: "the cabinet sounds",
toDb(cabRms));
if (!sounds)
++failures;
sendIr(hostContext, component, 0, "");
printf("\n");
}

processor->setProcessing(false);
component->setActive(false);

if (failures) {
printf("FAILED - %d check%s did not hold\n", failures, failures == 1 ? "" : "s");
return 1;
}
printf("PASSED - the second slot is invisible to a one-IR user, and the blend is level\n");
printf("PASSED - the second slot is invisible to a one-IR user, the blend is level, and the "
"cabinet works with no capture loaded\n");
return 0;
}
5 changes: 3 additions & 2 deletions core/tools/toolcaptures.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ inline bool sendCaptureLoad(Steinberg::Vst::HostApplication &host,
}

// All four channels from one root, each from its own subdirectory. A channel whose directory is
// missing is not an error here: ModelBank warns and that channel outputs ramped silence, which is
// the behaviour a tool asserting on a partial bank set wants to see rather than be spared.
// missing is not an error here: ModelBank warns and that channel stays empty, passing its input
// through dry, which is the behaviour a tool asserting on a partial bank set wants to see rather
// than be spared.
// Publish a Slim setting the way the settings overlay does: an IMessage on the message thread,
// never the parameter queue, because applying it rebuilds every capture in every loaded bank.
// The caller has to WAIT afterwards - a rebuilt bank is republished before any entry is ready, so
Expand Down
8 changes: 5 additions & 3 deletions products/rack/src/rationsprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ tresult PLUGIN_API RationsProcessor::initialize(FUnknown *context)
// Nothing is loaded here, and that is the change this build is about. The plug-in used to ship
// four banks inside its own bundle and request all four at this point; it ships none now, so a
// fresh instance comes up with four empty channels and the settings page asking for them. Empty
// is a state the rack already handles correctly - it answers with ramped silence, never with
// dry signal, which would jump in level the instant a model landed - so there is nothing to add
// here beyond not doing it.
// is a state the rack already handles: a channel with no capture assigned passes its input
// through dry, as the parent plug-in does with no model loaded, so an instance can be used for
// its cabinet alone. Only a capture that is assigned but still building answers with ramped
// silence, because dry signal there would jump in level the instant the model landed. So there
// is nothing to add here beyond not loading anything.
//
// The four workers still exist and still start now. What makes the build breadth-first is one
// worker per channel, and that is a property of the rack rather than of when the loads arrive:
Expand Down
3 changes: 2 additions & 1 deletion products/rack/src/rationsprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class RationsProcessor : public Steinberg::Vst::AudioEffect
void sendMidiTable(); // message thread only
void allocateBuffers(); // message thread only
// Load one channel's bank from a folder (isDirectory) or a single file. An empty path clears
// the channel, which the rack answers with ramped silence. Message thread only — file I/O.
// the channel, which the rack answers by passing its input through dry. Message thread only —
// file I/O.
void loadCaptureSource(int channel, const std::string &path, bool isDirectory);
// Publish the output section to the rack. Safe from EITHER thread - it is nothing but atomic
// stores - which it has to be, because a radio click on the settings page arrives as a host
Expand Down
4 changes: 2 additions & 2 deletions products/rack/tools/rations_midicheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ int main(int argc, char **argv)

// A learned footswitch has to reach the channel that is actually SOUNDING, not merely the
// parameter, and this tool asserts exactly that — so the four channels have to have something
// to sound. With nothing loaded every channel is ramped silence and the assertion would pass
// against four identical nothings.
// to sound. With nothing loaded every channel passes the same dry input through and the
// assertion would pass against four identical signals.
opt.captures = RationsTools::captureRoot(opt.captures);
if (opt.captures.empty()) {
RationsTools::printCaptureUsage("rations_midicheck");
Expand Down
4 changes: 2 additions & 2 deletions products/rations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ endforeach()
# person's amps, and made every build of it depend on files that are deliberately
# not in this repository. Both are gone. The four banks are now whatever folder or
# file the user picks on the settings page, remembered by absolute path in the
# state blob, and an instance with nothing loaded outputs ramped silence rather
# than failing to exist.
# state blob, and an instance with nothing loaded passes its input through dry
# rather than failing to exist.
#
# The offline proofs still need captures to run against, and take a --captures
# argument (or $RATIONS_TEST_CAPTURES) rather than reading them out of a bundle.
Expand Down
6 changes: 3 additions & 3 deletions products/rations/scripts/ir-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ root="${RATIONS_IR_DIR:-$HOME/Impulse-Responses}"
build="${RATIONS_BUILD_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)/build}"
bundle="$build/VST3/Release/NAMp-rations.vst3"
tool="$build/rations_ircheck"
# The cabinet stage is measured through the whole chain, so the channels have to be sounding
# something: with no captures loaded the rack outputs ramped silence and every blend measurement
# would be taken on nothing. The plug-in ships no captures, so this has to say where they are.
# The cabinet stage is measured through the whole chain, so the channels have to be sounding an
# amp: with no captures loaded the rack passes the DI through dry and every blend measurement would
# be taken on that instead. The plug-in ships no captures, so this has to say where they are.
captures="${RATIONS_TEST_CAPTURES:-$(cd "$(dirname "$0")/.." && pwd)/captures}"

V="$root/Celestion Vintage 30 - 2002 Mesa Boogie Traditional 4x12 - SM57"
Expand Down
8 changes: 5 additions & 3 deletions products/rations/src/rationsprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ tresult PLUGIN_API RationsProcessor::initialize(FUnknown *context)
// Nothing is loaded here, and that is the change this build is about. The plug-in used to ship
// four banks inside its own bundle and request all four at this point; it ships none now, so a
// fresh instance comes up with four empty channels and the settings page asking for them. Empty
// is a state the rack already handles correctly - it answers with ramped silence, never with
// dry signal, which would jump in level the instant a model landed - so there is nothing to add
// here beyond not doing it.
// is a state the rack already handles: a channel with no capture assigned passes its input
// through dry, as the parent plug-in does with no model loaded, so an instance can be used for
// its cabinet alone. Only a capture that is assigned but still building answers with ramped
// silence, because dry signal there would jump in level the instant the model landed. So there
// is nothing to add here beyond not loading anything.
//
// The four workers still exist and still start now. What makes the build breadth-first is one
// worker per channel, and that is a property of the rack rather than of when the loads arrive:
Expand Down
3 changes: 2 additions & 1 deletion products/rations/src/rationsprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class RationsProcessor : public Steinberg::Vst::AudioEffect
void sendMidiTable(); // message thread only
void allocateBuffers(); // message thread only
// Load one channel's bank from a folder (isDirectory) or a single file. An empty path clears
// the channel, which the rack answers with ramped silence. Message thread only — file I/O.
// the channel, which the rack answers by passing its input through dry. Message thread only —
// file I/O.
void loadCaptureSource(int channel, const std::string &path, bool isDirectory);
// Publish the output section to the rack. Safe from EITHER thread - it is nothing but atomic
// stores - which it has to be, because a radio click on the settings page arrives as a host
Expand Down
Loading