Skip to content

Fix audio preview (AudioBuffer redesign) and insert-to-DAW drag initiation#23

Merged
lmangani merged 2 commits into
mainfrom
copilot/fix-audio-preview-issue
Mar 22, 2026
Merged

Fix audio preview (AudioBuffer redesign) and insert-to-DAW drag initiation#23
lmangani merged 2 commits into
mainfrom
copilot/fix-audio-preview-issue

Conversation

Copilot AI commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Two broken features in the Library tab: audio preview produced silence, and "Insert into DAW" created file copies instead of initiating a DAW drag.

Audio Preview — PluginPreview redesign

AudioTransportSource was silently failing: setSource() called from the message thread requires precise prepareToPlay() ordering and a proper buffering/thread strategy that wasn't in place.

Replaced with a straightforward AudioBuffer<float>-backed implementation:

  • loadFile() decodes the entire file into memory; linear-interpolation resampling applied at load time when source ≠ DAW sample rate
  • play() / stop() flip std::atomic<int> playPos_ — no locks
  • render() copies from the in-memory buffer using the atomic position; ScopedTryLock keeps the audio thread wait-free during concurrent loadFile() calls
  • Public API unchanged — PluginProcessor.cpp untouched

Insert to DAW — drag from mouseDrag, not onClick

performExternalDragDropOfFiles() requires an active mouse press; calling it from onClick (mouse-up) is a no-op on macOS, causing the fallback to reveal the file in Finder — which DAWs then import as a copy.

Added InsertDawDragListener (a juce::MouseListener inner struct on insertDawButton_):

void InsertDawDragListener::mouseDrag(const juce::MouseEvent& e)
{
    if (dragStarted_ || e.getDistanceFromDragStart() < 8) return;
    dragStarted_ = true;
    editor_.startInsertDawDrag(); // calls performExternalDragDropOfFiles()
}

A plain click (no drag) still falls back to revealing the file and copying the path to the clipboard.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] Fix broken audio preview playback and insert to DAW Fix audio preview (AudioBuffer redesign) and insert-to-DAW drag initiation Mar 22, 2026
Copilot AI requested a review from lmangani March 22, 2026 19:02
@lmangani
lmangani marked this pull request as ready for review March 22, 2026 20:01
@lmangani
lmangani merged commit d6b5485 into main Mar 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants