@@ -284,4 +284,109 @@ inline bool projectInstalledNativeChannelIdGraph(
284284 // Product LIVE stays false until independent vendor/Show/hardware FAT.
285285 return true ;
286286}
287+
288+ /* *
289+ * Milestone A: one authoritative control-thread SessionSnapshot projection.
290+ * The native callback remains the only PCM producer. Legacy M4 may be an
291+ * implementation detail but NEVER independently competes with ChannelId.
292+ * There is no UI, file I/O, VST preparation or RT mutation in this routine.
293+ */
294+ inline void publishAuthoritativeMixerSession (juce::var& snapshot)
295+ {
296+ if (!snapshot.isObject ())return ;
297+ const auto device=snapshot.getProperty (" device" ,{});
298+ const auto graph=snapshot.getProperty (" graph" ,{});
299+ const auto caps=graph.getProperty (" capabilities" ,{});
300+ const auto m4=snapshot.getProperty (" legacyM4" ,{});
301+ const auto epoch=device.getProperty (" epoch" ," 0" ).toString ();
302+ const auto graphRows=graph.getProperty (" channels" ,{});
303+ const bool channelIdReady=caps.isObject () &&
304+ static_cast <bool >(caps.getProperty (" callbackOwnsChannelIds" ,false )) &&
305+ nativeV8Decimal (epoch) && epoch!=" 0" &&
306+ nativeV8Decimal (graph.getProperty (" revision" ,{})) &&
307+ graphRows.isArray () && graphRows.getArray ()->size ()>0 ;
308+ const auto sources=m4.getProperty (" channels" ,{});
309+ const auto controls=m4.getProperty (" channelControls" ,{});
310+ const auto peakL=m4.getProperty (" channelPeaksL" ,{});
311+ const auto peakR=m4.getProperty (" channelPeaksR" ,{});
312+ const bool preparedM4=!channelIdReady && m4.isObject () &&
313+ static_cast <bool >(m4.getProperty (" active" ,false )) &&
314+ static_cast <bool >(m4.getProperty (" routeAccepted" ,false )) &&
315+ !static_cast <bool >(m4.getProperty (" nativeBusStructural" ,true )) &&
316+ nativeV8Decimal (epoch) && epoch!=" 0" &&
317+ nativeV8Decimal (m4.getProperty (" routingRevision" ,{})) &&
318+ sources.isArray () && controls.isArray () && peakL.isArray () && peakR.isArray () &&
319+ sources.getArray ()->size ()==10 && controls.getArray ()->size ()==10 &&
320+ peakL.getArray ()->size ()==10 && peakR.getArray ()->size ()==10 ;
321+ juce::Array<juce::var> rows;
322+ bool validM4=preparedM4;
323+ if (preparedM4) {
324+ for (int i=0 ;i<10 ;++i) {
325+ const auto src=sources[i],ctl=controls[i];
326+ double db=0 .,pan=0 .,l=0 .,r=0 .;
327+ if (!src.isObject () || !ctl.isObject () ||
328+ !nativeV8Number (ctl.getProperty (" db" ,{}),db) ||
329+ !nativeV8Number (ctl.getProperty (" pan" ,{}),pan) ||
330+ !nativeV8Number (peakL[i],l) ||
331+ !nativeV8Number (peakR[i],r) ||
332+ !ctl.getProperty (" mute" ,{}).isBool () ||
333+ !ctl.getProperty (" solo" ,{}).isBool () ||
334+ !src.getProperty (" main" ,{}).isBool () ||
335+ db< -60.01 || db>10.01 || pan< -100.01 || pan>100.01 ||
336+ l<0 . || r<0 .) {validM4=false ;break ;}
337+ auto c=std::make_unique<juce::DynamicObject>();
338+ c->setProperty (" faderDb" ,db);
339+ c->setProperty (" pan" ,pan/100 .);
340+ c->setProperty (" mute" ,ctl.getProperty (" mute" ,{}));
341+ c->setProperty (" solo" ,ctl.getProperty (" solo" ,{}));
342+ auto row=std::make_unique<juce::DynamicObject>();
343+ // M4 IDs are deliberately NOT uint64 native ChannelIds.
344+ row->setProperty (" id" ," m4:" +juce::String (i+1 ).paddedLeft (' 0' ,2 ));
345+ row->setProperty (" ordinal" ,i);
346+ row->setProperty (" role" ," INPUT" );
347+ row->setProperty (" source" ,src);
348+ row->setProperty (" controls" ,juce::var (c.release ()));
349+ row->setProperty (" primaryOut" ,static_cast <bool >(
350+ src.getProperty (" main" ,false ))?" MAIN" :" NONE" );
351+ row->setProperty (" peakL" ,l);
352+ row->setProperty (" peakR" ,r);
353+ rows.add (juce::var (row.release ()));
354+ }
355+ if (!validM4)rows.clear ();
356+ }
357+ auto session=std::make_unique<juce::DynamicObject>();
358+ const auto authority=channelIdReady?" CHANNEL_ID" :validM4?" M4" :" NONE" ;
359+ session->setProperty (" authority" ,authority);
360+ session->setProperty (" deviceEpoch" ,epoch);
361+ session->setProperty (" routeRevision" ,channelIdReady?
362+ graph.getProperty (" revision" ," 0" ):validM4?
363+ m4.getProperty (" routingRevision" ," 0" ):juce::var (" 0" ));
364+ session->setProperty (" rosterRevision" ,channelIdReady?
365+ graph.getProperty (" rosterRevision" ," 0" ):juce::var (" 0" ));
366+ session->setProperty (" channels" ,channelIdReady?graphRows:juce::var (rows));
367+ session->setProperty (" supportedOps" ,channelIdReady?
368+ caps.getProperty (" supportedOps" ,juce::var (juce::Array<juce::var>{})):
369+ juce::var (juce::Array<juce::var>{}));
370+ // Actual physical post-mixer MAIN is not a second audio graph.
371+ auto master=std::make_unique<juce::DynamicObject>();
372+ if (channelIdReady) {
373+ for (const auto & ch:*graphRows.getArray ())
374+ if (ch.getProperty (" role" ," " ).toString ()==" MAIN" ) {
375+ const auto c=ch.getProperty (" controls" ,{});
376+ if (c.isObject ()) {
377+ master->setProperty (" db" ,c.getProperty (" faderDb" ,{}));
378+ master->setProperty (" mute" ,c.getProperty (" mute" ,{}));
379+ }
380+ break ;
381+ }
382+ }else if (validM4) {
383+ master->setProperty (" db" ,m4.getProperty (" masterDb" ,{}));
384+ master->setProperty (" mute" ,m4.getProperty (" masterMute" ,{}));
385+ }
386+ master->setProperty (" outputArmed" ,device.getProperty (" outputArmed" ,false ));
387+ session->setProperty (" main" ,juce::var (master.release ()));
388+ snapshot.getDynamicObject ()->setProperty (" mixerSession" ,
389+ juce::var (session.release ()));
390+ }
391+
287392} // namespace armix::console
0 commit comments