Skip to content

Fix JUCE API method name in audio file writer#13

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-macos-build-errors-again
Draft

Fix JUCE API method name in audio file writer#13
Copilot wants to merge 2 commits intomainfrom
copilot/fix-macos-build-errors-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

macOS build fails at PluginProcessor.cpp:433 due to calling non-existent writeFromFloatSampleBuffer method on AudioFormatWriter.

Changes

  • ml-bridge/plugin/PluginProcessor.cpp:433: Corrected method name to writeFromAudioSampleBuffer
// Before
if (writer->writeFromFloatSampleBuffer(fileBuffer, 0, numSamples))

// After  
if (writer->writeFromAudioSampleBuffer(fileBuffer, 0, numSamples))

The fileBuffer is already AudioBuffer<float>, which is the expected parameter type for writeFromAudioSampleBuffer.

Original prompt

Problem

The macOS build is failing with compilation errors in ml-bridge/plugin/PluginProcessor.cpp:

Error 1 (line 433):

error: no member named 'writeFromFloatSampleBuffer' in 'juce::AudioFormatWriter'; did you mean 'writeFromAudioSampleBuffer'?

Error 2 (line 431):

warning: 'createWriterFor' is deprecated: Use the function taking an AudioFormatWriterOptions instead.

Root Cause

The code at lines 429-436 in ml-bridge/plugin/PluginProcessor.cpp uses:

  1. A deprecated JUCE API for creating the audio format writer
  2. An incorrect method name writeFromFloatSampleBuffer that doesn't exist (should be writeFromAudioSampleBuffer)

Current Code (lines 429-436)

juce::OutputStream* raw = outStream.release();
juce::WavAudioFormat wavFormat;
if (auto* writer = wavFormat.createWriterFor(raw, fileSampleRate, static_cast<unsigned int>(numCh), 24, {}, 0))
{
    if (writer->writeFromFloatSampleBuffer(fileBuffer, 0, numSamples))
        addToLibrary(wavFile, promptForLibrary);
    delete writer;
}
else
{
    delete raw;
}

Required Fix

Replace the code block (lines 429-441 in the handleAsyncUpdate() method) with the correct JUCE API usage:

juce::OutputStream* raw = outStream.release();
juce::WavAudioFormat wavFormat;
if (auto* writer = wavFormat.createWriterFor(raw, fileSampleRate, static_cast<unsigned int>(numCh), 24, {}, 0))
{
    if (writer->writeFromAudioSampleBuffer(fileBuffer, 0, numSamples))
        addToLibrary(wavFile, promptForLibrary);
    delete writer;
}
else
{
    delete raw;
}

Key Changes:

  1. Change writeFromFloatSampleBuffer to writeFromAudioSampleBuffer on line 433
  2. Keep the existing createWriterFor signature as-is (the warning is acceptable; the newer AudioFormatWriterOptions-based API may not be available in all JUCE versions used)

Validation

The fix must:

  • Resolve the compilation error by using the correct method name
  • Not break existing functionality
  • Work with the JUCE version in the project dependencies

Reference

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…oSampleBuffer

Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix macOS build errors in PluginProcessor.cpp Fix JUCE API method name in audio file writer Feb 6, 2026
Copilot AI requested a review from lmangani February 6, 2026 14:00
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