Loading...
Searching...
No Matches
juce_AudioFormat.cpp
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
AudioFormat::AudioFormat (String name, StringArray extensions)
: formatName (name), fileExtensions (extensions)
{
}
AudioFormat::AudioFormat (StringRef name, StringRef extensions)
: formatName (name.text), fileExtensions (StringArray::fromTokens (extensions, false))
{
}
AudioFormat::~AudioFormat()
{
}
bool AudioFormat::canHandleFile (const File& f)
{
for (auto& e : getFileExtensions())
if (f.hasFileExtension (e))
return true;
return false;
}
const String& AudioFormat::getFormatName() const { return formatName; }
StringArray AudioFormat::getFileExtensions() const { return fileExtensions; }
bool AudioFormat::isCompressed() { return false; }
StringArray AudioFormat::getQualityOptions() { return {}; }
MemoryMappedAudioFormatReader* AudioFormat::createMemoryMappedReader (const File&)
{
return nullptr;
}
MemoryMappedAudioFormatReader* AudioFormat::createMemoryMappedReader (FileInputStream* fin)
{
delete fin;
return nullptr;
}
bool AudioFormat::isChannelLayoutSupported (const AudioChannelSet& channelSet)
{
if (channelSet == AudioChannelSet::mono()) return canDoMono();
if (channelSet == AudioChannelSet::stereo()) return canDoStereo();
return false;
}
AudioFormatWriter* AudioFormat::createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
const AudioChannelSet& channelLayout,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex)
{
if (isChannelLayoutSupported (channelLayout))
return createWriterFor (streamToWriteTo, sampleRateToUse,
static_cast<unsigned int> (channelLayout.size()),
bitsPerSample, metadataValues, qualityOptionIndex);
return nullptr;
}
} // namespace juce
juce::AudioChannelSet
Definition juce_AudioChannelSet.h:47
juce::AudioChannelSet::size
int size() const noexcept
Definition juce_AudioChannelSet.cpp:483
juce::AudioChannelSet::mono
static AudioChannelSet JUCE_CALLTYPE mono()
Definition juce_AudioChannelSet.cpp:538
juce::AudioChannelSet::stereo
static AudioChannelSet JUCE_CALLTYPE stereo()
Definition juce_AudioChannelSet.cpp:539
juce::AudioFormatWriter
Definition juce_AudioFormatWriter.h:44
juce::AudioFormat::getFileExtensions
virtual StringArray getFileExtensions() const
Definition juce_AudioFormat.cpp:53
juce::AudioFormat::isChannelLayoutSupported
virtual bool isChannelLayoutSupported(const AudioChannelSet &channelSet)
Definition juce_AudioFormat.cpp:68
juce::AudioFormat::createMemoryMappedReader
virtual MemoryMappedAudioFormatReader * createMemoryMappedReader(const File &file)
Definition juce_AudioFormat.cpp:57
juce::AudioFormat::createWriterFor
virtual AudioFormatWriter * createWriterFor(OutputStream *streamToWriteTo, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex)=0
juce::AudioFormat::canDoStereo
virtual bool canDoStereo()=0
juce::AudioFormat::getQualityOptions
virtual StringArray getQualityOptions()
Definition juce_AudioFormat.cpp:55
juce::AudioFormat::canDoMono
virtual bool canDoMono()=0
juce::AudioFormat::canHandleFile
virtual bool canHandleFile(const File &fileToTest)
Definition juce_AudioFormat.cpp:43
juce::AudioFormat::AudioFormat
AudioFormat(String formatName, StringArray fileExtensions)
Definition juce_AudioFormat.cpp:29
juce::AudioFormat::~AudioFormat
virtual ~AudioFormat()
Definition juce_AudioFormat.cpp:39
juce::AudioFormat::getFormatName
const String & getFormatName() const
Definition juce_AudioFormat.cpp:52
juce::AudioFormat::isCompressed
virtual bool isCompressed()
Definition juce_AudioFormat.cpp:54
juce::FileInputStream
Definition juce_FileInputStream.h:35
juce::File
Definition juce_File.h:45
juce::File::hasFileExtension
bool hasFileExtension(StringRef extensionToTest) const
Definition juce_File.cpp:682
juce::MemoryMappedAudioFormatReader
Definition juce_MemoryMappedAudioFormatReader.h:47
juce::OutputStream
Definition juce_OutputStream.h:38
juce::StringArray
Definition juce_StringArray.h:35
juce::StringPairArray
Definition juce_StringPairArray.h:35
juce::StringRef
Definition juce_StringRef.h:62
juce::String
Definition juce_String.h:53