OpenShot Library | libopenshot-audio  0.2.0
juce_AudioFormatReaderSource.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  A type of AudioSource that will read from an AudioFormatReader.
37 
38  @see PositionableAudioSource, AudioTransportSource, BufferingAudioSource
39 
40  @tags{Audio}
41 */
43 {
44 public:
45  //==============================================================================
46  /** Creates an AudioFormatReaderSource for a given reader.
47 
48  @param sourceReader the reader to use as the data source - this must
49  not be null
50  @param deleteReaderWhenThisIsDeleted if true, the reader passed-in will be deleted
51  when this object is deleted; if false it will be
52  left up to the caller to manage its lifetime
53  */
55  bool deleteReaderWhenThisIsDeleted);
56 
57  /** Destructor. */
58  ~AudioFormatReaderSource() override;
59 
60  //==============================================================================
61  /** Toggles loop-mode.
62 
63  If set to true, it will continuously loop the input source. If false,
64  it will just emit silence after the source has finished.
65 
66  @see isLooping
67  */
68  void setLooping (bool shouldLoop) override;
69 
70  /** Returns whether loop-mode is turned on or not. */
71  bool isLooping() const override { return looping; }
72 
73  /** Returns the reader that's being used. */
74  AudioFormatReader* getAudioFormatReader() const noexcept { return reader; }
75 
76  //==============================================================================
77  /** Implementation of the AudioSource method. */
78  void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
79 
80  /** Implementation of the AudioSource method. */
81  void releaseResources() override;
82 
83  /** Implementation of the AudioSource method. */
84  void getNextAudioBlock (const AudioSourceChannelInfo&) override;
85 
86  //==============================================================================
87  /** Implements the PositionableAudioSource method. */
88  void setNextReadPosition (int64 newPosition) override;
89 
90  /** Implements the PositionableAudioSource method. */
91  int64 getNextReadPosition() const override;
92 
93  /** Implements the PositionableAudioSource method. */
94  int64 getTotalLength() const override;
95 
96 private:
97  //==============================================================================
99 
100  int64 nextPlayPos;
101  bool looping;
102 
103  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFormatReaderSource)
104 };
105 
106 } // namespace juce
107 
108 /** @}*/
juce::PositionableAudioSource
A type of AudioSource which can be repositioned.
Definition: juce_PositionableAudioSource.h:42
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition: juce_StandardHeader.h:143
juce::AudioFormatReaderSource::getAudioFormatReader
AudioFormatReader * getAudioFormatReader() const noexcept
Returns the reader that's being used.
Definition: juce_AudioFormatReaderSource.h:74
juce::AudioSourceChannelInfo
Used by AudioSource::getNextAudioBlock().
Definition: juce_AudioSource.h:36
juce::OptionalScopedPointer
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.
Definition: juce_OptionalScopedPointer.h:43
juce::AudioFormatReaderSource
A type of AudioSource that will read from an AudioFormatReader.
Definition: juce_AudioFormatReaderSource.h:42
juce::AudioFormatReaderSource::isLooping
bool isLooping() const override
Returns whether loop-mode is turned on or not.
Definition: juce_AudioFormatReaderSource.h:71
juce::AudioFormatReader
Reads samples from an audio file stream.
Definition: juce_AudioFormatReader.h:48