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: 2 additions & 0 deletions integration/ApprovedNativeRuntimeSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ inline bool projectInstalledNativeChannelIdGraph(
if(has("NATIVE_MOVE_INSERT"))available.add(juce::String("MOVE_INSERT"));
if(has("NATIVE_LOAD_INSERT"))
available.add(juce::String("LOAD_INSERT"));
if(has("NATIVE_CREATE_CHANNEL"))
available.add(juce::String("CREATE_CHANNEL"));
if(has("NATIVE_CREATE_GROUP_SELECTED"))
available.add(juce::String("CREATE_GROUP"));
const auto graph=snapshot.getProperty("graph",{});
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_approved_native_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def accepted_pages_html() -> str:
" }\n"
" return true;\n"
" },\n"
" make,render,findTrack,displayMeterDbfs,\n"
" make,render,findTrack,displayMeterDbfs,revealTrack,\n"
" openChannelIdentity,closeChannelIdentity,\n"
" get identityTrackId(){return identityTrackId;},\n"
" get identityColor(){return identityColor;},get identityIcon(){return identityIcon;},\n"
Expand Down
51 changes: 39 additions & 12 deletions scripts/compose_operator_ux.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
.command-bar .mixer-file-tool{display:inline-flex;align-items:center;gap:5px}
.command-bar .mixer-file-tool img{display:block;flex:none;pointer-events:none}
.command-bar #densitySelect,.command-bar [for="densitySelect"],.command-bar #mode{display:none!important}
#channelIdentity .identity-head{cursor:move;touch-action:none}
#channelIdentity .identity-head button{cursor:pointer}
/* Every console floating editor uses one square Material close key. */
:is(#pluginClose,#identityClose,#fastClose,#wireConfigClose,#wireWsClose,#routeChoiceClose){
box-sizing:border-box!important;flex:0 0 29px!important;width:29px!important;
Expand Down Expand Up @@ -208,21 +210,44 @@ def apply_operator_ux(html: str, assets: Path) -> str:
"place editor under body outside scrolling app")
html = once(html,
"function openChannelIdentity(t,anchor){",
"""function positionChannelIdentity(dialog,anchor){
// One geometry read on explicit open, not in the live meter/PCM path.
"""function channelIdentityViewport(){
const visual=window.visualViewport;
const vx=visual?.offsetLeft??0,vy=visual?.offsetTop??0;
const vw=visual?.width||window.innerWidth,vh=visual?.height||window.innerHeight;
return {left:visual?.offsetLeft??0,top:visual?.offsetTop??0,
width:visual?.width||window.innerWidth,height:visual?.height||window.innerHeight};
}
function placeChannelIdentity(dialog,box,view,x,y){
const gap=8;
dialog.style.maxWidth=Math.max(1,vw-2*gap)+'px';
dialog.style.maxHeight=Math.max(1,vh-2*gap)+'px';
dialog.style.left=Math.max(view.left+gap,Math.min(view.left+view.width-box.width-gap,x))+'px';
dialog.style.top=Math.max(view.top+gap,Math.min(view.top+view.height-box.height-gap,y))+'px';
}
function positionChannelIdentity(dialog,anchor){
// One geometry read on explicit open, not in the live meter/PCM path.
const view=channelIdentityViewport();
dialog.style.maxWidth=Math.max(1,view.width-16)+'px';
dialog.style.maxHeight=Math.max(1,view.height-16)+'px';
const box=dialog.getBoundingClientRect(),a=anchor?.getBoundingClientRect?.();
const preferredX=a?a.left+a.width/2-box.width/2:vx+gap;
const preferredY=a?a.top+18:vy+gap;
const x=Math.max(vx+gap,Math.min(vx+vw-box.width-gap,preferredX));
const y=Math.max(vy+gap,Math.min(vy+vh-box.height-gap,preferredY));
dialog.style.left=x+'px';dialog.style.top=y+'px';
placeChannelIdentity(dialog,box,view,a?a.left+(a.width-box.width)/2:view.left+8,
a?a.top+18:view.top+8);
}
const channelIdentityCard=document.getElementById('channelIdentity');
const channelIdentityHandle=channelIdentityCard.querySelector('.identity-head');
let channelIdentityDrag=null;
channelIdentityHandle.addEventListener('pointerdown',e=>{
if(e.button!==0||!e.isPrimary||e.target.closest('button'))return;
const box=channelIdentityCard.getBoundingClientRect();
channelIdentityDrag={id:e.pointerId,box,x:e.clientX-box.left,y:e.clientY-box.top};
channelIdentityHandle.setPointerCapture(e.pointerId);
e.preventDefault();
});
channelIdentityHandle.addEventListener('pointermove',e=>{
const drag=channelIdentityDrag;
if(!drag||drag.id!==e.pointerId)return;
placeChannelIdentity(channelIdentityCard,drag.box,channelIdentityViewport(),
e.clientX-drag.x,e.clientY-drag.y);
});
channelIdentityHandle.addEventListener('lostpointercapture',e=>{
if(channelIdentityDrag?.id===e.pointerId)channelIdentityDrag=null;
});
function openChannelIdentity(t,anchor){""",
"install measured viewport positioning")
html = once(html,
Expand All @@ -233,7 +258,9 @@ def apply_operator_ux(html: str, assets: Path) -> str:
}
document.getElementById('identityName').focus?.();""",
""" positionChannelIdentity(dialog,anchor);
document.getElementById('identityName').focus({preventScroll:true});""",
const name=document.getElementById('identityName');
name.focus({preventScroll:true});
name.select();""",
"remove mixer-relative geometry and focus scroll")
targets = ("identityClose","pluginClose","fastClose",
"wireConfigClose","wireWsClose","routeChoiceClose")
Expand Down
83 changes: 38 additions & 45 deletions src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
const auto frames=juce::jmax(32,device->getCurrentBufferSizeSamples());
if(!(rate>0.0) || frames>maxFrames)
return "Unsupported device sample rate or buffer quantum";
juce::OwnedArray<juce::PluginDescription> descriptions;
fmt->findAllTypesForFile(descriptions,filename);
juce::PluginDescription* chosen=nullptr;
for(auto* d:descriptions)
if(d && d->uniqueId==uid && !d->isInstrument) { chosen=d;break; }
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,filename,uid);
if(!chosen)return "Effect identity not found inside VST3 module";
juce::String error;
auto instance=formats_.createPluginInstance(*chosen,rate,frames,error);
Expand Down Expand Up @@ -967,13 +963,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
if (fx.binary.getSize() > armix::storage::NativePresetArchive::maxStateBytes ||
!juce::File (fx.path).exists() || !fx.path.endsWithIgnoreCase (".vst3"))
return "Plugin is missing or invalid: " + fx.name;
juce::OwnedArray<juce::PluginDescription> descriptions;
fmt->findAllTypesForFile (descriptions, fx.path);
juce::PluginDescription* match = nullptr;
for (auto* candidate : descriptions)
if (candidate != nullptr && candidate->uniqueId == fx.uid &&
!candidate->isInstrument)
{ match = candidate; break; }
const auto match=armix::vst::DescriptionCache::resolve(*fmt,fx.path,fx.uid);
if (!match) return "VST3 plugin identity missing: " + fx.name;

juce::String error;
Expand Down Expand Up @@ -1478,7 +1468,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
// Read-only control-thread verification of the currently opened pins.
juce::String inspectNativeMixerSessionBinding(
const armix::session::MixerSessionDocument& saved,
MixerBindingInspection& out) {
MixerBindingInspection& out,
armix::session::MixerDeviceBindingPolicy::Mode mode) {
if(independent_.active()||!attached_||
!directFence_.permitted()||handoff_.busy()||
fxMovePhase_.load(std::memory_order_acquire)!=0||
Expand Down Expand Up @@ -1507,10 +1498,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
candidate.live={
deviceManager_.getCurrentAudioDeviceType(),
setup.inputDeviceName,setup.outputDeviceName,
inputMask.toString(16),outputMask.toString(16),rate,frames};
inputMask.toString(16),outputMask.toString(16),rate,frames,
device->getInputChannelNames(),device->getOutputChannelNames()};
candidate.callbackInputs=candidate.pins.inputs.enabledCount;
candidate.outputs=armix::session::MixerDeviceBindingPolicy::proposedOutputs(
saved,candidate.live,candidate.pins.outputCount);
saved,candidate.live,candidate.pins.outputCount,mode);
if(candidate.epoch!=dryRoutingLab_.epoch())
return "NEEDS_REMAP: device changed during inspection";
out=std::move(candidate);
Expand All @@ -1522,7 +1514,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
juce::String restoreNativeMixerSession(
armix::session::MixerSessionDocument document,
const std::vector<armix::shows::BinaryState>& states,
bool replaceActive=false,bool* sameLiveOutputs=nullptr) {
bool replaceActive=false,bool* sameLiveOutputs=nullptr,
armix::session::MixerDeviceBindingPolicy::Mode mode=
armix::session::MixerDeviceBindingPolicy::Mode::exact) {
if((replaceActive?secondaryOutput_.armed():!allOutputsDisarmed())||
independent_.active()||!attached_||
!directFence_.permitted()||handoff_.busy()||
Expand All @@ -1532,13 +1526,13 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
routeReconfiguring_.load(std::memory_order_acquire))
return "MUTE output and verify DIRECT before restoring mixer";
MixerBindingInspection inspected;
auto bindingError=inspectNativeMixerSessionBinding(document,inspected);
auto bindingError=inspectNativeMixerSessionBinding(document,inspected,mode);
if(bindingError.isNotEmpty())return bindingError;
using BindingPolicy=armix::session::MixerDeviceBindingPolicy;
if(sameLiveOutputs)
*sameLiveOutputs=dryRoutingLab_.matchesNativeMixerOutputs(inspected.outputs);
bindingError=BindingPolicy::apply(document,inspected.live,inspected.outputs,
inspected.callbackInputs,false);
inspected.callbackInputs,mode);
if(bindingError.isNotEmpty())return bindingError;
const auto ep=inspected.epoch;
const auto next=dryRoutingLab_.nativeGraphRevisionForRestore();
Expand Down Expand Up @@ -1738,12 +1732,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
if(!fmt||!fmt->fileMightContainThisPluginType(path))
{fail.error="NATIVE_VST3_MODULE_NOT_FOUND";return fail;}
try {
juce::OwnedArray<juce::PluginDescription> descriptions;
fmt->findAllTypesForFile(descriptions,path);
juce::PluginDescription* chosen=nullptr;
for(auto* item:descriptions)
if(item&&item->uniqueId==uid&&!item->isInstrument)
{chosen=item;break;}
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,path,uid);
if(!chosen){fail.error="NATIVE_VST3_IDENTITY_NOT_FOUND";return fail;}
juce::String pluginError;
auto instance=formats_.createPluginInstance(*chosen,rate,
Expand Down Expand Up @@ -1813,24 +1802,29 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
std::uint64_t epoch,std::uint64_t pcmRevision,
std::uint64_t rosterRevision,const std::string& name,
armix::mixer::ProcessingFormat format) {
LiveDryRoutingLab::NativeBusResult fail;
fail.error="HARDWARE_NOT_DISARMED";
if(independent_.active()||!attached_||!directFence_.permitted()||
routeReconfiguring_.load(std::memory_order_acquire)||
diagnosticRoute_.load(std::memory_order_acquire)!=
armix::diagnostics::Route::normal ||
!allOutputsDisarmed()||handoff_.busy()||
fxMovePhase_.load(std::memory_order_acquire)!=0)
return fail;
return dryRoutingLab_.createNativeInputChannel(
epoch,pcmRevision,rosterRevision,name,format,true);
return editNativeInputTopology(epoch,"NATIVE_TRACK_DEVICE_UNAVAILABLE",
"NATIVE_TRACK_PUBLICATION_EXCEPTION",[&](const auto& beforePublish){
return dryRoutingLab_.createNativeInputChannel(
epoch,pcmRevision,rosterRevision,name,format,true,beforePublish);
});
}
LiveDryRoutingLab::NativeBusResult patchNativeInputSource(
std::uint64_t epoch,std::uint64_t pcmRevision,
std::uint64_t rosterRevision,armix::mixer::ChannelId channel,
int left,int right,bool stereo) {
return editNativeInputTopology(epoch,"NATIVE_SOURCE_DEVICE_UNAVAILABLE",
"NATIVE_SOURCE_PUBLICATION_EXCEPTION",[&](const auto& beforePublish){
return dryRoutingLab_.patchNativeInputSource(
epoch,pcmRevision,rosterRevision,channel,left,right,stereo,
true,beforePublish);
});
}
template<class Edit>
LiveDryRoutingLab::NativeBusResult editNativeInputTopology(
std::uint64_t epoch,const char* unavailable,const char* exception,
Edit&& edit) {
LiveDryRoutingLab::NativeBusResult fail;
fail.error="NATIVE_SOURCE_DEVICE_UNAVAILABLE";
fail.error=unavailable;
if(independent_.active()||!attached_||!directFence_.permitted()||
secondaryOutput_.armed()||
routeReconfiguring_.load(std::memory_order_acquire)||
Expand All @@ -1841,13 +1835,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
const bool wasMonitoring=isMonitorEnabled();
bool publishing=false;
try{
const auto result=dryRoutingLab_.patchNativeInputSource(
epoch,pcmRevision,rosterRevision,channel,left,right,stereo,
true,[&]{
publishing=true;
if(wasMonitoring)topologyPublicationMute_.store(
true,std::memory_order_release);
});
const auto result=edit([&]{
publishing=true;
if(wasMonitoring)topologyPublicationMute_.store(
true,std::memory_order_release);
});
if(publishing){
if(wasMonitoring &&
!armix::mixer::NativeTopologyEditSafety::mayRestoreMonitor(
Expand All @@ -1863,7 +1855,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
setOutputMuted(true);
topologyPublicationMute_.store(false,std::memory_order_release);
}
fail.error="NATIVE_SOURCE_PUBLICATION_EXCEPTION";
fail.error=exception;
return fail;
}
}
Expand Down Expand Up @@ -2192,7 +2184,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
return {deviceManager_.getCurrentAudioDeviceType(),setup.inputDeviceName,
setup.outputDeviceName,device.getActiveInputChannels().toString(16),
device.getActiveOutputChannels().toString(16),device.getCurrentSampleRate(),
device.getCurrentBufferSizeSamples()};
device.getCurrentBufferSizeSamples(),device.getInputChannelNames(),
device.getOutputChannelNames()};
}
struct WasapiBinding {
armix::device::EndpointIdentityPolicy::Selection endpoints;
Expand Down
12 changes: 5 additions & 7 deletions src/LiveDryRoutingLab.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include "Vst3DescriptionCache.h"
#include "../engine/core/PreparedMixerBlock.h"
#include "../engine/core/MasterOutputMonoPolicy.h"
#include "../engine/core/LiveChannelFxGraph.h"
Expand Down Expand Up @@ -386,12 +387,7 @@ class LiveDryRoutingLab final {
auto* fmt=formats.getFormat(0);
if(!fmt || !fmt->fileMightContainThisPluginType(req.path))
return label+": VST3 module unavailable; rescan catalog";
juce::OwnedArray<juce::PluginDescription> descriptions;
fmt->findAllTypesForFile(descriptions,req.path);
juce::PluginDescription* chosen=nullptr;
for(auto* item:descriptions)
if(item && item->uniqueId==req.uid && !item->isInstrument)
{chosen=item;break;}
const auto chosen=armix::vst::DescriptionCache::resolve(*fmt,req.path,req.uid);
if(!chosen)
return label+": selected effect identity is unavailable or instrument";
juce::String pluginError;
Expand Down Expand Up @@ -1606,7 +1602,8 @@ class LiveDryRoutingLab final {
NativeBusResult createNativeInputChannel(std::uint64_t expectedEpoch,
std::uint64_t expectedPcmRevision,std::uint64_t expectedRosterRevision,
const std::string& name,armix::mixer::ProcessingFormat format,
bool outputsDisarmed=false) {
bool outputsDisarmed=false,
const std::function<void()>& beforePublish={}) {
using namespace armix::mixer;
NativeBusResult reply{};
reply.pcmRevision=nativeAccepted_.pcmRevision;
Expand Down Expand Up @@ -1661,6 +1658,7 @@ class LiveDryRoutingLab final {
};
fx.deviceEpoch=expectedEpoch;
fx.graphRevision=expectedPcmRevision+1;
if(beforePublish)beforePublish();
const auto published=nativePublisher_.commit(
roster,nativeAccepted_.graph.request,expectedPcmRevision,
expectedEpoch,epoch(),true,std::move(fx));
Expand Down
Loading
Loading