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_AUDIOSUBSECTIONREADER_JUCEHEADER__
27 #define __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__
29 #include "juce_AudioFormatReader.h"
32 //==============================================================================
34 This class is used to wrap an AudioFormatReader and only read from a
35 subsection of the file.
37 So if you have a reader which can read a 1000 sample file, you could wrap it
38 in one of these to only access, e.g. samples 100 to 200, and any samples
39 outside that will come back as 0. Accessing sample 0 from this reader will
40 actually read the first sample from the other's subsection, which might
41 be at a non-zero position.
43 @see AudioFormatReader
45 class JUCE_API AudioSubsectionReader
: public AudioFormatReader
48 //==============================================================================
49 /** Creates a AudioSubsectionReader for a given data source.
51 @param sourceReader the source reader from which we'll be taking data
52 @param subsectionStartSample the sample within the source reader which will be
53 mapped onto sample 0 for this reader.
54 @param subsectionLength the number of samples from the source that will
55 make up the subsection. If this reader is asked for
56 any samples beyond this region, it will return zero.
57 @param deleteSourceWhenDeleted if true, the sourceReader object will be deleted when
58 this object is deleted.
60 AudioSubsectionReader (AudioFormatReader
* sourceReader
,
61 int64 subsectionStartSample
,
62 int64 subsectionLength
,
63 bool deleteSourceWhenDeleted
);
66 ~AudioSubsectionReader();
69 //==============================================================================
70 bool readSamples (int** destSamples
, int numDestChannels
, int startOffsetInDestBuffer
,
71 int64 startSampleInFile
, int numSamples
);
73 void readMaxLevels (int64 startSample
,
82 //==============================================================================
83 AudioFormatReader
* const source
;
84 int64 startSample
, length
;
85 const bool deleteSourceWhenDeleted
;
87 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSubsectionReader
);
90 #endif // __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__