OpenShot Audio Library | OpenShotAudio: juce_AudioTransportSource.h Source File

OpenShot Audio Library | OpenShotAudio 0.3.0

Loading...
Searching...
No Matches
juce_AudioTransportSource.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
41 class JUCE_API AudioTransportSource : public PositionableAudioSource,
42 public ChangeBroadcaster
43{
44public:
45 //==============================================================================
49 AudioTransportSource();
50
52 ~AudioTransportSource() override;
53
54 //==============================================================================
78 void setSource (PositionableAudioSource* newSource,
79 int readAheadBufferSize = 0,
80 TimeSliceThread* readAheadThread = nullptr,
81 double sourceSampleRateToCorrectFor = 0.0,
82 int maxNumChannels = 2);
83
84 //==============================================================================
94 void setPosition (double newPosition);
95
99 double getCurrentPosition() const;
100
102 double getLengthInSeconds() const;
103
105 bool hasStreamFinished() const noexcept { return inputStreamEOF; }
106
107 //==============================================================================
113 void start();
114
120 void stop();
121
123 bool isPlaying() const noexcept { return playing; }
124
125 //==============================================================================
130 void setGain (float newGain) noexcept;
131
135 float getGain() const noexcept { return gain; }
136
137 //==============================================================================
139 void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
140
142 void releaseResources() override;
143
145 void getNextAudioBlock (const AudioSourceChannelInfo&) override;
146
147 //==============================================================================
149 void setNextReadPosition (int64 newPosition) override;
150
152 int64 getNextReadPosition() const override;
153
155 int64 getTotalLength() const override;
156
158 bool isLooping() const override;
159
160private:
161 //==============================================================================
162 PositionableAudioSource* source = nullptr;
163 ResamplingAudioSource* resamplerSource = nullptr;
164 BufferingAudioSource* bufferingSource = nullptr;
165 PositionableAudioSource* positionableSource = nullptr;
166 AudioSource* masterSource = nullptr;
167
168 CriticalSection callbackLock;
169 float gain = 1.0f, lastGain = 1.0f;
170 std::atomic<bool> playing { false }, stopped { true };
171 double sampleRate = 44100.0, sourceSampleRate = 0;
172 int blockSize = 128, readAheadBufferSize = 0;
173 bool isPrepared = false, inputStreamEOF = false;
174
175 void releaseMasterResources();
176
177 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioTransportSource)
178};
179
180} // namespace juce
juce::AudioSource
Definition: juce_AudioSource.h:110
juce::AudioTransportSource
Definition: juce_AudioTransportSource.h:43
juce::AudioTransportSource::hasStreamFinished
bool hasStreamFinished() const noexcept
Definition: juce_AudioTransportSource.h:105
juce::AudioTransportSource::getGain
float getGain() const noexcept
Definition: juce_AudioTransportSource.h:135
juce::AudioTransportSource::isPlaying
bool isPlaying() const noexcept
Definition: juce_AudioTransportSource.h:123
juce::BufferingAudioSource
Definition: juce_BufferingAudioSource.h:40
juce::ChangeBroadcaster
Definition: juce_ChangeBroadcaster.h:35
juce::CriticalSection
Definition: juce_CriticalSection.h:43
juce::PositionableAudioSource
Definition: juce_PositionableAudioSource.h:39
juce::ResamplingAudioSource
Definition: juce_ResamplingAudioSource.h:35
juce::TimeSliceThread
Definition: juce_TimeSliceThread.h:83
juce::AudioSourceChannelInfo
Definition: juce_AudioSource.h:33