37 usesFloatingPointData (
false),
52 usesFloatingPointData (
false),
64static void convertFloatsToInts (
int* dest,
const float* src,
int numSamples)
noexcept
66 while (--numSamples >= 0)
68 const double samp = *src++;
85 const int bufferSize = 16384;
88 int*
buffers[128] = {
nullptr };
111 constexpr auto scaleFactor = 1.0f /
static_cast<float> (0x7fffffff);
114 FloatVectorOperations::convertFixedToFloat ((
float*) b, (
int*) b, scaleFactor,
numToDo);
116 convertFloatsToInts ((
int*) b, (
float*) b,
numToDo);
158 return write ((
const int**) channels, numSamples);
172 while (numSamples > 0)
177 convertFloatsToInts (
chans[(
size_t) i], channels[(
size_t) i] + startSample,
numToDo);
194 if (startSample == 0)
197 const float*
chans[256];
219 buffer (channels, numSamples),
220 timeSliceThread (
tst),
231 while (writePendingData() == 0)
235 bool write (
const float*
const* data,
int numSamples)
237 if (numSamples <= 0 || ! isRunning)
261 return writePendingData();
264 int writePendingData()
274 writer->writeFromAudioSampleBuffer (buffer,
start1,
size1);
278 if (receiver !=
nullptr)
279 receiver->addBlock (samplesWritten, buffer,
start1,
size1);
281 samplesWritten +=
size1;
285 writer->writeFromAudioSampleBuffer (buffer,
start2,
size2);
287 if (receiver !=
nullptr)
288 receiver->addBlock (samplesWritten, buffer,
start2,
size2);
290 samplesWritten +=
size2;
295 if (samplesPerFlush > 0)
299 if (flushSampleCounter <= 0)
301 flushSampleCounter = samplesPerFlush;
309 void setDataReceiver (IncomingDataReceiver*
newReceiver)
319 void setFlushInterval (
int numSamples)
noexcept
321 samplesPerFlush = numSamples;
326 AudioBuffer<float> buffer;
327 TimeSliceThread& timeSliceThread;
329 CriticalSection thumbnailLock;
330 IncomingDataReceiver* receiver = {};
331 int64 samplesWritten = 0;
332 int samplesPerFlush = 0, flushSampleCounter = 0;
349 return buffer->write (data, numSamples);
354 buffer->setDataReceiver (receiver);
void prepareToWrite(int numToWrite, int &startIndex1, int &blockSize1, int &startIndex2, int &blockSize2) const noexcept
Returns the location within the buffer at which an incoming block of data should be written.
int getTotalSize() const noexcept
Returns the total size of the buffer being managed.
void prepareToRead(int numWanted, int &startIndex1, int &blockSize1, int &startIndex2, int &blockSize2) const noexcept
Returns the location within the buffer from which the next block of data should be read.
void finishedRead(int numRead) noexcept
Called after reading from the FIFO, to indicate that this many items have now been consumed.
void finishedWrite(int numWritten) noexcept
Called after writing from the FIFO, to indicate that this many items have been added.
A multi-channel buffer containing floating point audio samples.
Type * getWritePointer(int channelNumber) noexcept
Returns a writeable pointer to one of the buffer's channels.
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
int getNumSamples() const noexcept
Returns the number of samples allocated in each of the buffer's channels.
void copyFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples) noexcept
Copies samples from another buffer to this one.
const Type * getReadPointer(int channelNumber) const noexcept
Returns a pointer to an array of read-only samples in one of the buffer's channels.
const Type *const * getArrayOfReadPointers() const noexcept
Returns an array of pointers to the channels in the buffer.
Represents a set of audio channel types.
Base class for objects that can produce a continuous stream of audio.
virtual void getNextAudioBlock(const AudioSourceChannelInfo &bufferToFill)=0
Called repeatedly to fetch subsequent blocks of audio data.
Automatically locks and unlocks a mutex object.
The base class for streams that write data to some kind of destination.
void notify() const
Wakes up the thread.
bool isThreadRunning() const
Returns true if the thread is currently active.
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...
void removeTimeSliceClient(TimeSliceClient *clientToRemove)
Removes a client from the list.
void addTimeSliceClient(TimeSliceClient *clientToAdd, int millisecondsBeforeStarting=0)
Adds a client to the list.
CriticalSection::ScopedLockType ScopedLock
Automatically locks and unlocks a CriticalSection object.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
constexpr int numElementsInArray(Type(&)[N]) noexcept
Handy function for getting the number of elements in a simple const C array.
long long int64
A platform-independent 64-bit integer type.
Used by AudioSource::getNextAudioBlock().
void clearActiveBufferRegion() const
Convenient method to clear the buffer if the source is not producing any data.