Skip to content

Commit

Permalink
Split utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
leonp-s committed Jan 17, 2024
1 parent d1730e6 commit 55a9b51
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 281 deletions.
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ enable_testing()

add_executable(unit_tests)
target_sources(unit_tests PRIVATE
ConvolverUtilitiesTests.cpp
SplitBlockTests.cpp
ComplexBufferTests.cpp
)

Expand Down
2 changes: 1 addition & 1 deletion test/ComplexBufferTests.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <catch2/catch_test_macros.hpp>
#include <melatonin_test_helpers/melatonin_test_helpers.h>
#include <zones_convolver/ConvolverUtilities.h>
#include <zones_convolver/util/ComplexBuffer.h>

SCENARIO ("can construct complex buffers with different channel and point sizes", "[ComplexBuffer]")
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <zones_convolver/ConvolverUtilities.h>

#include <catch2/catch_test_macros.hpp>
#include <melatonin_test_helpers/melatonin_test_helpers.h>
#include <zones_convolver/util/SplitBlock.h>

SCENARIO ("split blocks can be cleared", "[SplitBlock]")
{
Expand Down
197 changes: 0 additions & 197 deletions zones_convolver/ConvolverUtilities.cpp

This file was deleted.

78 changes: 0 additions & 78 deletions zones_convolver/ConvolverUtilities.h

This file was deleted.

19 changes: 19 additions & 0 deletions zones_convolver/util/CircularBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "CircularBuffer.h"

CircularBuffer::CircularBuffer (juce::AudioBuffer<float> & buffer)
: buffer_ (buffer)
{
}

SplitBlock CircularBuffer::GetNext (std::size_t advancement)
{
juce::dsp::AudioBlock<float> block {buffer_};
auto num_samples = buffer_.getNumSamples ();
head_position_ = (head_position_ + advancement) % num_samples;

auto first_samples_to_take = num_samples - head_position_;
auto wrapped_samples_to_take = num_samples - first_samples_to_take;

return {block.getSubBlock (head_position_, first_samples_to_take),
block.getSubBlock (0, wrapped_samples_to_take)};
}
16 changes: 16 additions & 0 deletions zones_convolver/util/CircularBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "SplitBlock.h"

#include <juce_dsp/juce_dsp.h>

class CircularBuffer
{
public:
explicit CircularBuffer (juce::AudioBuffer<float> & buffer);
SplitBlock GetNext (std::size_t advancement);

private:
std::size_t head_position_ = 0;
juce::AudioBuffer<float> & buffer_;
};
Loading

0 comments on commit 55a9b51

Please sign in to comment.