Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / src / audio / audio_file_formats / juce_AudioCDReader.h
blob18930c31de7c6696bc72dfdf745c1f782970165d
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_AUDIOCDREADER_JUCEHEADER__
27 #define __JUCE_AUDIOCDREADER_JUCEHEADER__
29 #if JUCE_USE_CDREADER || DOXYGEN
31 #include "juce_AudioFormatReader.h"
32 #include "../../containers/juce_Array.h"
33 #include "../../memory/juce_ScopedPointer.h"
34 #include "../../text/juce_StringArray.h"
35 #include "../../memory/juce_MemoryBlock.h"
36 #if JUCE_MAC
37 #include "../../io/files/juce_File.h"
38 #endif
40 //==============================================================================
41 /**
42 A type of AudioFormatReader that reads from an audio CD.
44 One of these can be used to read a CD as if it's one big audio stream. Use the
45 getPositionOfTrackStart() method to find where the individual tracks are
46 within the stream.
48 @see AudioFormatReader
50 class JUCE_API AudioCDReader : public AudioFormatReader
52 public:
53 //==============================================================================
54 /** Returns a list of names of Audio CDs currently available for reading.
56 If there's a CD drive but no CD in it, this might return an empty list, or
57 possibly a device that can be opened but which has no tracks, depending
58 on the platform.
60 @see createReaderForCD
62 static StringArray getAvailableCDNames();
64 /** Tries to create an AudioFormatReader that can read from an Audio CD.
66 @param index the index of one of the available CDs - use getAvailableCDNames()
67 to find out how many there are.
68 @returns a new AudioCDReader object, or 0 if it couldn't be created. The
69 caller will be responsible for deleting the object returned.
71 static AudioCDReader* createReaderForCD (const int index);
73 //==============================================================================
74 /** Destructor. */
75 ~AudioCDReader();
77 /** Implementation of the AudioFormatReader method. */
78 bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
79 int64 startSampleInFile, int numSamples);
81 /** Checks whether the CD has been removed from the drive.
83 bool isCDStillPresent() const;
85 /** Returns the total number of tracks (audio + data).
87 int getNumTracks() const;
89 /** Finds the sample offset of the start of a track.
91 @param trackNum the track number, where trackNum = 0 is the first track
92 and trackNum = getNumTracks() means the end of the CD.
94 int getPositionOfTrackStart (int trackNum) const;
96 /** Returns true if a given track is an audio track.
98 @param trackNum the track number, where 0 is the first track.
100 bool isTrackAudio (int trackNum) const;
102 /** Returns an array of sample offsets for the start of each track, followed by
103 the sample position of the end of the CD.
105 const Array<int>& getTrackOffsets() const;
107 /** Refreshes the object's table of contents.
109 If the disc has been ejected and a different one put in since this
110 object was created, this will cause it to update its idea of how many tracks
111 there are, etc.
113 void refreshTrackLengths();
115 /** Enables scanning for indexes within tracks.
117 @see getLastIndex
119 void enableIndexScanning (bool enabled);
121 /** Returns the index number found during the last read() call.
123 Index scanning is turned off by default - turn it on with enableIndexScanning().
125 Then when the read() method is called, if it comes across an index within that
126 block, the index number is stored and returned by this method.
128 Some devices might not support indexes, of course.
130 (If you don't know what CD indexes are, it's unlikely you'll ever need them).
132 @see enableIndexScanning
134 int getLastIndex() const;
136 /** Scans a track to find the position of any indexes within it.
138 @param trackNumber the track to look in, where 0 is the first track on the disc
139 @returns an array of sample positions of any index points found (not including
140 the index that marks the start of the track)
142 const Array <int> findIndexesInTrack (const int trackNumber);
144 /** Returns the CDDB id number for the CD.
146 It's not a great way of identifying a disc, but it's traditional.
148 int getCDDBId();
150 /** Tries to eject the disk.
152 Of course this might not be possible, if some other process is using it.
154 void ejectDisk();
156 //==============================================================================
157 enum
159 framesPerSecond = 75,
160 samplesPerFrame = 44100 / framesPerSecond
163 private:
164 //==============================================================================
165 Array<int> trackStartSamples;
167 #if JUCE_MAC
168 File volumeDir;
169 Array<File> tracks;
170 int currentReaderTrack;
171 ScopedPointer <AudioFormatReader> reader;
172 AudioCDReader (const File& volume);
174 #elif JUCE_WINDOWS
175 bool audioTracks [100];
176 void* handle;
177 MemoryBlock buffer;
178 bool indexingEnabled;
179 int lastIndex, firstFrameInBuffer, samplesInBuffer;
180 AudioCDReader (void* handle);
181 int getIndexAt (int samplePos);
183 #elif JUCE_LINUX
184 AudioCDReader();
185 #endif
187 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioCDReader);
190 #endif
191 #endif // __JUCE_AUDIOCDREADER_JUCEHEADER__