Loading...
Searching...
No Matches
juce_AudioTransportSource.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API AudioTransportSource : public PositionableAudioSource,
public ChangeBroadcaster
{
public:
//==============================================================================
AudioTransportSource();
~AudioTransportSource() override;
//==============================================================================
void setSource (PositionableAudioSource* newSource,
int readAheadBufferSize = 0,
TimeSliceThread* readAheadThread = nullptr,
double sourceSampleRateToCorrectFor = 0.0,
int maxNumChannels = 2);
//==============================================================================
void setPosition (double newPosition);
double getCurrentPosition() const;
double getLengthInSeconds() const;
bool hasStreamFinished() const noexcept;
//==============================================================================
void start();
void stop();
bool isPlaying() const noexcept { return playing; }
//==============================================================================
void setGain (float newGain) noexcept;
float getGain() const noexcept { return gain; }
//==============================================================================
void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
void releaseResources() override;
void getNextAudioBlock (const AudioSourceChannelInfo&) override;
//==============================================================================
void setNextReadPosition (int64 newPosition) override;
int64 getNextReadPosition() const override;
int64 getTotalLength() const override;
bool isLooping() const override;
private:
//==============================================================================
PositionableAudioSource* source = nullptr;
ResamplingAudioSource* resamplerSource = nullptr;
BufferingAudioSource* bufferingSource = nullptr;
PositionableAudioSource* positionableSource = nullptr;
AudioSource* masterSource = nullptr;
CriticalSection callbackLock;
float gain = 1.0f, lastGain = 1.0f;
std::atomic<bool> playing { false }, stopped { true };
double sampleRate = 44100.0, sourceSampleRate = 0;
int blockSize = 128, readAheadBufferSize = 0;
bool isPrepared = false;
void releaseMasterResources();
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioTransportSource)
};
} // 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