33 jassert (audioSourceBeingRead !=
nullptr);
37 sampleRate = audioSourceBeingRead->getSampleRate();
38 numChannels = (
unsigned int) audioSourceBeingRead->getChannelCount();
42 audioSourceBeingRead->addListener (
this);
44 if (audioSourceBeingRead->isSampleAccessEnabled())
45 hostReader.reset (
new ARA::PlugIn::HostAudioReader (audioSourceBeingRead));
48ARAAudioSourceReader::~ARAAudioSourceReader()
62 audioSourceBeingRead->removeListener (
this);
63 audioSourceBeingRead =
nullptr;
66void ARAAudioSourceReader::willUpdateAudioSourceProperties (ARAAudioSource*
audioSource,
77void ARAAudioSourceReader::doUpdateAudioSourceContent ([[maybe_unused]] ARAAudioSource* audioSource,
78 ARAContentUpdateScopes scopeFlags)
80 jassert (audioSourceBeingRead == audioSource);
83 if (scopeFlags.affectSamples())
87void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess ([[maybe_unused]] ARAAudioSource* audioSource,
bool enable)
89 jassert (audioSourceBeingRead == audioSource);
94 ScopedWriteLock scopedLock (lock);
99void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess ([[maybe_unused]] ARAAudioSource* audioSource,
bool enable)
101 jassert (audioSourceBeingRead == audioSource);
106 ScopedWriteLock scopedLock (lock);
107 hostReader.reset (
new ARA::PlugIn::HostAudioReader (audioSourceBeingRead));
111void ARAAudioSourceReader::willDestroyAudioSource ([[maybe_unused]] ARAAudioSource* audioSource)
113 jassert (audioSourceBeingRead == audioSource);
128 if (readLock.
isLocked() && hostReader !=
nullptr)
130 for (
size_t i = 0; i < tmpPtrs.size(); ++i)
141 static thread_local std::vector<uint8_t>
dummyBuffer;
150 return hostReader->readAudioSamples (
startSampleInFile, numSamples, tmpPtrs.data());
189 if (playbackRenderer !=
nullptr)
201 playbackRenderer->addPlaybackRegion (ARA::PlugIn::toRef (
playbackRegion));
208 playbackRenderer->prepareToPlay (rate,
211 AudioProcessor::ProcessingPrecision::singlePrecision,
212 ARARenderer::AlwaysNonRealtime::yes);
221ARAPlaybackRegionReader::~ARAPlaybackRegionReader()
233 for (
auto&
playbackRegion : playbackRenderer->getPlaybackRegions())
236 playbackRenderer->releaseResources();
237 playbackRenderer.reset();
256 while (numSamples > 0)
261 success &= playbackRenderer->processBlock (buffer, AudioProcessor::Realtime::no, positionInfo);
276void ARAPlaybackRegionReader::willUpdatePlaybackRegionProperties (ARAPlaybackRegion*
playbackRegion, ARAPlaybackRegion::PropertiesPtr
newProperties)
278 jassert (ARA::contains (playbackRenderer->getPlaybackRegions(),
playbackRegion));
284 || (
playbackRegion->isTimestretchEnabled() != ((
newProperties->transformationFlags & ARA::kARAPlaybackTransformationTimestretch) != 0))
285 || (
playbackRegion->isTimeStretchReflectingTempo() != ((
newProperties->transformationFlags & ARA::kARAPlaybackTransformationTimestretchReflectingTempo) != 0))
286 || (
playbackRegion->hasContentBasedFadeAtHead() != ((
newProperties->transformationFlags & ARA::kARAPlaybackTransformationContentBasedFadeAtHead) != 0))
287 || (
playbackRegion->hasContentBasedFadeAtTail() != ((
newProperties->transformationFlags & ARA::kARAPlaybackTransformationContentBasedFadeAtTail) != 0)))
293void ARAPlaybackRegionReader::didUpdatePlaybackRegionContent ([[maybe_unused]] ARAPlaybackRegion* playbackRegion,
294 ARAContentUpdateScopes scopeFlags)
296 jassert (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion));
299 if (scopeFlags.affectSamples())
303void ARAPlaybackRegionReader::willDestroyPlaybackRegion ([[maybe_unused]] ARAPlaybackRegion* playbackRegion)
305 jassert (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion));
ARAAudioSourceReader(ARAAudioSource *audioSource)
bool readSamples(int *const *destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) override
bool readSamples(int *const *destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) override
ARAPlaybackRegionReader(ARAPlaybackRegion *playbackRegion)
void setTimeInSamples(Optional< int64_t > timeInSamplesIn)
Optional< int64_t > getTimeInSamples() const
void setTimeInSeconds(Optional< double > timeInSecondsIn)
void setIsPlaying(bool isPlayingIn)
bool isLocked() const noexcept