OpenShot Library | libopenshot-audio 0.2.0
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,
71
72 /** Handy method to make it easy to register the formats that come with JUCE.
73 Currently, this will add WAV and AIFF to the list.
74 */
75 void registerBasicFormats();
76
77 /** Clears the list of known formats. */
78 void clearFormats();
79
80 /** Returns the number of currently registered file formats. */
81 int getNumKnownFormats() const;
82
83 /** Returns one of the registered file formats. */
84 AudioFormat* getKnownFormat (int index) const;
85
86 /** Iterator access to the list of known formats. */
87 AudioFormat** begin() const noexcept { return knownFormats.begin(); }
88
89 /** Iterator access to the list of known formats. */
90 AudioFormat** end() const noexcept { return knownFormats.end(); }
91
92 /** Looks for which of the known formats is listed as being for a given file
93 extension.
94
95 The extension may have a dot before it, so e.g. ".wav" or "wav" are both ok.
96 */
97 AudioFormat* findFormatForFileExtension (const String& fileExtension) const;
98
99 /** Returns the format which has been set as the default one.
100
101 You can set a format as being the default when it is registered. It's useful
102 when you want to write to a file, because the best format may change between
103 platforms, e.g. AIFF is preferred on the Mac, WAV on Windows.
104
105 If none has been set as the default, this method will just return the first
106 one in the list.
107 */
108 AudioFormat* getDefaultFormat() const;
109
110 /** Returns a set of wildcards for file-matching that contains the extensions for
111 all known formats.
112
113 E.g. if might return "*.wav;*.aiff" if it just knows about wavs and aiffs.
114 */
115 String getWildcardForAllFormats() const;
116
117 //==============================================================================
118 /** Searches through the known formats to try to create a suitable reader for
119 this file.
120
121 If none of the registered formats can open the file, it'll return nullptr.
122 It's the caller's responsibility to delete the reader that is returned.
123 */
124 AudioFormatReader* createReaderFor (const File& audioFile);
125
126 /** Searches through the known formats to try to create a suitable reader for
127 this stream.
128
129 The stream object that is passed-in will be deleted by this method or by the
130 reader that is returned, so the caller should not keep any references to it.
131
132 The stream that is passed-in must be capable of being repositioned so
133 that all the formats can have a go at opening it.
134
135 If none of the registered formats can open the stream, it'll return nullptr.
136 If it returns a reader, it's the caller's responsibility to delete the reader.
137 */
139
140private:
141 //==============================================================================
142 OwnedArray<AudioFormat> knownFormats;
143 int defaultFormatIndex = 0;
144
145 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatManager)
146};
147
148} // namespace juce
149
150/** @}*/
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:60
ElementType * begin() const noexcept
Returns a pointer to the first element in the array.
Definition juce_Array.h:309
ElementType * end() const noexcept
Returns a pointer to the element which follows the last element in the array.
Definition juce_Array.h:317
A class for keeping a list of available audio formats, and for deciding which one to use to open a gi...
AudioFormat ** end() const noexcept
Iterator access to the list of known formats.
AudioFormat ** begin() const 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.
The JUCE String class!
Definition juce_String.h:43
#define JUCE_API
This macro is added to all JUCE public class declarations.