JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_BufferingAudioSource.h
Go to the documentation of this file.
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//==============================================================================
39 private TimeSliceClient
40{
41public:
42 //==============================================================================
58 TimeSliceThread& backgroundThread,
59 bool deleteSourceWhenDeleted,
60 int numberOfSamplesToBuffer,
61 int numberOfChannels = 2,
62 bool prefillBufferOnPrepareToPlay = true);
63
69 ~BufferingAudioSource() override;
70
71 //==============================================================================
73 void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
74
76 void releaseResources() override;
77
79 void getNextAudioBlock (const AudioSourceChannelInfo&) override;
80
81 //==============================================================================
83 void setNextReadPosition (int64 newPosition) override;
84
86 int64 getNextReadPosition() const override;
87
89 int64 getTotalLength() const override { return source->getTotalLength(); }
90
92 bool isLooping() const override { return source->isLooping(); }
93
98 bool waitForNextAudioBlockReady (const AudioSourceChannelInfo& info, uint32 timeout);
99
100private:
101 //==============================================================================
102 Range<int> getValidBufferRange (int numSamples) const;
103 bool readNextBufferChunk();
104 void readBufferSection (int64 start, int length, int bufferOffset);
105 int useTimeSlice() override;
106
107 //==============================================================================
109 TimeSliceThread& backgroundThread;
110 int numberOfSamplesToBuffer, numberOfChannels;
111 AudioBuffer<float> buffer;
112 CriticalSection callbackLock, bufferRangeLock;
113 WaitableEvent bufferReadyEvent;
114 int64 bufferValidStart = 0, bufferValidEnd = 0;
115 std::atomic<int64> nextPlayPos { 0 };
116 double sampleRate = 0;
117 bool wasSourceLooping = false, isPrepared = false;
118 const bool prefillBuffer;
119
120 //==============================================================================
122};
123
124} // namespace juce
A multi-channel buffer containing floating point audio samples.
An AudioSource which takes another source as input, and buffers it using a thread.
int64 getTotalLength() const override
Implements the PositionableAudioSource method.
bool isLooping() const override
Implements the PositionableAudioSource method.
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.
A type of AudioSource which can be repositioned.
virtual bool isLooping() const =0
Returns true if this source is actually playing in a loop.
virtual int64 getTotalLength() const =0
Returns the total length of the stream (in samples).
A general-purpose range object, that simply represents any linear range with a start and end point.
Definition juce_Range.h:40
Used by the TimeSliceThread class.
A thread that keeps a list of clients, and calls each one in turn, giving them all a chance to run so...
Allows threads to wait for events triggered by other threads.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.
Used by AudioSource::getNextAudioBlock().