OpenShot Audio Library | OpenShotAudio  0.3.1
juce_AudioFormat.cpp
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
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 5 End-User License
11  Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12  27th April 2017).
13 
14  End User License Agreement: www.juce.com/juce-5-licence
15  Privacy Policy: www.juce.com/juce-5-privacy-policy
16 
17  Or: You may also use this code under the terms of the GPL v3 (see
18  www.gnu.org/licenses).
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 
31  : formatName (name), fileExtensions (extensions)
32 {
33 }
34 
36  : formatName (name.text), fileExtensions (StringArray::fromTokens (extensions, false))
37 {
38 }
39 
41 {
42 }
43 
45 {
46  for (auto& e : getFileExtensions())
47  if (f.hasFileExtension (e))
48  return true;
49 
50  return false;
51 }
52 
53 const String& AudioFormat::getFormatName() const { return formatName; }
54 StringArray AudioFormat::getFileExtensions() const { return fileExtensions; }
55 bool AudioFormat::isCompressed() { return false; }
57 
59 {
60  return nullptr;
61 }
62 
64 {
65  delete fin;
66  return nullptr;
67 }
68 
70 {
71  if (channelSet == AudioChannelSet::mono()) return canDoMono();
72  if (channelSet == AudioChannelSet::stereo()) return canDoStereo();
73 
74  return false;
75 }
76 
78  double sampleRateToUse,
79  const AudioChannelSet& channelLayout,
80  int bitsPerSample,
81  const StringPairArray& metadataValues,
82  int qualityOptionIndex)
83 {
84  if (isChannelLayoutSupported (channelLayout))
85  return createWriterFor (streamToWriteTo, sampleRateToUse,
86  static_cast<unsigned int> (channelLayout.size()),
87  bitsPerSample, metadataValues, qualityOptionIndex);
88 
89  return nullptr;
90 }
91 
92 } // 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:679