OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
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
29 AudioFormat::AudioFormat (String name, StringArray extensions)
30 : formatName (name), fileExtensions (extensions)
31{
32}
33
34 AudioFormat::AudioFormat (StringRef name, StringRef extensions)
35 : formatName (name.text), fileExtensions (StringArray::fromTokens (extensions, false))
36{
37}
38
39 AudioFormat::~AudioFormat()
40{
41}
42
43 bool AudioFormat::canHandleFile (const File& f)
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; }
55 StringArray AudioFormat::getQualityOptions() { return {}; }
56
57 MemoryMappedAudioFormatReader* AudioFormat::createMemoryMappedReader (const File&)
58{
59 return nullptr;
60}
61
62 MemoryMappedAudioFormatReader* AudioFormat::createMemoryMappedReader (FileInputStream* fin)
63{
64 delete fin;
65 return nullptr;
66}
67
68 bool AudioFormat::isChannelLayoutSupported (const AudioChannelSet& channelSet)
69{
70 if (channelSet == AudioChannelSet::mono()) return canDoMono();
71 if (channelSet == AudioChannelSet::stereo()) return canDoStereo();
72
73 return false;
74}
75
76 AudioFormatWriter* AudioFormat::createWriterFor (OutputStream* streamToWriteTo,
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
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