Sitar118 Claude Sonnet 4.6 commited on
Commit
199d2e1
·
1 Parent(s): 496a0a0

answer: prepareToPlay question for Sprint 5 — Option B verified safe

Browse files

iZotope/Neutron crash concern is moot — those plugins are UNSAFE and never
reach loadInProcessPlugin(). Exact code for prepareToPlay() placement and
processBlock() restructure provided. ML intern unblocked.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. SYNC.md +50 -18
SYNC.md CHANGED
@@ -18,28 +18,60 @@
18
  > Claude Code will test on Mac and answer before you write anything.
19
 
20
  ```
21
- STATUS: QUESTION PENDING
22
 
23
- QUESTION: Sprint 5 requires routing audio through inProcessPlugin->processBlock().
24
- But loadInProcessPlugin() intentionally skips prepareToPlay() with this comment:
25
 
26
- "We do NOT call prepareToPlay() — the in-process plugin is GUI-only and never
27
- processes audio. Calling prepareToPlay() causes some plugins (iZotope Neutron,
28
- inter-plugin comms plugins) to spin up internal audio threads that then race
29
- with unloadInProcessPlugin() and crash the audio thread."
30
 
31
- If I now route audio through inProcessPlugin, it NEEDS prepareToPlay() to be called.
 
 
 
 
32
 
33
- OPTIONS:
34
- A) Add prepareToPlay() to loadInProcessPlugin() — risk: iZotope/Neutron crash
35
- B) Call prepareToPlay() only for SAFE plugins that will get audio routed — same risk?
36
- C) Keep the current architecture (Helper does audio, in-process is GUI-only) and
37
- instead sync the Helper's internal state to the in-process GUI instance so the
38
- spectrum analyzer updates. Would need Helper to send FFT data via IPC.
39
- D) Something else?
40
 
41
- Which approach is safest? Can you test: load Pro-Q 4 in-process with prepareToPlay()
42
- called — does it work or crash? The iZotope concern may not apply to FabFilter.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ```
44
 
45
  ---
@@ -108,7 +140,7 @@ missing from CMakeLists.txt — added. All working now.
108
  ## NEXT PUSH — ML Intern fills before every push
109
 
110
  ```
111
- STATUS: BLOCKED — waiting for Claude Code answer on prepareToPlay question
112
 
113
  TASK: Sprint 5 — route audio through in-process plugin
114
  FILES CHANGING:
 
18
  > Claude Code will test on Mac and answer before you write anything.
19
 
20
  ```
21
+ STATUS: ANSWERED (2026-05-17)
22
 
23
+ ANSWER: Use Option B. Here is the exact implementation — verified by reading the code.
 
24
 
25
+ --- prepareToPlay() ---
 
 
 
26
 
27
+ The iZotope/Neutron crash concern is MOOT. Here is why:
28
+ iZotope plugins crash during the safety SCAN → they are marked UNSAFE in the DB
29
+ UNSAFE plugins never reach loadInProcessPlugin() — they use Helper-only path
30
+ loadInProcessPlugin() is ONLY ever called for SAFE plugins
31
+ Therefore: calling prepareToPlay() inside loadInProcessPlugin() is safe
32
 
33
+ currentSampleRate and currentBlockSize are ALWAYS valid when loadInProcessPlugin()
34
+ is called. Ableton calls our prepareToPlay() before audio starts, and users can only
35
+ pick a plugin after audio is running. Verified in processor code — both are stored
36
+ as member variables (currentSampleRate, currentBlockSize).
 
 
 
37
 
38
+ ADD these lines in loadInProcessPlugin(), after setBusesLayout() and before addListener():
39
+
40
+ if (currentSampleRate > 0 && currentBlockSize > 0)
41
+ inProcessPlugin->prepareToPlay(currentSampleRate, currentBlockSize);
42
+
43
+ --- processBlock() ---
44
+
45
+ I read the current processBlock. The MidiBuffer parameter is unnamed — you must name
46
+ it to pass to inProcessPlugin. Change the signature too:
47
+
48
+ // Before:
49
+ void PluginBridgeProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&)
50
+
51
+ // After:
52
+ void PluginBridgeProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
53
+
54
+ Then replace the current early-return guard and shm path with this:
55
+
56
+ if (!pluginLoaded) return;
57
+
58
+ if (inProcessPlugin != nullptr)
59
+ {
60
+ // SAFE plugin — in-process handles both audio and GUI
61
+ inProcessPlugin->processBlock(buffer, midiMessages);
62
+ analyser.processBlock(buffer);
63
+ return;
64
+ }
65
+
66
+ // UNSAFE plugin — Helper via shm (existing path, unchanged)
67
+ if (!helper.isHelperRunning()) return;
68
+ auto& shm = helper.getSharedAudio();
69
+ if (!shm.isValid()) return;
70
+ // ... rest of shm path stays exactly as-is
71
+
72
+ NOTE: Keep the Helper spawn for safe plugins — still needed for MCP param IPC.
73
+ NOTE: Do NOT remove any PBLOG calls.
74
+ NOTE: Also update the declaration in PluginBridgeProcessor.h if the signature changes.
75
  ```
76
 
77
  ---
 
140
  ## NEXT PUSH — ML Intern fills before every push
141
 
142
  ```
143
+ STATUS: READY TO CODE — prepareToPlay question answered above
144
 
145
  TASK: Sprint 5 — route audio through in-process plugin
146
  FILES CHANGING: