OpenShot Audio Library | OpenShotAudio  0.6.0
juce_AudioFormat.cpp
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2022 - Raw Material Software Limited
6 
7  JUCE is an open source library subject to commercial or open-source
8  licensing.
9 
10  By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11  Agreement and JUCE Privacy Policy.
12 
13  End User License Agreement: www.juce.com/juce-7-licence
14  Privacy Policy: www.juce.com/juce-privacy-policy
15 
16  Or: You may also use this code under the terms of the GPL v3 (see
17  www.gnu.org/licenses).
18 
19  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21  DISCLAIMED.
22 
23  ==============================================================================
24 */
25 
26 namespace juce
27 {
28 
30  : formatName (name), fileExtensions (extensions)
31 {
32 }
33 
35  : formatName (name.text), fileExtensions (StringArray::fromTokens (extensions, false))
36 {
37 }
38 
40 {
41 }
42 
44 {
45  for (auto& e : getFileExtensions())
46  if (f.hasFileExtension (e))
47  return true;
48 
49  return false;
50 }
51 
52 const String& AudioFormat::getFormatName() const { return formatName; }
53 StringArray AudioFormat::getFileExtensions() const { return fileExtensions; }
54 bool AudioFormat::isCompressed() { return false; }
56 
58 {
59  return nullptr;
60 }
61 
63 {
64  delete fin;
65  return nullptr;
66 }
67 
69 {
70  if (channelSet == AudioChannelSet::mono()) return canDoMono();
71  if (channelSet == AudioChannelSet::stereo()) return canDoStereo();
72 
73  return false;
74 }
75 
77  double sampleRateToUse,
78  const AudioChannelSet& channelLayout,
79  int bitsPerSample,
80  const StringPairArray& metadataValues,
81  int qualityOptionIndex)
82 {
83  if (isChannelLayoutSupported (channelLayout))
84  return createWriterFor (streamToWriteTo, sampleRateToUse,
85  static_cast<unsigned int> (channelLayout.size()),
86  bitsPerSample, metadataValues, qualityOptionIndex);
87 
88  return nullptr;
89 }
90 
91 } // namespace juce
int size() const noexcept
static AudioChannelSet JUCE_CALLTYPE mono()
static AudioChannelSet JUCE_CALLTYPE stereo()
virtual StringArray getFileExtensions() const
virtual bool isChannelLayoutSupported(const AudioChannelSet &channelSet)
virtual MemoryMappedAudioFormatReader * createMemoryMappedReader(const File &file)
virtual bool canDoStereo()=0
virtual StringArray getQualityOptions()
virtual bool canDoMono()=0
virtual bool canHandleFile(const File &fileToTest)
AudioFormat(String formatName, StringArray fileExtensions)
virtual AudioFormatWriter * createWriterFor(OutputStream *streamToWriteTo, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex)=0
const String & getFormatName() const
virtual bool isCompressed()
bool hasFileExtension(StringRef extensionToTest) const
Definition: juce_File.cpp:682