OpenShot Library | libopenshot-audio  0.2.0
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
juce::AudioFormat::getFormatName
const String & getFormatName() const
Returns the name of this format.
Definition: juce_AudioFormat.cpp:53
juce::StringArray
A special array for holding a list of strings.
Definition: juce_StringArray.h:38
juce::StringRef
A simple class for holding temporary references to a string literal or String.
Definition: juce_StringRef.h:65
juce::AudioFormat::createWriterFor
virtual AudioFormatWriter * createWriterFor(OutputStream *streamToWriteTo, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, const StringPairArray &metadataValues, int qualityOptionIndex)=0
Tries to create an object that can write to a stream with this audio format.
juce::AudioFormat::createMemoryMappedReader
virtual MemoryMappedAudioFormatReader * createMemoryMappedReader(const File &file)
Attempts to create a MemoryMappedAudioFormatReader, if possible for this format.
Definition: juce_AudioFormat.cpp:58
juce::AudioFormat::isCompressed
virtual bool isCompressed()
Returns true if the format uses compressed data.
Definition: juce_AudioFormat.cpp:55
juce::AudioFormat::getQualityOptions
virtual StringArray getQualityOptions()
Returns a list of different qualities that can be used when writing.
Definition: juce_AudioFormat.cpp:56
juce::AudioFormat::canDoMono
virtual bool canDoMono()=0
Returns true if the format can do 1-channel audio.
juce::AudioFormat::~AudioFormat
virtual ~AudioFormat()
Destructor.
Definition: juce_AudioFormat.cpp:40
juce::OutputStream
The base class for streams that write data to some kind of destination.
Definition: juce_OutputStream.h:41
juce::File
Represents a local file or directory.
Definition: juce_File.h:44
juce::AudioFormat::getFileExtensions
virtual StringArray getFileExtensions() const
Returns all the file extensions that might apply to a file of this format.
Definition: juce_AudioFormat.cpp:54
juce::StringPairArray
A container for holding a set of strings which are keyed by another string.
Definition: juce_StringPairArray.h:38
juce::AudioChannelSet
Represents a set of audio channel types.
Definition: juce_AudioChannelSet.h:50
juce::FileInputStream
An input stream that reads from a local file.
Definition: juce_FileInputStream.h:38
juce::AudioFormat::AudioFormat
AudioFormat(String formatName, StringArray fileExtensions)
Creates an AudioFormat object.
Definition: juce_AudioFormat.cpp:30
juce::AudioChannelSet::mono
static AudioChannelSet JUCE_CALLTYPE mono()
Creates a one-channel mono set (centre).
Definition: juce_AudioChannelSet.cpp:378
juce::AudioFormat::canDoStereo
virtual bool canDoStereo()=0
Returns true if the format can do 2-channel audio.
juce::AudioFormat::canHandleFile
virtual bool canHandleFile(const File &fileToTest)
Returns true if this the given file can be read by this format.
Definition: juce_AudioFormat.cpp:44
juce::String
The JUCE String class!
Definition: juce_String.h:42
juce::AudioFormatWriter
Writes samples to an audio file stream.
Definition: juce_AudioFormatWriter.h:48
juce::File::hasFileExtension
bool hasFileExtension(StringRef extensionToTest) const
Checks whether the file has a given extension.
Definition: juce_File.cpp:659
juce::AudioChannelSet::size
int size() const noexcept
Returns the number of channels in the set.
Definition: juce_AudioChannelSet.cpp:323
juce::AudioFormat::isChannelLayoutSupported
virtual bool isChannelLayoutSupported(const AudioChannelSet &channelSet)
Returns true if the channel layout is supported by this format.
Definition: juce_AudioFormat.cpp:69
juce::AudioChannelSet::stereo
static AudioChannelSet JUCE_CALLTYPE stereo()
Creates a set containing a stereo set (left, right).
Definition: juce_AudioChannelSet.cpp:379
juce::MemoryMappedAudioFormatReader
A specialised type of AudioFormatReader that uses a MemoryMappedFile to read directly from an audio f...
Definition: juce_MemoryMappedAudioFormatReader.h:51