OpenShot Audio Library | OpenShotAudio: juce_AudioTransportSource.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0 |

Loading...
Searching...
No Matches
juce_AudioTransportSource.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
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;
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;
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::stop
void stop()
Definition juce_AudioTransportSource.cpp:121
juce::AudioTransportSource::hasStreamFinished
bool hasStreamFinished() const noexcept
Definition juce_AudioTransportSource.cpp:157
juce::AudioTransportSource::getCurrentPosition
double getCurrentPosition() const
Definition juce_AudioTransportSource.cpp:141
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::AudioTransportSource::setPosition
void setPosition(double newPosition)
Definition juce_AudioTransportSource.cpp:135
juce::AudioTransportSource::getLengthInSeconds
double getLengthInSeconds() const
Definition juce_AudioTransportSource.cpp:149
juce::AudioTransportSource::setSource
void setSource(PositionableAudioSource *newSource, int readAheadBufferSize=0, TimeSliceThread *readAheadThread=nullptr, double sourceSampleRateToCorrectFor=0.0, int maxNumChannels=2)
Definition juce_AudioTransportSource.cpp:36
juce::AudioTransportSource::AudioTransportSource
AudioTransportSource()
Definition juce_AudioTransportSource.cpp:26
juce::AudioTransportSource::start
void start()
Definition juce_AudioTransportSource.cpp:107
juce::BufferingAudioSource
Definition juce_BufferingAudioSource.h:40
juce::ChangeBroadcaster::ChangeBroadcaster
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::PositionableAudioSource
Definition juce_PositionableAudioSource.h:39
juce::PositionableAudioSource::PositionableAudioSource
PositionableAudioSource()=default
juce::ResamplingAudioSource
Definition juce_ResamplingAudioSource.h:35
juce::TimeSliceThread
Definition juce_TimeSliceThread.h:83
juce::AudioSourceChannelInfo
Definition juce_AudioSource.h:33