OpenShot Library | OpenShotAudio 0.2.2
juce_AudioFormatManager.h
1
2/** @weakgroup juce_audio_formats-format
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 By using JUCE, you agree to the terms of both the JUCE 5 End-User License
15 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
16 27th April 2017).
17
18 End User License Agreement: www.juce.com/juce-5-licence
19 Privacy Policy: www.juce.com/juce-5-privacy-policy
20
21 Or: You may also use this code under the terms of the GPL v3 (see
22 www.gnu.org/licenses).
23
24 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
25 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
26 DISCLAIMED.
27
28 ==============================================================================
29*/
30
31namespace juce
32{
33
34//==============================================================================
35/**
36 A class for keeping a list of available audio formats, and for deciding which
37 one to use to open a given file.
38
39 After creating an AudioFormatManager object, you should call registerFormat()
40 or registerBasicFormats() to give it a list of format types that it can use.
41
42 @see AudioFormat
43
44 @tags{Audio}
45*/
47{
48public:
49 //==============================================================================
50 /** Creates an empty format manager.
51
52 Before it'll be any use, you'll need to call registerFormat() with all the
53 formats you want it to be able to recognise.
54 */
56
57 /** Destructor. */
59
60 //==============================================================================
61 /** Adds a format to the manager's list of available file types.
62
63 The object passed-in will be deleted by this object, so don't keep a pointer
64 to it!
65
66 If makeThisTheDefaultFormat is true, then the getDefaultFormat() method will
67 return this one when called.
68 */
69 void registerFormat (AudioFormat* newFormat,
70 bool makeThisTheDefaultFormat);
71
72 /** Handy method to make it easy to register the formats that come with JUCE.
73 This will add WAV and AIFF to the list, along with any other formats enabled
74 in either the Projucer or your application's AppConfig.h.
75 */
76 void registerBasicFormats();
77
78 /** Clears the list of known formats. */
79 void clearFormats();
80
81 /** Returns the number of currently registered file formats. */
82 int getNumKnownFormats() const;
83
84 /** Returns one of the registered file formats. */
85 AudioFormat* getKnownFormat (int index) const;
86
87 /** Iterator access to the list of known formats. */
88 AudioFormat** begin() noexcept { return knownFormats.begin(); }
89
90 /** Iterator access to the list of known formats. */
91 AudioFormat* const* begin() const noexcept { return knownFormats.begin(); }
92
93 /** Iterator access to the list of known formats. */
94 AudioFormat** end() noexcept { return knownFormats.end(); }
95
96 /** Iterator access to the list of known formats. */
97 AudioFormat* const* end() const noexcept { return knownFormats.end(); }
98
99 /** Looks for which of the known formats is listed as being for a given file
100 extension.
101
102 The extension may have a dot before it, so e.g. ".wav" or "wav" are both ok.
103 */
104 AudioFormat* findFormatForFileExtension (const String& fileExtension) const;
105
106 /** Returns the format which has been set as the default one.
107
108 You can set a format as being the default when it is registered. It's useful
109 when you want to write to a file, because the best format may change between
110 platforms, e.g. AIFF is preferred on the Mac, WAV on Windows.
111
112 If none has been set as the default, this method will just return the first
113 one in the list.
114 */
115 AudioFormat* getDefaultFormat() const;
116
117 /** Returns a set of wildcards for file-matching that contains the extensions for
118 all known formats.
119
120 E.g. if might return "*.wav;*.aiff" if it just knows about wavs and aiffs.
121 */
122 String getWildcardForAllFormats() const;
123
124 //==============================================================================
125 /** Searches through the known formats to try to create a suitable reader for
126 this file.
127
128 If none of the registered formats can open the file, it'll return nullptr.
129 It's the caller's responsibility to delete the reader that is returned.
130 */
131 AudioFormatReader* createReaderFor (const File& audioFile);
132
133 /** Searches through the known formats to try to create a suitable reader for
134 this stream.
135
136 The stream object that is passed-in will be deleted by this method or by the
137 reader that is returned, so the caller should not keep any references to it.
138
139 The stream that is passed-in must be capable of being repositioned so
140 that all the formats can have a go at opening it.
141
142 If none of the registered formats can open the stream, it'll return nullptr.
143 If it returns a reader, it's the caller's responsibility to delete the reader.
144 */
145 AudioFormatReader* createReaderFor (InputStream* audioFileStream);
146
147private:
148 //==============================================================================
149 OwnedArray<AudioFormat> knownFormats;
150 int defaultFormatIndex = 0;
151
152 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatManager)
153};
154
155} // namespace juce
156
157/** @}*/
A class for keeping a list of available audio formats, and for deciding which one to use to open a gi...
AudioFormat ** end() noexcept
Iterator access to the list of known formats.
AudioFormat *const * begin() const noexcept
Iterator access to the list of known formats.
AudioFormat *const * end() const noexcept
Iterator access to the list of known formats.
AudioFormat ** begin() noexcept
Iterator access to the list of known formats.
Reads samples from an audio file stream.
Subclasses of AudioFormat are used to read and write different audio file formats.
Represents a local file or directory.
Definition: juce_File.h:45
The base class for streams that read data.
An array designed for holding objects.
The JUCE String class!
Definition: juce_String.h:43
#define JUCE_API
This macro is added to all JUCE public class declarations.