Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Resources/Scripts/gha_unit_tests.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
diff --git a/Tests/Processors/CMakeLists.txt b/Tests/Processors/CMakeLists.txt
index a89fa4da4..ab53e8d89 100644
index 5c14d2a0e..7770875b8 100644
--- a/Tests/Processors/CMakeLists.txt
+++ b/Tests/Processors/CMakeLists.txt
@@ -5,8 +5,8 @@ add_sources(${COMPONENT_NAME}_tests
@@ -5,9 +5,9 @@ add_sources(${COMPONENT_NAME}_tests
DataBufferTests.cpp
PluginManagerTests.cpp
SourceNodeTests.cpp
- RecordNodeTests.cpp
+ # RecordNodeTests.cpp
SIMDConverterTests.cpp
- ProcessorGraphTests.cpp
+ #RecordNodeTests.cpp
+ #ProcessorGraphTests.cpp
+ # ProcessorGraphTests.cpp
EventTests.cpp
DataThreadTests.cpp
GenericProcessorTests.cpp
3 changes: 2 additions & 1 deletion Source/Processors/AudioNode/AudioNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define __AUDIONODE_H_AF61F3C5__

#include "../../../JuceLibraryCode/JuceHeader.h"
#include "../../TestableExport.h"
#include <stdio.h>

#include "../Dsp/Dsp.h"
Expand Down Expand Up @@ -67,7 +68,7 @@ class Expander
@see GenericProcessor, AudioEditor

*/
class AudioNode : public GenericProcessor
class TESTABLE AudioNode : public GenericProcessor
{
public:
/** Constructor */
Expand Down
17 changes: 9 additions & 8 deletions Source/Processors/DataThreads/DataBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int DataBuffer::getNumSamples() const { return abstractFifo.getNumReady(); }

int DataBuffer::readAllFromBuffer (AudioBuffer<float>& data,
int64* blockSampleNumber,
double* blockTimestamp,
double* blockTimestamps,
uint64* eventCodes,
int maxSize,
int dstStartChannel,
Expand All @@ -134,15 +134,15 @@ int DataBuffer::readAllFromBuffer (AudioBuffer<float>& data,
blockSize1); // numSamples
}

memcpy (blockSampleNumber, sampleNumberBuffer + startIndex1, 8);
memcpy (blockTimestamp, timestampBuffer + startIndex1, 8);
memcpy (eventCodes, eventCodeBuffer + startIndex1, blockSize1 * 8);
memcpy (blockSampleNumber, sampleNumberBuffer + startIndex1, sizeof (int64));
memcpy (blockTimestamps, timestampBuffer + startIndex1, (size_t) blockSize1 * sizeof (double));
memcpy (eventCodes, eventCodeBuffer + startIndex1, (size_t) blockSize1 * sizeof (uint64));
}
else
{
// std::cout << "NO SAMPLES" << std::endl;
memcpy (blockSampleNumber, &lastSampleNumber, 8);
memcpy (blockTimestamp, &lastTimestamp, 8);
memcpy (blockSampleNumber, &lastSampleNumber, sizeof (int64));
memcpy (blockTimestamps, &lastTimestamp, sizeof (double));
}

if (blockSize2 > 0)
Expand All @@ -156,15 +156,16 @@ int DataBuffer::readAllFromBuffer (AudioBuffer<float>& data,
startIndex2, // sourceStartSample
blockSize2); // numSamples
}
memcpy (eventCodes + blockSize1, eventCodeBuffer + startIndex2, blockSize2 * 8);
memcpy (blockTimestamps + blockSize1, timestampBuffer + startIndex2, (size_t) blockSize2 * sizeof (double));
memcpy (eventCodes + blockSize1, eventCodeBuffer + startIndex2, (size_t) blockSize2 * sizeof (uint64));
}

// std::cout << "START SAMPLE FOR READ: " << *blockSampleNumber << std::endl;

if (numItems > 0)
{
lastSampleNumber = *blockSampleNumber;
lastTimestamp = *blockTimestamp;
lastTimestamp = *blockTimestamps;

// std::cout << "Updating last sample number: " << lastSampleNumber << std::endl;
}
Expand Down
6 changes: 5 additions & 1 deletion Source/Processors/DataThreads/DataBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ class PLUGIN_API DataBuffer
/** Returns the number of samples currently available in the buffer.*/
int getNumSamples() const;

/** Copies as many samples as possible from the DataBuffer to an AudioBuffer.*/
/** Copies as many samples as possible from the DataBuffer to an AudioBuffer.

The first sample number is returned in `sampleNumbers[0]`, while `timestamps`
and `eventCodes` receive one value per copied sample.
*/
int readAllFromBuffer (AudioBuffer<float>& data,
int64* sampleNumbers,
double* timestamps,
Expand Down
44 changes: 42 additions & 2 deletions Source/Processors/Events/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ size_t SystemEvent::fillTimestampAndSamplesData (HeapBlock<char>& data,
return eventSize;
}

size_t SystemEvent::fillTimestampArrayData (HeapBlock<char>& data,
const GenericProcessor* proc,
uint16 streamId,
int64 startSampleForBlock,
const double* timestamps,
uint32 nSamplesInBlock,
int64 processStartTime,
uint16 syncStreamId)
{
const size_t timestampDataSize = (size_t) nSamplesInBlock * sizeof (double);
const size_t eventSize = EVENT_BASE_SIZE + 4 + 8 + timestampDataSize;
const double startTimestampForBlock = nSamplesInBlock > 0 && timestamps != nullptr ? timestamps[0] : -1.0;

data.allocate (eventSize, true);
data[0] = SYSTEM_EVENT;
data[1] = TIMESTAMP_ARRAY;
*reinterpret_cast<uint16*> (data.getData() + 2) = proc->getNodeId();
*reinterpret_cast<uint16*> (data.getData() + 4) = streamId;
*reinterpret_cast<uint16*> (data.getData() + 6) = syncStreamId;
*reinterpret_cast<int64*> (data.getData() + 8) = startSampleForBlock;
*reinterpret_cast<double*> (data.getData() + 16) = startTimestampForBlock;
*reinterpret_cast<uint32*> (data.getData() + EVENT_BASE_SIZE) = nSamplesInBlock;
*reinterpret_cast<int64*> (data.getData() + EVENT_BASE_SIZE + 4) = processStartTime;

if (timestampDataSize > 0 && timestamps != nullptr)
memcpy (data.getData() + EVENT_BASE_SIZE + 12, timestamps, timestampDataSize);

return eventSize;
}

size_t SystemEvent::fillTimestampSyncTextData (
HeapBlock<char>& data,
const GenericProcessor* proc,
Expand Down Expand Up @@ -277,15 +307,25 @@ size_t SystemEvent::fillReferenceSampleEvent (HeapBlock<char>& data,

uint32 SystemEvent::getNumSamples (const EventPacket& packet)
{
if (getBaseType (packet) != SYSTEM_EVENT && getSystemEventType (packet) != TIMESTAMP_AND_SAMPLES)
if (getBaseType (packet) != SYSTEM_EVENT)
return 0;

Type type = getSystemEventType (packet);

if (type != TIMESTAMP_AND_SAMPLES && type != TIMESTAMP_ARRAY)
return 0;

return *reinterpret_cast<const uint32*> (packet.getRawData() + EVENT_BASE_SIZE);
}

int64 SystemEvent::getHiResTicks (const EventPacket& packet)
{
if (getBaseType (packet) != SYSTEM_EVENT && getSystemEventType (packet) != TIMESTAMP_AND_SAMPLES)
if (getBaseType (packet) != SYSTEM_EVENT)
return 0;

Type type = getSystemEventType (packet);

if (type != TIMESTAMP_AND_SAMPLES && type != TIMESTAMP_ARRAY)
return 0;

return *reinterpret_cast<const int64*> (packet.getRawData() + EVENT_BASE_SIZE + 4);
Expand Down
15 changes: 14 additions & 1 deletion Source/Processors/Events/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ class PLUGIN_API SystemEvent : public EventBase
TIMESTAMP_SYNC_TEXT = 3,

// Indicates reference sample information for each incoming data buffer
REFERENCE_SAMPLE = 4
REFERENCE_SAMPLE = 4,

// Per-sample timestamps for the current buffer
TIMESTAMP_ARRAY = 5
};

/* Create a TIMESTAMP_AND_SAMPLES event (used by processors that update timestamps) */
Expand All @@ -233,6 +236,16 @@ class PLUGIN_API SystemEvent : public EventBase
int64 processStartTime,
uint16 syncStreamId = 0);

/* Create a TIMESTAMP_ARRAY event (used by processors that provide per-sample timestamps) */
static size_t fillTimestampArrayData (HeapBlock<char>& data,
const GenericProcessor* proc,
uint16 streamId,
int64 startSampleForBlock,
const double* timestamps,
uint32 nSamplesInBlock,
int64 processStartTime,
uint16 syncStreamId = 0);

/* Create a TIMESTAMP_SYNC_TEXT event (used by Record Node) */
static size_t fillTimestampSyncTextData (HeapBlock<char>& data,
const GenericProcessor* proc,
Expand Down
Loading
Loading