Massive UI work
[juce-lv2.git] / juce / source / src / audio / audio_file_formats / juce_AudioFormatManager.h
blob068f68b4e0ec4c4c906e9e0013218a8c35f0a1cf
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__
27 #define __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__
29 #include "juce_AudioFormat.h"
30 #include "../../core/juce_Singleton.h"
31 #include "../../containers/juce_OwnedArray.h"
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.
39 You can either use this class as a singleton object, or create instances of it
40 yourself. Once created, use its registerFormat() method to tell it which
41 formats it should use.
43 @see AudioFormat
45 class JUCE_API AudioFormatManager
47 public:
48 //==============================================================================
49 /** Creates an empty format manager.
51 Before it'll be any use, you'll need to call registerFormat() with all the
52 formats you want it to be able to recognise.
54 AudioFormatManager();
56 /** Destructor. */
57 ~AudioFormatManager();
59 //==============================================================================
60 /** Adds a format to the manager's list of available file types.
62 The object passed-in will be deleted by this object, so don't keep a pointer
63 to it!
65 If makeThisTheDefaultFormat is true, then the getDefaultFormat() method will
66 return this one when called.
68 void registerFormat (AudioFormat* newFormat,
69 bool makeThisTheDefaultFormat);
71 /** 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.
75 void registerBasicFormats();
77 /** Clears the list of known formats. */
78 void clearFormats();
80 /** Returns the number of currently registered file formats. */
81 int getNumKnownFormats() const;
83 /** Returns one of the registered file formats. */
84 AudioFormat* getKnownFormat (int index) const;
86 /** Looks for which of the known formats is listed as being for a given file
87 extension.
89 The extension may have a dot before it, so e.g. ".wav" or "wav" are both ok.
91 AudioFormat* findFormatForFileExtension (const String& fileExtension) const;
93 /** Returns the format which has been set as the default one.
95 You can set a format as being the default when it is registered. It's useful
96 when you want to write to a file, because the best format may change between
97 platforms, e.g. AIFF is preferred on the Mac, WAV on Windows.
99 If none has been set as the default, this method will just return the first
100 one in the list.
102 AudioFormat* getDefaultFormat() const;
104 /** Returns a set of wildcards for file-matching that contains the extensions for
105 all known formats.
107 E.g. if might return "*.wav;*.aiff" if it just knows about wavs and aiffs.
109 String getWildcardForAllFormats() const;
111 //==============================================================================
112 /** Searches through the known formats to try to create a suitable reader for
113 this file.
115 If none of the registered formats can open the file, it'll return 0. If it
116 returns a reader, it's the caller's responsibility to delete the reader.
118 AudioFormatReader* createReaderFor (const File& audioFile);
120 /** Searches through the known formats to try to create a suitable reader for
121 this stream.
123 The stream object that is passed-in will be deleted by this method or by the
124 reader that is returned, so the caller should not keep any references to it.
126 The stream that is passed-in must be capable of being repositioned so
127 that all the formats can have a go at opening it.
129 If none of the registered formats can open the stream, it'll return 0. If it
130 returns a reader, it's the caller's responsibility to delete the reader.
132 AudioFormatReader* createReaderFor (InputStream* audioFileStream);
134 private:
135 //==============================================================================
136 OwnedArray<AudioFormat> knownFormats;
137 int defaultFormatIndex;
139 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatManager);
143 #endif // __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__