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
2 changes: 1 addition & 1 deletion .github/workflows/p1-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
-DBUILD_TESTING=ON
-DJUCE_WEBVIEW2_PACKAGE_LOCATION="${{ github.workspace }}/.deps"
- name: Build executable and native RT tests
run: cmake --build build --config Release --target ARMixConsole ARMixWorkspaceTests ARMixVaultTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixRTTests ARMixPresetTests ARMixDiagnosticTests ARMixClockBridgeTests ARMixVirtualClockSoakTests ARMixCadenceTests ARMixCrackleWindowTests ARMixHealthTests ARMixPolicyTests ARMixPeriodEvidenceTests ARMixLifecycleTests ARMixWasapiProbeTests ARMixDualJuceTests ARMixClockSizingTests ARMixIndependentFormatTests ARMixRecoveryTests ARMixStreamWatchdogTests ARMixBridgeContinuityTests ARMixEndpointPolicyTests ARMixEndpointGuardTests ARMixAsioPolicyTests ARMixAsioBackendTests ARMixAsioRegistryIdentityTests ARMixDirectFenceTests --parallel 2
run: cmake --build build --config Release --target ARMixConsole ARMixWorkspaceTests ARMixVaultTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixRTTests ARMixPresetTests ARMixDiagnosticTests ARMixClockBridgeTests ARMixVirtualClockSoakTests ARMixCadenceTests ARMixCrackleWindowTests ARMixHealthTests ARMixPolicyTests ARMixPeriodEvidenceTests ARMixLifecycleTests ARMixWasapiProbeTests ARMixDualJuceTests ARMixClockSizingTests ARMixIndependentFormatTests ARMixRecoveryTests ARMixStreamWatchdogTests ARMixBridgeContinuityTests ARMixEndpointPolicyTests ARMixEndpointGuardTests ARMixAsioPolicyTests ARMixAsioBackendTests ARMixAsioRegistryIdentityTests ARMixDirectFenceTests --parallel 2
- name: Test realtime control primitives
run: ctest --test-dir build -C Release --output-on-failure
- name: Package verified JUCE GUI for hardware FAT
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ juce_add_gui_app(ARMixConsole
juce_add_binary_data(ARMixAssets SOURCES
web/index.html web/styles.css web/app.js web/bridge.js web/monitor.js)

target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/VstOrbitController.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h src/PluginCatalog.h src/PluginVault.h src/PortableWorkspace.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h)
target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/VstOrbitController.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h src/PluginCatalog.h src/PluginVault.h src/PortableWorkspace.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h)
target_compile_definitions(ARMixConsole PRIVATE
JUCE_WEB_BROWSER=1
JUCE_USE_WIN_WEBVIEW2=1
Expand Down Expand Up @@ -53,6 +53,9 @@ if(BUILD_TESTING)
add_executable(ARMixOrbitMotionTests tests/orbit_motion_test.cpp)
target_compile_features(ARMixOrbitMotionTests PRIVATE cxx_std_20)
add_test(NAME VstThreeAxisMotionPaths COMMAND ARMixOrbitMotionTests)
add_executable(ARMixOrbitDistanceTests tests/orbit_distance_mapping_test.cpp)
target_compile_features(ARMixOrbitDistanceTests PRIVATE cxx_std_20)
add_test(NAME VstOrbitVendorDistanceMapping COMMAND ARMixOrbitDistanceTests)
add_executable(ARMixOrbitControlTests tests/orbit_control_policy_test.cpp)
target_compile_features(ARMixOrbitControlTests PRIVATE cxx_std_20)
add_test(NAME VstOrbitControlRatePolicy COMMAND ARMixOrbitControlTests)
Expand Down
43 changes: 43 additions & 0 deletions engine/core/OrbitDistanceMapping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <algorithm>
#include <cmath>

namespace armix::core
{
// Invert a monotonic vendor DISPLAY mapping, not an assumed linear physical scale.
// Find the interval for the *exact* displayed value and aim at its centre.
// This prevents a midpoint search from yielding 1.99 m when 2.00 m was requested.
// A setpoint the vendor cannot display exactly is rejected, never misrepresented.
template <typename ReadDisplayedValue>
bool normalizedForDisplayedSetpoint(double requested,double minimum,double maximum,
ReadDisplayedValue&& read,float& result) noexcept
{
if (!std::isfinite(requested) || !std::isfinite(minimum) ||
!std::isfinite(maximum) || minimum >= maximum ||
requested < minimum || requested > maximum) return false;
constexpr int iterations=30;
auto boundary=[&](bool greater,double& out)->bool {
double lo=0.,hi=1.;
const auto atLo=read(0.f),atHi=read(1.f);
if (!std::isfinite(atLo)||!std::isfinite(atHi)||atLo>atHi) return false;
for(int i=0;i<iterations;++i) {
const double mid=(lo+hi)*0.5;
const double displayed=read(static_cast<float>(mid));
if(!std::isfinite(displayed))return false;
if(greater?displayed>requested:displayed>=requested)hi=mid;
else lo=mid;
}
out=hi;return true;
};
double first=0.,end=1.;
if(!boundary(false,first)||!boundary(true,end))return false;
const float candidate=static_cast<float>((first+end)*0.5);
const double displayed=read(candidate);
// Decimal text parsed into doubles may contain a few ULPs of representation.
if(!std::isfinite(displayed) || std::abs(displayed-requested)>
1.e-7*std::max(1.,std::abs(requested)))return false;
result=candidate;
return true;
}
}
18 changes: 18 additions & 0 deletions engine/core/OrbitMotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ inline double orbitShapePhaseForAzimuth(float azimuth,int shape) noexcept {
std::cos(angle)/orbitAxisY(shape));
return orbitWrap(t/(2.0*pi));
}
// Crossing a near/far phase extremum between timer ticks is common at 60 Hz.
// Capture the actual endpoint once (without another thread or timer) so the
// distance parameter really reaches the user-selected near/far setpoints.
inline bool crossesOrbitDistanceExtreme(double previous,double current,
int shape,bool isFarEndpoint) noexcept
{
if (!needsOrbitDistance(shape) ||
!std::isfinite(previous)||!std::isfinite(current) ||
std::abs(current-previous)>0.125 || previous==current)return false;
const double lo=std::min(previous,current),hi=std::max(previous,current);
const bool frontBack=(shape==1||shape==4);
const double offset=frontBack?(isFarEndpoint?0.0:0.25):(isFarEndpoint?0.25:0.0);
for(int side=0;side<2;++side) {
const double threshold=offset+side*0.5;
if(std::floor(hi-threshold)>std::floor(lo-threshold))return true;
}
return false;
}
struct OrbitMotionPoint {
float azimuth=0.5f, distance=0.5f, elevation=0.5f;
float x=0.0f,y=1.0f,z=0.0f; // top-down x/y, signed elevation z
Expand Down
19 changes: 6 additions & 13 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <BinaryData.h>
#include "LiveAudioEngine.h"
#include "VstOrbitController.h"
#include "../engine/core/OrbitDistanceMapping.h"
#include "DiagnosticsRecorder.h"
#include "../engine/device/DirectRestoreBackoff.h"
#include "../engine/device/PeriodCapabilityEvidence.h"
Expand Down Expand Up @@ -473,18 +474,10 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
double loMeters=0,hiMeters=0;
if(!distanceMeterBounds(p,loMeters,hiMeters)||
!std::isfinite(metres)||metres<loMeters||metres>hiMeters)return false;
double lo=0.0,hi=1.0;
for(int i=0;i<24;++i){
const double mid=(lo+hi)*0.5;
const double v=p->getText(static_cast<float>(mid),48).getDoubleValue();
if(!std::isfinite(v))return false;
if(v<metres)lo=mid;else hi=mid;
}
normalized=static_cast<float>((lo+hi)*0.5);
// Round-trip tolerance accommodates formatted vendor resolution.
const double actual=p->getText(normalized,48).getDoubleValue();
return std::isfinite(actual)&&std::abs(actual-metres)<=
std::max(0.2,0.01*(hiMeters-loMeters));
return armix::core::normalizedForDisplayedSetpoint(
metres,loMeters,hiMeters,
[p](float value) {return p->getText(value,48).getDoubleValue();},
normalized);
}

void emitOrbitState (int slot,int previewShape=-1)
Expand Down Expand Up @@ -1194,7 +1187,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
auto* param=plugin->getParameters()[distanceIndex];
if(!metresToNormalized(param,rawNear,nearValue)||
!metresToNormalized(param,rawFar,farValue))
return emitNotice("VST3 cannot resolve these metre setpoints; choose valid near/far values.",true);
return emitNotice("This VST3 cannot represent the requested metres exactly. Choose a supported value.",true);
}else if(unitArg=="%"){
if(!std::isfinite(rawNear)||!std::isfinite(rawFar)||
rawNear<0||rawFar>100)
Expand Down
31 changes: 24 additions & 7 deletions src/VstOrbitController.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class VstOrbitController final : private juce::Timer
dispatch_={};
startMs_=juce::Time::getMillisecondCounterHiRes();
previousTickMs_=startMs_;
previousAbsolutePhase_=startPhase;
azimuth_->beginChangeGesture();
if(distance_)distance_->beginChangeGesture();
if(elevation_)elevation_->beginChangeGesture();
Expand Down Expand Up @@ -110,15 +111,30 @@ class VstOrbitController final : private juce::Timer
previousTickMs_=now;
++dispatch_.ticks;
const double elapsed=(now-startMs_)/1000.0;
const double absolutePhase=static_cast<double>(phaseStart_) +
(reverse_?-1.0:1.0)*elapsed/period_;
const auto pos=armix::core::orbitMotionPoint(
armix::core::orbitRamp(phaseStart_,elapsed,period_,reverse_),shape_,
nearDistance_,farDistance_);
armix::core::orbitWrap(absolutePhase),shape_,nearDistance_,farDistance_);
float appliedDistance=pos.distance;
bool forceDistanceEndpoint=false;
if(distance_ && elapsed>=0.3) {
if(armix::core::crossesOrbitDistanceExtreme(previousAbsolutePhase_,
absolutePhase,shape_,true)){
appliedDistance=static_cast<float>(farDistance_);
forceDistanceEndpoint=true;
}else if(armix::core::crossesOrbitDistanceExtreme(previousAbsolutePhase_,
absolutePhase,shape_,false)){
appliedDistance=static_cast<float>(nearDistance_);
forceDistanceEndpoint=true;
}
}
previousAbsolutePhase_=absolutePhase;
const auto publish=[&](juce::AudioProcessorParameter* p,float value,
float& previous,bool cyclic,int steps){
float& previous,bool cyclic,int steps,bool force=false){
if(!p)return;
const bool needed=cyclic ?
const bool needed=force||(cyclic ?
armix::core::shouldPublishOrbit(value,previous,steps):
std::abs(value-previous)>0.0001f;
std::abs(value-previous)>0.0001f);
if(needed && std::isfinite(value) && value>=0.f && value<=1.f){
p->setValueNotifyingHost(value);previous=value;++dispatch_.writes;
} else ++dispatch_.coalesced;
Expand All @@ -127,7 +143,8 @@ class VstOrbitController final : private juce::Timer
// 300 ms easing prevents jumps when enabling additional axes.
const float mix=static_cast<float>(std::clamp(elapsed/0.3,0.0,1.0));
if(distance_)publish(distance_,initialDistance_+
mix*(pos.distance-initialDistance_),lastDist_,false,0);
mix*(appliedDistance-initialDistance_),lastDist_,false,0,
forceDistanceEndpoint);
if(elevation_)publish(elevation_,initialElevation_+
mix*(pos.elevation-initialElevation_),lastElev_,false,0);
}
Expand All @@ -139,7 +156,7 @@ class VstOrbitController final : private juce::Timer
int slot_=-1,azimuthIndex_=-1,distanceIndex_=-1,elevationIndex_=-1;
int shape_=0,azimuthSteps_=0;
double period_=20.0,startMs_=0.0,previousTickMs_=0.0;
double nearDistance_=0.2,farDistance_=0.7;
double nearDistance_=0.2,farDistance_=0.7,previousAbsolutePhase_=0.0;
float phaseStart_=0.f,lastAz_=0.5f,lastDist_=0.5f,lastElev_=0.5f;
float initialDistance_=0.5f,initialElevation_=0.5f;
bool reverse_=false;
Expand Down
6 changes: 5 additions & 1 deletion tests/native_orbit_ui_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ async def main():
assert await page.locator("#nativeOrbit .native-dialog-footer").is_hidden()
await page.wait_for_function("""()=>document.querySelector("#nativeOrbitParameter")?.value==="2" """)
assert await modal.locator("#nativeOrbitParameter").input_value() == "2"
assert "-180" in await modal.inner_text(), "Vendor endpoint range should be visible"
assert await modal.locator("#nativeOrbitParameter option").count()==2, "Only Azimuth should be listed"
assert await modal.locator("#nativeOrbitDistance option").count()==2, "Only Distance should be listed"
assert (await modal.locator("#nativeOrbitDistance option").last.inner_text()).strip()=="Distance"
assert "30.0 m" not in await modal.locator("#nativeOrbitDistance").inner_text(), "Vendor technical limit is not a dropdown label"
assert "Gain" not in await modal.locator("#nativeOrbitParameter").inner_text(), "Unrelated VST parameters must be filtered"
start = modal.locator("[data-orbit-start]")
assert await modal.locator("#nativeOrbitConfirm").count()==0
assert await start.is_enabled(), "START must be ready without checkbox"
Expand Down
30 changes: 30 additions & 0 deletions tests/orbit_distance_mapping_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: AGPL-3.0-only
#include "../engine/core/OrbitDistanceMapping.h"
#include <cmath>
#include <iostream>
#include <limits>
int main(){
using armix::core::normalizedForDisplayedSetpoint;
int failed=0;
auto check=[&](bool ok,const char* name){if(!ok){std::cerr<<"FAIL "<<name<<"\n";++failed;}};
// Simulate a vendor's quantized text for a 0.1-30m parameter.
auto vendor=[](float v){
const double physical=0.1+29.9*std::pow(v,1.7);
return std::round(physical*100.)/100.;
};
float norm=0.f;
check(normalizedForDisplayedSetpoint(2.,.1,30.,vendor,norm),"2m mapped");
check(vendor(norm)==2.,"2m displayed exactly (never 1.99)");
check(normalizedForDisplayedSetpoint(1.5,.1,30.,vendor,norm),"1.5m mapped");
check(vendor(norm)==1.5,"1.5m roundtrip");
check(normalizedForDisplayedSetpoint(30.,.1,30.,vendor,norm),"upper boundary");
check(vendor(norm)==30.,"30m exact boundary");
check(!normalizedForDisplayedSetpoint(31.,.1,30.,vendor,norm),"outside bounds rejected");
// A plugin with only 0.1m increments cannot represent 2.05m;
// silently using 2.0/2.1 would mislead the user.
auto coarse=[](float v){return std::round(v*100.)/10.;};
check(!normalizedForDisplayedSetpoint(2.05,0.,10.,coarse,norm),"unrepresentable rejected");
auto nan=[](float){return std::numeric_limits<double>::quiet_NaN();};
check(!normalizedForDisplayedSetpoint(2.,0.,10.,nan,norm),"invalid vendor mapping rejected");
return failed?1:0;
}
10 changes: 10 additions & 0 deletions tests/orbit_motion_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,15 @@ int main() {
"ellipse uses far setpoint at front/back");
check(std::abs(orbitMotionPoint(.25,1,.25,.9).distance-.25f)<1.e-5,
"changing distance setpoints alters C++ output");
// Crossed extrema must publish exact setpoints even if no 60Hz tick
// happens exactly at phase 0.25 / 0.50 / 0.75.
check(crossesOrbitDistanceExtreme(.242,.258,1,false),"front/back near crossover");
check(crossesOrbitDistanceExtreme(.491,.510,1,true),"front/back far crossover");
check(crossesOrbitDistanceExtreme(.242,.258,2,true),"left/right far crossover");
check(crossesOrbitDistanceExtreme(.491,.510,2,false),"left/right near crossover");
check(crossesOrbitDistanceExtreme(.258,.242,1,false),"reverse near crossover");
check(!crossesOrbitDistanceExtreme(.258,.280,1,false),"no false peak");
check(!crossesOrbitDistanceExtreme(.1,.3,1,false),"stalled timer ignores stale extremum");
check(!crossesOrbitDistanceExtreme(.242,.258,0,false),"circle has constant distance");
return failures?1:0;
}
Loading
Loading