openshot-audio  0.1.7
juce_AudioTransportSource.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_AUDIOTRANSPORTSOURCE_H_INCLUDED
26 #define JUCE_AUDIOTRANSPORTSOURCE_H_INCLUDED
27 
28 
29 //==============================================================================
43  public ChangeBroadcaster
44 {
45 public:
46  //==============================================================================
51 
54 
55  //==============================================================================
79  void setSource (PositionableAudioSource* newSource,
80  int readAheadBufferSize = 0,
81  TimeSliceThread* readAheadThread = nullptr,
82  double sourceSampleRateToCorrectFor = 0.0,
83  int maxNumChannels = 2);
84 
85  //==============================================================================
93  void setPosition (double newPosition);
94 
98  double getCurrentPosition() const;
99 
101  double getLengthInSeconds() const;
102 
104  bool hasStreamFinished() const noexcept { return inputStreamEOF; }
105 
106  //==============================================================================
112  void start();
113 
119  void stop();
120 
122  bool isPlaying() const noexcept { return playing; }
123 
124  //==============================================================================
129  void setGain (float newGain) noexcept;
130 
134  float getGain() const noexcept { return gain; }
135 
136  //==============================================================================
138  void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
139 
141  void releaseResources() override;
142 
144  void getNextAudioBlock (const AudioSourceChannelInfo&) override;
145 
146  //==============================================================================
148  void setNextReadPosition (int64 newPosition) override;
149 
151  int64 getNextReadPosition() const override;
152 
154  int64 getTotalLength() const override;
155 
157  bool isLooping() const override;
158 
159 private:
160  //==============================================================================
161  PositionableAudioSource* source;
162  ResamplingAudioSource* resamplerSource;
163  BufferingAudioSource* bufferingSource;
164  PositionableAudioSource* positionableSource;
165  AudioSource* masterSource;
166 
168  float volatile gain, lastGain;
169  bool volatile playing, stopped;
170  double sampleRate, sourceSampleRate;
171  int blockSize, readAheadBufferSize;
172  bool volatile isPrepared, inputStreamEOF;
173 
174  void releaseMasterResources();
175 
177 };
178 
179 
180 #endif // JUCE_AUDIOTRANSPORTSOURCE_H_INCLUDED
CriticalSection callbackLock
Definition: juce_mac_CoreMidi.cpp:258
Definition: juce_AudioSource.h:110
virtual int64 getNextReadPosition() const =0
virtual bool isLooping() const =0
Definition: juce_AudioTransportSource.h:42
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_ResamplingAudioSource.h:35
virtual int64 getTotalLength() const =0
virtual void releaseResources()=0
Definition: juce_ChangeBroadcaster.h:35
#define JUCE_API
Definition: juce_StandardHeader.h:139
virtual void prepareToPlay(int samplesPerBlockExpected, double sampleRate)=0
Definition: juce_CriticalSection.h:47
Definition: juce_BufferingAudioSource.h:39
Definition: juce_AudioSource.h:33
virtual void setNextReadPosition(int64 newPosition)=0
bool isPlaying() const noexcept
Definition: juce_AudioTransportSource.h:122
long long int64
Definition: juce_MathsFunctions.h:60
virtual void getNextAudioBlock(const AudioSourceChannelInfo &bufferToFill)=0
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_TimeSliceThread.h:84
Definition: juce_PositionableAudioSource.h:39
float getGain() const noexcept
Definition: juce_AudioTransportSource.h:134
bool hasStreamFinished() const noexcept
Definition: juce_AudioTransportSource.h:104