@@ -49,6 +49,9 @@ void IntersectProcessor::drainCommands()
4949 handleCommand (commandBuffer[(size_t ) (scope.startIndex1 + i)]);
5050 for (int i = 0 ; i < scope.blockSize2 ; ++i)
5151 handleCommand (commandBuffer[(size_t ) (scope.startIndex2 + i)]);
52+
53+ if (scope.blockSize1 + scope.blockSize2 > 0 )
54+ updateHostDisplay (ChangeDetails ().withNonParameterStateChanged (true ));
5255}
5356
5457void IntersectProcessor::handleCommand (const Command& cmd)
@@ -58,8 +61,9 @@ void IntersectProcessor::handleCommand (const Command& cmd)
5861 case CmdLoadFile:
5962 if (sampleData.loadFromFile (cmd.fileParam , currentSampleRate))
6063 {
61- // Clear existing slices but don't create a default one
6264 sliceManager.clearAll ();
65+ sampleMissing.store (false );
66+ missingFilePath.clear ();
6367 }
6468 break ;
6569
@@ -73,7 +77,21 @@ void IntersectProcessor::handleCommand (const Command& cmd)
7377
7478 case CmdLazyChopStart:
7579 if (sampleData.isLoaded ())
76- lazyChop.start (sampleData.getNumFrames (), sliceManager);
80+ {
81+ PreviewStretchParams psp;
82+ psp.stretchEnabled = stretchParam->load () > 0 .5f ;
83+ psp.algorithm = (int ) algoParam->load ();
84+ psp.bpm = bpmParam->load ();
85+ psp.pitch = pitchParam->load ();
86+ psp.dawBpm = dawBpm.load ();
87+ psp.tonality = tonalityParam->load ();
88+ psp.formant = formantParam->load ();
89+ psp.formantComp = formantCompParam->load () > 0 .5f ;
90+ psp.grainMode = (int ) grainModeParam->load ();
91+ psp.sampleRate = currentSampleRate;
92+ psp.sample = &sampleData;
93+ lazyChop.start (sampleData.getNumFrames (), sliceManager, psp);
94+ }
7795 break ;
7896
7997 case CmdLazyChopStop:
@@ -321,7 +339,7 @@ void IntersectProcessor::getStateInformation (juce::MemoryBlock& destData)
321339 juce::MemoryOutputStream stream (destData, false );
322340
323341 // Version
324- stream.writeInt (8 );
342+ stream.writeInt (9 );
325343
326344 // APVTS state
327345 auto state = apvts.copyState ();
@@ -368,20 +386,8 @@ void IntersectProcessor::getStateInformation (juce::MemoryBlock& destData)
368386 stream.writeFloat (s.volume );
369387 }
370388
371- // Audio PCM data (stereo interleaved floats)
372- int numFrames = sampleData.getNumFrames ();
373- stream.writeInt (numFrames);
374- if (numFrames > 0 )
375- {
376- const auto & buf = sampleData.getBuffer ();
377- for (int f = 0 ; f < numFrames; ++f)
378- {
379- stream.writeFloat (buf.getSample (0 , f));
380- stream.writeFloat (buf.getSample (1 , f));
381- }
382- }
383-
384- // v8: sample filename
389+ // v9: store file path only (no PCM)
390+ stream.writeString (sampleData.getFilePath ());
385391 stream.writeString (sampleData.getFileName ());
386392}
387393
@@ -460,21 +466,47 @@ void IntersectProcessor::setStateInformation (const void* data, int sizeInBytes)
460466 }
461467 }
462468
463- // Audio PCM
464- int numFrames = stream.readInt ();
465- if (numFrames > 0 )
469+ if (version >= 9 )
466470 {
467- juce::AudioBuffer<float > restoredBuf (2 , numFrames);
468- for (int f = 0 ; f < numFrames; ++f)
471+ // v9: path-only restore
472+ auto filePath = stream.readString ();
473+ auto fileName = stream.readString ();
474+
475+ if (filePath.isNotEmpty ())
469476 {
470- restoredBuf.setSample (0 , f, stream.readFloat ());
471- restoredBuf.setSample (1 , f, stream.readFloat ());
477+ juce::File f (filePath);
478+ double sr = currentSampleRate > 0 ? currentSampleRate : 44100.0 ;
479+ if (f.existsAsFile () && sampleData.loadFromFile (f, sr))
480+ {
481+ sampleMissing.store (false );
482+ }
483+ else
484+ {
485+ sampleMissing.store (true );
486+ missingFilePath = filePath;
487+ sampleData.setFileName (fileName);
488+ sampleData.setFilePath (filePath);
489+ }
472490 }
473- sampleData.loadFromBuffer (std::move (restoredBuf));
474491 }
492+ else
493+ {
494+ // v8 and earlier: PCM restore (backward compat)
495+ int numFrames = stream.readInt ();
496+ if (numFrames > 0 )
497+ {
498+ juce::AudioBuffer<float > restoredBuf (2 , numFrames);
499+ for (int f = 0 ; f < numFrames; ++f)
500+ {
501+ restoredBuf.setSample (0 , f, stream.readFloat ());
502+ restoredBuf.setSample (1 , f, stream.readFloat ());
503+ }
504+ sampleData.loadFromBuffer (std::move (restoredBuf));
505+ }
475506
476- if (version >= 8 )
477- sampleData.setFileName (stream.readString ());
507+ if (version >= 8 )
508+ sampleData.setFileName (stream.readString ());
509+ }
478510
479511 sliceManager.rebuildMidiMap ();
480512}
0 commit comments