mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Deprecate the old AudioFormat::createWriterFor functions
This commit is contained in:
parent
eb7de7f15b
commit
1ce35453db
18 changed files with 47 additions and 189 deletions
|
|
@ -1,5 +1,38 @@
|
|||
# JUCE breaking changes
|
||||
|
||||
# develop
|
||||
|
||||
## Change
|
||||
|
||||
The AudioFormat class now only has one virtual createWriterFor member function:
|
||||
`createWriterFor (std::unique_ptr<OutputStream>&, const AudioFormatWriterOptions&)`.
|
||||
|
||||
The older createWriterFor overloads are now non-virtual and deprecated.
|
||||
|
||||
**Possible Issues**
|
||||
|
||||
Classes overriding the old AudioFormat::createWriterFor functions will fail to
|
||||
compile.
|
||||
|
||||
Additionally, code calling the old functions will emit a deprecation warning.
|
||||
|
||||
**Workaround**
|
||||
|
||||
Classes inheriting from AudioFormat should override the new createWriterFor
|
||||
function that takes an AudioFormatWriterOptions parameter.
|
||||
|
||||
**Rationale**
|
||||
|
||||
Adding support for writing wav files in 32-bit PCM format required the addition
|
||||
of another parameter to the AudioFormat::createWriterFor interface. This
|
||||
function already had many parameters, some of them already superfluous for some
|
||||
of the formats that share this interface. The introduction of a new options type
|
||||
makes it easier to extend this interface now and in the future. The old
|
||||
functions are marked deprecated, as allowing to override them would have made
|
||||
the implementation more complicated. The new signature better communicates
|
||||
resource ownership, helping to avoid bugs due to misuse.
|
||||
|
||||
|
||||
## Change
|
||||
|
||||
Some functions and types have been moved from the VST3ClientExtentions class
|
||||
|
|
|
|||
|
|
@ -1017,20 +1017,6 @@ MemoryMappedAudioFormatReader* AiffAudioFormat::createMemoryMappedReader (FileIn
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AudioFormatWriter* AiffAudioFormat::createWriterFor (OutputStream* out,
|
||||
double sampleRate,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int /*qualityOptionIndex*/)
|
||||
{
|
||||
if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample))
|
||||
return new AiffAudioFormatWriter (out, sampleRate, numberOfChannels,
|
||||
(unsigned int) bitsPerSample, metadataValues);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> AiffAudioFormat::createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,13 +88,6 @@ public:
|
|||
MemoryMappedAudioFormatReader* createMemoryMappedReader (const File&) override;
|
||||
MemoryMappedAudioFormatReader* createMemoryMappedReader (FileInputStream*) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) override;
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -654,17 +654,6 @@ AudioFormatReader* CoreAudioFormat::createReaderFor (InputStream* sourceStream,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream*,
|
||||
double /*sampleRateToUse*/,
|
||||
unsigned int /*numberOfChannels*/,
|
||||
int /*bitsPerSample*/,
|
||||
const StringPairArray& /*metadataValues*/,
|
||||
int /*qualityOptionIndex*/)
|
||||
{
|
||||
jassertfalse; // not yet implemented!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> CoreAudioFormat::createWriterFor (std::unique_ptr<OutputStream>&,
|
||||
const AudioFormatWriterOptions&)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,13 +106,6 @@ public:
|
|||
AudioFormatReader* createReaderFor (InputStream*,
|
||||
bool deleteStreamIfOpeningFails) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream*,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) override;
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -600,24 +600,6 @@ AudioFormatReader* FlacAudioFormat::createReaderFor (InputStream* in, const bool
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AudioFormatWriter* FlacAudioFormat::createWriterFor (OutputStream* out,
|
||||
double sampleRate,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& /*metadataValues*/,
|
||||
int qualityOptionIndex)
|
||||
{
|
||||
if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample))
|
||||
{
|
||||
std::unique_ptr<FlacWriter> w (new FlacWriter (out, sampleRate, numberOfChannels,
|
||||
(uint32) bitsPerSample, qualityOptionIndex));
|
||||
if (w->ok)
|
||||
return w.release();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> FlacAudioFormat::createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,13 +69,6 @@ public:
|
|||
AudioFormatReader* createReaderFor (InputStream* sourceStream,
|
||||
bool deleteStreamIfOpeningFails) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) override;
|
||||
|
||||
using AudioFormat::createWriterFor;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -234,30 +234,6 @@ std::unique_ptr<AudioFormatWriter> LAMEEncoderAudioFormat::createWriterFor (std:
|
|||
options.getMetadataValues());
|
||||
}
|
||||
|
||||
AudioFormatWriter* LAMEEncoderAudioFormat::createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex)
|
||||
{
|
||||
if (streamToWriteTo == nullptr)
|
||||
return nullptr;
|
||||
|
||||
int vbr = 4;
|
||||
int cbr = 0;
|
||||
|
||||
const String qual (getQualityOptions() [qualityOptionIndex]);
|
||||
|
||||
if (qual.contains ("VBR"))
|
||||
vbr = qual.retainCharacters ("0123456789").getIntValue();
|
||||
else
|
||||
cbr = qual.getIntValue();
|
||||
|
||||
return new Writer (streamToWriteTo, getFormatName(), lameApp, vbr, cbr,
|
||||
sampleRateToUse, numberOfChannels, bitsPerSample, metadataValues);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -74,10 +74,6 @@ public:
|
|||
|
||||
AudioFormatReader* createReaderFor (InputStream*, bool deleteStreamIfOpeningFails) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse,
|
||||
unsigned int numberOfChannels, int bitsPerSample,
|
||||
const StringPairArray& metadataValues, int qualityOptionIndex);
|
||||
|
||||
using AudioFormat::createWriterFor;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -3180,14 +3180,6 @@ std::unique_ptr<AudioFormatWriter> MP3AudioFormat::createWriterFor (std::unique_
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AudioFormatWriter* MP3AudioFormat::createWriterFor (OutputStream*, double /*sampleRateToUse*/,
|
||||
unsigned int /*numberOfChannels*/, int /*bitsPerSample*/,
|
||||
const StringPairArray& /*metadataValues*/, int /*qualityOptionIndex*/)
|
||||
{
|
||||
jassertfalse; // not yet implemented!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -71,10 +71,6 @@ public:
|
|||
//==============================================================================
|
||||
AudioFormatReader* createReaderFor (InputStream*, bool deleteStreamIfOpeningFails) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse,
|
||||
unsigned int numberOfChannels, int bitsPerSample,
|
||||
const StringPairArray& metadataValues, int qualityOptionIndex) override;
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -485,23 +485,6 @@ std::unique_ptr<AudioFormatWriter> OggVorbisAudioFormat::createWriterFor (std::u
|
|||
return w;
|
||||
}
|
||||
|
||||
AudioFormatWriter* OggVorbisAudioFormat::createWriterFor (OutputStream* out,
|
||||
double sampleRate,
|
||||
unsigned int numChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex)
|
||||
{
|
||||
if (out == nullptr)
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<OggWriter> w (new OggWriter (out, sampleRate, numChannels,
|
||||
(unsigned int) bitsPerSample,
|
||||
qualityOptionIndex, metadataValues));
|
||||
|
||||
return w->ok ? w.release() : nullptr;
|
||||
}
|
||||
|
||||
StringArray OggVorbisAudioFormat::getQualityOptions()
|
||||
{
|
||||
return { "64 kbps", "80 kbps", "96 kbps", "112 kbps", "128 kbps", "160 kbps",
|
||||
|
|
|
|||
|
|
@ -96,13 +96,6 @@ public:
|
|||
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) override;
|
||||
|
||||
using AudioFormat::createWriterFor;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -2042,29 +2042,6 @@ std::unique_ptr<AudioFormatWriter> WavAudioFormat::createWriterFor (std::unique_
|
|||
options.getSampleFormat());
|
||||
}
|
||||
|
||||
AudioFormatWriter* WavAudioFormat::createWriterFor (OutputStream* out, double sampleRate,
|
||||
unsigned int numChannels, int bitsPerSample,
|
||||
const StringPairArray& metadataValues, int qualityOptionIndex)
|
||||
{
|
||||
return createWriterFor (out, sampleRate, WavFileHelpers::canonicalWavChannelSet (static_cast<int> (numChannels)),
|
||||
bitsPerSample, metadataValues, qualityOptionIndex);
|
||||
}
|
||||
|
||||
AudioFormatWriter* WavAudioFormat::createWriterFor (OutputStream* out,
|
||||
double sampleRate,
|
||||
const AudioChannelSet& channelLayout,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int /*qualityOptionIndex*/)
|
||||
{
|
||||
if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample) && isChannelLayoutSupported (channelLayout))
|
||||
return new WavAudioFormatWriter (out, sampleRate, channelLayout,
|
||||
(unsigned int) bitsPerSample, toMap (metadataValues),
|
||||
AudioFormatWriterOptions::SampleFormat::automatic);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
namespace WavFileHelpers
|
||||
{
|
||||
static bool slowCopyWavFileWithNewMetadata (const File& file, const StringMap& metadata)
|
||||
|
|
|
|||
|
|
@ -300,20 +300,6 @@ public:
|
|||
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
const AudioChannelSet& channelLayout,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) override;
|
||||
|
||||
using AudioFormat::createWriterFor;
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -357,14 +357,6 @@ AudioFormatReader* WindowsMediaAudioFormat::createReaderFor (InputStream* source
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
AudioFormatWriter* WindowsMediaAudioFormat::createWriterFor (OutputStream* /*streamToWriteTo*/, double /*sampleRateToUse*/,
|
||||
unsigned int /*numberOfChannels*/, int /*bitsPerSample*/,
|
||||
const StringPairArray& /*metadataValues*/, int /*qualityOptionIndex*/)
|
||||
{
|
||||
jassertfalse; // not yet implemented!
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioFormatWriter> WindowsMediaAudioFormat::createWriterFor (std::unique_ptr<OutputStream>&,
|
||||
const AudioFormatWriterOptions&)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,10 +63,6 @@ public:
|
|||
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
|
||||
const AudioFormatWriterOptions& options) override;
|
||||
|
||||
AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse,
|
||||
unsigned int numberOfChannels, int bitsPerSample,
|
||||
const StringPairArray& metadataValues, int qualityOptionIndex) override;
|
||||
|
||||
using AudioFormat::createWriterFor;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -175,12 +175,13 @@ public:
|
|||
ignored
|
||||
@see AudioFormatWriter
|
||||
*/
|
||||
virtual AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex) = 0;
|
||||
[[deprecated ("Use the function taking an AudioFormatWriterOptions instead.")]]
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
unsigned int numberOfChannels,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex);
|
||||
|
||||
/** Tries to create an object that can write to a stream with this audio format.
|
||||
|
||||
|
|
@ -213,12 +214,13 @@ public:
|
|||
ignored
|
||||
@see AudioFormatWriter
|
||||
*/
|
||||
virtual AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
const AudioChannelSet& channelLayout,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex);
|
||||
[[deprecated ("Use the function taking an AudioFormatWriterOptions instead.")]]
|
||||
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
|
||||
double sampleRateToUse,
|
||||
const AudioChannelSet& channelLayout,
|
||||
int bitsPerSample,
|
||||
const StringPairArray& metadataValues,
|
||||
int qualityOptionIndex);
|
||||
|
||||
protected:
|
||||
/** Creates an AudioFormat object.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue