Deprecate the old AudioFormat::createWriterFor functions is broken and does not compile

Latest commit Deprecate the old AudioFormat::createWriterFor functions does not compile.

In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:135:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h:73:98: error: non-virtual member function marked 'override' hides virtual member function
   73 |                                                         const AudioFormatWriterOptions& options) override;
      |                                                                                                  ^
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:127:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/format/juce_AudioFormat.h:145:48: note: hidden overloaded virtual function 'juce::AudioFormat::createWriterFor' declared here: type mismatch at 1st parameter ('std::unique_ptr<OutputStream> &' vs 'std::unique_ptr<OutputStream>')
  145 |     virtual std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
      |                                                ^
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:78:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp:57:94: error: no viable conversion from 'const StringPairArray' to 'const std::unordered_map<String, String>'
   57 |                                                                         .withMetadataValues (metadata));
      |                                                                                              ^~~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:66:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_basics/juce_audio_basics.h:66:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/juce_core.h:215:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/system/juce_StandardHeader.h:68:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/functional:552:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/__functional/boyer_moore_searcher.h:26:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/unordered_map:1129:25: note: candidate constructor not viable: no known conversion from 'const StringPairArray' to 'const unordered_map<String, String> &' for 1st argument
 1129 |   _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u);
      |                         ^             ~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/unordered_map:1132:25: note: candidate constructor not viable: no known conversion from 'const StringPairArray' to 'unordered_map<String, String> &&' for 1st argument
 1132 |   _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
      |                         ^             ~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/unordered_map:1134:25: note: candidate constructor not viable: no known conversion from 'const StringPairArray' to 'initializer_list<value_type>' (aka 'initializer_list<pair<const juce::String, juce::String>>') for 1st argument
 1134 |   _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il);
      |                         ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/unordered_map:1090:3: note: explicit constructor is not a candidate
 1090 |   unordered_map(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
      |   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/unordered_map:1128:34: note: explicit constructor is not a candidate
 1128 |   _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a);
      |                                  ^
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:124:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/format/juce_AudioFormatWriterOptions.h:126:106: note: passing argument to parameter 'x' here
  126 |     [[nodiscard]] AudioFormatWriterOptions withMetadataValues (const std::unordered_map<String, String>& x) const
      |                                                                                                          ^
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:78:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp:53:28: error: no matching member function for call to 'createWriterFor'
   53 |         writer = wavFormat.createWriterFor (tempWav.getFile().createOutputStream(),
      |                  ~~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:77:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp:2026:52: note: candidate function not viable: no known conversion from 'std::unique_ptr<FileOutputStream>' to 'std::unique_ptr<OutputStream> &' for 1st argument
 2026 | std::unique_ptr<AudioFormatWriter> WavAudioFormat::createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
      |                                                    ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:127:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/format/juce_AudioFormat.h:179:24: note: candidate function not viable: requires 6 arguments, but 2 were provided
  179 |     AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
      |                        ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  180 |                                         double sampleRateToUse,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~
  181 |                                         unsigned int numberOfChannels,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  182 |                                         int bitsPerSample,
      |                                         ~~~~~~~~~~~~~~~~~~
  183 |                                         const StringPairArray& metadataValues,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  184 |                                         int qualityOptionIndex);
      |                                         ~~~~~~~~~~~~~~~~~~~~~~
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/format/juce_AudioFormat.h:218:24: note: candidate function not viable: requires 6 arguments, but 2 were provided
  218 |     AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
      |                        ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  219 |                                         double sampleRateToUse,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~
  220 |                                         const AudioChannelSet& channelLayout,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221 |                                         int bitsPerSample,
      |                                         ~~~~~~~~~~~~~~~~~~
  222 |                                         const StringPairArray& metadataValues,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  223 |                                         int qualityOptionIndex);
      |                                         ~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:78:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp:210:60: error: out-of-line definition of 'createWriterFor' does not match any declaration in 'juce::LAMEEncoderAudioFormat'
  210 | std::unique_ptr<AudioFormatWriter> LAMEEncoderAudioFormat::createWriterFor (std::unique_ptr<OutputStream> streamToWriteTo,
      |                                                            ^~~~~~~~~~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:66:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_basics/juce_audio_basics.h:66:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/juce_core.h:215:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/system/juce_StandardHeader.h:62:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/algorithm:1842:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/__algorithm/for_each.h:16:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/__ranges/movable_box.h:21:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/optional:1294:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/memory:944:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/__memory/inout_ptr.h:16:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/__memory/shared_ptr.h:32:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:635:30: error: no matching constructor for initialization of 'juce::LAMEEncoderAudioFormat::Writer'
  635 |   return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
      |                              ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:78:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp:226:17: note: in instantiation of function template specialization 'std::make_unique<juce::LAMEEncoderAudioFormat::Writer, juce::OutputStream *, const juce::String &, juce::File &, int &, int &, double, unsigned int, int, std::unordered_map<juce::String, juce::String>>' requested here
  226 |     return std::make_unique<Writer> (streamToWriteTo.release(),
      |                 ^
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp:43:5: note: candidate constructor not viable: no known conversion from 'std::unordered_map<juce::String, juce::String>' to 'const StringPairArray' for 9th argument
   43 |     Writer (OutputStream* destStream, const String& formatName,
      |     ^
   44 |             const File& appFile, int vbr, int cbr,
   45 |             double sampleRateIn, unsigned int numberOfChannels,
   46 |             int bitsPerSampleIn, const StringPairArray& metadata)
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp:161:51: note: candidate constructor not viable: requires 1 argument, but 9 were provided
  161 |     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Writer)
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from /Users/rrabien/dev.github/juce_bugs/DoesntBuild/JuceLibraryCode/include_juce_audio_formats.mm:8:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.mm:35:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.cpp:48:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_formats/juce_audio_formats.h:66:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_audio_basics/juce_audio_basics.h:66:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/juce_core.h:215:
In file included from /Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/system/juce_StandardHeader.h:95:
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/system/juce_PlatformDefs.h:260:31: note: expanded from macro 'JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR'
  260 |     JUCE_DECLARE_NON_COPYABLE(className) \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/Users/rrabien/dev.github/juce_bugs/JUCE/modules/juce_core/system/juce_PlatformDefs.h:246:5: note: expanded from macro 'JUCE_DECLARE_NON_COPYABLE'
  246 |     className (const className&) = delete;\
      |     ^          ~~~~~~~~~~~~~~~~
5 errors generated.

3 Likes

Thank you for reporting. A fix is now out on develop

2 Likes

Whether I have JUCE_USE_LAME_AUDIO_FORMAT=1 or JUCE_USE_LAME_AUDIO_FORMAT=0 I get the compile error.

This is when compiling my TracktionEngine DAW.

Is there a workaround?

I can’t currently reproduce this issue, even when trying to build the Trackion Engine DemoRunner.

Can you make sure this issue persists on the current develop branch?

If yes, can you share

  • what OS you’re seeing this on
  • what’s the specific compile error that you’re seeing
  • how are you specifying the compile definitions

I am on Windows 11 (up-to-date), VS2022 17.14.7.

When digging deeper, I hit the error in a TracktionEngine module file;

modules/tracktion_engine/audio_files/formats/tracktion_FloatAudioFileFormat.h

>C:\SDKs\TracktionEngine\modules\tracktion_engine\audio_files\formats\tracktion_FloatAudioFileFormat.h(40,30): error C3668: 'tracktion::engine::FloatAudioFormat::createWriterFor': method with override specifier 'override' did not override any base class methods

This does not occur when using JUCE Master. It does occur with JUCE Develop from the past three or four weeks.

I am thinking they are building all the TracktionEngine stuff from JUCE Master, and so have not updated TracktionEngine to be level with JUCE Develop. So, it is just a matter of waiting for them to update.

However, if there is a work around, I’d like to be able to use JUCE Devleop.

This commit added a breaking change to develop

which is why Tracktion won’t compile with it. So the workaround would be to modify tracktion_FloatAudioFileFormat.h in line with what the BREAKING_CHANGES.md suggests.

Other than that yes, it’s a matter of waiting for this change to arrive in a versioned JUCE release, and then Tracktion adopting that.