OpenShot Library | libopenshot-audio  0.1.9
juce_AudioSubsectionReader.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 
31 namespace juce
32 {
33 
34 //==============================================================================
35 /**
36  This class is used to wrap an AudioFormatReader and only read from a
37  subsection of the file.
38 
39  So if you have a reader which can read a 1000 sample file, you could wrap it
40  in one of these to only access, e.g. samples 100 to 200, and any samples
41  outside that will come back as 0. Accessing sample 0 from this reader will
42  actually read the first sample from the other's subsection, which might
43  be at a non-zero position.
44 
45  @see AudioFormatReader
46 
47  @tags{Audio}
48 */
50 {
51 public:
52  //==============================================================================
53  /** Creates an AudioSubsectionReader for a given data source.
54 
55  @param sourceReader the source reader from which we'll be taking data
56  @param subsectionStartSample the sample within the source reader which will be
57  mapped onto sample 0 for this reader.
58  @param subsectionLength the number of samples from the source that will
59  make up the subsection. If this reader is asked for
60  any samples beyond this region, it will return zero.
61  @param deleteSourceWhenDeleted if true, the sourceReader object will be deleted when
62  this object is deleted.
63  */
65  int64 subsectionStartSample,
66  int64 subsectionLength,
67  bool deleteSourceWhenDeleted);
68 
69  /** Destructor. */
70  ~AudioSubsectionReader() override;
71 
72 
73  //==============================================================================
74  bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
75  int64 startSampleInFile, int numSamples) override;
76 
77  void readMaxLevels (int64 startSample, int64 numSamples,
78  Range<float>* results, int numChannelsToRead) override;
79 
80 
81 private:
82  //==============================================================================
83  AudioFormatReader* const source;
84  int64 startSample, length;
85  const bool deleteSourceWhenDeleted;
86 
87  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSubsectionReader)
88 };
89 
90 } // namespace juce
91 
92 /** @}*/
#define JUCE_API
This macro is added to all JUCE public class declarations.
This class is used to wrap an AudioFormatReader and only read from a subsection of the file...
Reads samples from an audio file stream.
A general-purpose range object, that simply represents any linear range with a start and end point...
Definition: juce_Range.h:43