OpenShot Audio Library | OpenShotAudio: juce_AudioFormat.cpp Source File

OpenShot Audio Library | OpenShotAudio 0.3.1

Loading...
Searching...
No Matches
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
27namespace juce
28{
29
30AudioFormat::AudioFormat (String name, StringArray extensions)
31 : formatName (name), fileExtensions (extensions)
32{
33}
34
35 AudioFormat::AudioFormat (StringRef name, StringRef extensions)
36 : formatName (name.text), fileExtensions (StringArray::fromTokens (extensions, false))
37{
38}
39
40AudioFormat::~AudioFormat()
41{
42}
43
44 bool AudioFormat::canHandleFile (const File& f)
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; }
56 StringArray AudioFormat::getQualityOptions() { return {}; }
57
58 MemoryMappedAudioFormatReader* AudioFormat::createMemoryMappedReader (const File&)
59{
60 return nullptr;
61}
62
63 MemoryMappedAudioFormatReader* AudioFormat::createMemoryMappedReader (FileInputStream* fin)
64{
65 delete fin;
66 return nullptr;
67}
68
69 bool AudioFormat::isChannelLayoutSupported (const AudioChannelSet& channelSet)
70{
71 if (channelSet == AudioChannelSet::mono()) return canDoMono();
72 if (channelSet == AudioChannelSet::stereo()) return canDoStereo();
73
74 return false;
75}
76
77 AudioFormatWriter* AudioFormat::createWriterFor (OutputStream* streamToWriteTo,
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::AudioChannelSet
Definition: juce_AudioChannelSet.h:47
juce::AudioChannelSet::size
int size() const noexcept
Definition: juce_AudioChannelSet.cpp:323
juce::AudioChannelSet::mono
static AudioChannelSet JUCE_CALLTYPE mono()
Definition: juce_AudioChannelSet.cpp:378
juce::AudioChannelSet::stereo
static AudioChannelSet JUCE_CALLTYPE stereo()
Definition: juce_AudioChannelSet.cpp:379
juce::AudioFormatWriter
Definition: juce_AudioFormatWriter.h:45
juce::AudioFormat::getFileExtensions
virtual StringArray getFileExtensions() const
Definition: juce_AudioFormat.cpp:54
juce::AudioFormat::isChannelLayoutSupported
virtual bool isChannelLayoutSupported(const AudioChannelSet &channelSet)
Definition: juce_AudioFormat.cpp:69
juce::AudioFormat::createMemoryMappedReader
virtual MemoryMappedAudioFormatReader * createMemoryMappedReader(const File &file)
Definition: juce_AudioFormat.cpp:58
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:56
juce::AudioFormat::canDoMono
virtual bool canDoMono()=0
juce::AudioFormat::canHandleFile
virtual bool canHandleFile(const File &fileToTest)
Definition: juce_AudioFormat.cpp:44
juce::AudioFormat::AudioFormat
AudioFormat(String formatName, StringArray fileExtensions)
Definition: juce_AudioFormat.cpp:30
juce::AudioFormat::~AudioFormat
virtual ~AudioFormat()
Definition: juce_AudioFormat.cpp:40
juce::AudioFormat::getFormatName
const String & getFormatName() const
Definition: juce_AudioFormat.cpp:53
juce::AudioFormat::isCompressed
virtual bool isCompressed()
Definition: juce_AudioFormat.cpp:55
juce::FileInputStream
Definition: juce_FileInputStream.h:35
juce::File
Definition: juce_File.h:41
juce::File::hasFileExtension
bool hasFileExtension(StringRef extensionToTest) const
Definition: juce_File.cpp:679
juce::MemoryMappedAudioFormatReader
Definition: juce_MemoryMappedAudioFormatReader.h:48
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:39