Skip to content

Commit

Permalink
prepare windows port
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonZimmer committed Feb 10, 2025
1 parent cd3e723 commit d148661
Show file tree
Hide file tree
Showing 29 changed files with 117 additions and 104 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.13)

if (APPLE)
include(toolchains/macToolchain.cmake)
elseif (WIN32)
include(toolchains/windowsToolchain.cmake)
endif ()

project(seele)

set(CONAN_DISABLE_CHECK_COMPILER TRUE)
Expand Down
8 changes: 4 additions & 4 deletions core/inc/core/AudioBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ namespace hidonash::core

void setSample(int destChannel, int destSample, float newValue) override;

int getNumChannels() const override;
size_t getNumChannels() const override;

int getNumSamples() const override;
size_t getNumSamples() const override;

float* getDataPointer() const override;

Expand Down Expand Up @@ -99,8 +99,8 @@ namespace hidonash::core
};

private:
int numChannels_ = 0;
int numSamples_ = 0;
size_t numChannels_ = 0;
size_t numSamples_ = 0;

MemoryBlock memoryBlock_;
float* const* data_;
Expand Down
4 changes: 2 additions & 2 deletions core/inc/core/IAudioBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace hidonash::core

virtual void setSample(int destChannel, int destSample, float newValue) = 0;

virtual int getNumChannels() const = 0;
virtual size_t getNumChannels() const = 0;

virtual int getNumSamples() const = 0;
virtual size_t getNumSamples() const = 0;

virtual float* getDataPointer() const = 0;

Expand Down
10 changes: 5 additions & 5 deletions core/mocks/inc/AudioBufferMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ namespace hidonash::core

MOCK_METHOD(float, getSample, (int, int), (const));

MOCK_METHOD(void, setSample, (int, int, float));
MOCK_METHOD(void, setSample, (int, int, float) );

MOCK_METHOD(int, getNumChannels, (), (const));
MOCK_METHOD(size_t, getNumChannels, (), (const));

MOCK_METHOD(int, getNumSamples, (), (const));
MOCK_METHOD(size_t, getNumSamples, (), (const));

MOCK_METHOD(float*, getDataPointer, (), (const));

MOCK_METHOD(const std::unique_ptr<IAudioBuffer::IChannel>, getChannel, (size_t channel), (const));

MOCK_METHOD(std::unique_ptr<IAudioBuffer::IChannel>, getChannel, (size_t channel));

MOCK_METHOD(void, fill, (float));
MOCK_METHOD(void, fill, (float) );

MOCK_METHOD(void, copyFrom, (const IAudioBuffer&));
MOCK_METHOD(void, copyFrom, (const IAudioBuffer&) );

MOCK_METHOD(void, copy, (const IAudioBuffer&, size_t, size_t, size_t));

Expand Down
22 changes: 12 additions & 10 deletions core/src/AudioBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ namespace hidonash::core

void AudioBuffer::Channel::fill(float value)
{
for (auto sa = 0; sa < size_; ++sa)
for (size_t sa = 0; sa < size_; ++sa)
buffer_[sa] = value;
}

void AudioBuffer::Channel::applyGain(float gain)
{
for (auto sa = 0; sa < size_; ++sa)
for (size_t sa = 0; sa < size_; ++sa)
buffer_[sa] *= gain;
}

Expand Down Expand Up @@ -60,12 +60,12 @@ namespace hidonash::core
*(data_[destChannel] + destSample) = newValue;
}

int AudioBuffer::getNumChannels() const
size_t AudioBuffer::getNumChannels() const
{
return numChannels_;
}

int AudioBuffer::getNumSamples() const
size_t AudioBuffer::getNumSamples() const
{
return numSamples_;
}
Expand Down Expand Up @@ -93,8 +93,8 @@ namespace hidonash::core

void AudioBuffer::fill(float value)
{
for (auto ch = 0; ch < numChannels_; ++ch)
for (auto sa = 0; sa < numSamples_; ++sa)
for (size_t ch = 0; ch < numChannels_; ++ch)
for (size_t sa = 0; sa < numSamples_; ++sa)
setSample(ch, sa, value);
}

Expand All @@ -104,10 +104,11 @@ namespace hidonash::core
memcpy(data_[0], other.getDataPointer(), numChannels_ * numSamples_ * sizeof(float));
else
{
const auto channelsToCopy = std::min(other.getNumChannels(), numChannels_);
const auto samplesToCopy = std::min(numSamples_, other.getNumSamples());
const auto channelsToCopy =
static_cast<size_t>(std::min(static_cast<int>(other.getNumChannels()), static_cast<int>(numChannels_)));
const auto samplesToCopy = std::min(static_cast<int>(numSamples_), static_cast<int>(other.getNumSamples()));

for (auto c = size_t {0}; c < channelsToCopy; ++c)
for (size_t c = 0; c < channelsToCopy; ++c)
memcpy(data_[c], other.getDataPointer(), samplesToCopy * sizeof(float));
}
}
Expand Down Expand Up @@ -136,7 +137,8 @@ namespace hidonash::core

void AudioBuffer::multiply(const std::vector<float>& from, size_t multiplyLength)
{
const auto numChannels = std::min(numChannels_, static_cast<int>(from.size()));
const auto numChannels =
static_cast<size_t>(std::min(static_cast<int>(numChannels_), static_cast<int>(from.size())));

for (size_t c = 0; c < numChannels; ++c)
for (size_t i = 0; i < multiplyLength; ++i)
Expand Down
6 changes: 3 additions & 3 deletions seele/inc/MiniSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace hidonash
}

void drawLinearSlider(juce::Graphics& graphics, int x, int y, int width, int height, float sliderPos,
float minSliderPos, float maxSliderPos, const juce::Slider::SliderStyle style,
juce::Slider& slider) override
float /*minSliderPos*/, float /*maxSliderPos*/,
const juce::Slider::SliderStyle /*style*/, juce::Slider& slider) override
{
const auto sliderWidth = slider.getWidth();
graphics.setColour(currentColour_);
Expand Down Expand Up @@ -78,7 +78,7 @@ namespace hidonash
setLookAndFeel(nullptr);
}

void mouseEnter(const juce::MouseEvent& e) override
void mouseEnter(const juce::MouseEvent&) override
{
setMouseCursor(juce::MouseCursor::StandardCursorType::PointingHandCursor);
lookAndFeel_.setHighlightColour();
Expand Down
1 change: 0 additions & 1 deletion seele/inc/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class NewProjectAudioProcessor : public juce::AudioProcessor
juce::AudioProcessorValueTreeState parameters_;
hidonash::MemberParameterSetPtr memberParameterSet_;

int currentProgram_;
hidonash::AudioProcessorPtr engine_;

juce::AudioBuffer<float> visualizationBuffer_;
Expand Down
8 changes: 4 additions & 4 deletions seele/inc/SeeleSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace hidonash
setColour(juce::Slider::ColourIds::textBoxOutlineColourId, juce::Colours::transparentBlack);
}

void drawLinearSlider(juce::Graphics& graphics, int x, int y, int width, int height, float sliderPos,
float minSliderPos, float maxSliderPos, const juce::Slider::SliderStyle style,
juce::Slider& slider) override
void drawLinearSlider(juce::Graphics& graphics, int x, int /*y*/, int /*width*/, int height,
float sliderPos, float /*minSliderPos*/, float /*maxSliderPos*/,
const juce::Slider::SliderStyle /*style*/, juce::Slider& slider) override
{
graphics.fillAll(juce::Colour::fromRGB(40, 40, 70));
const auto sliderWidth = slider.getWidth();
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace hidonash
setLookAndFeel(nullptr);
}

void mouseEnter(const juce::MouseEvent& e) override
void mouseEnter(const juce::MouseEvent&) override
{
setMouseCursor(juce::MouseCursor::StandardCursorType::PointingHandCursor);
lookAndFeel_.setHighlightColour();
Expand Down
6 changes: 3 additions & 3 deletions seele/seeleCore/inc/seeleCore/Analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace hidonash
private:
int freqPerBin_;

std::array<float, config::constants::analysisSize / 2 + 1> lastPhase_;
std::array<float, config::constants::analysisSize> analysisFrequencyBuffer_;
std::array<float, config::constants::analysisSize> analysisMagnitudeBuffer_;
std::array<float, config::constants::fftFrameSize / 2 + 1> lastPhase_;
std::array<float, config::constants::fftFrameSize> analysisFrequencyBuffer_;
std::array<float, config::constants::fftFrameSize> analysisMagnitudeBuffer_;
};

}
1 change: 0 additions & 1 deletion seele/seeleCore/inc/seeleCore/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace hidonash
{
constexpr auto pi = 3.14159265358979323846;
constexpr auto fftFrameSize = 2048;
constexpr auto analysisSize = 2 * fftFrameSize;
constexpr auto oversamplingFactor = 8;
constexpr auto stepSize = fftFrameSize / oversamplingFactor;
constexpr auto inFifoLatency = fftFrameSize - stepSize;
Expand Down
1 change: 0 additions & 1 deletion seele/seeleCore/inc/seeleCore/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace hidonash
const IMemberParameterSet& memberParameterSet_;
core::AudioBuffer accumulationBuffer_;
size_t numChannels_;
double sampleRate_;
std::vector<float> lastDistances_;
};
}
4 changes: 2 additions & 2 deletions seele/seeleCore/inc/seeleCore/IAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace hidonash
{
struct AnalysisResult
{
std::array<float, config::constants::analysisSize> magnitudeBuffer;
std::array<float, config::constants::analysisSize> frequencyBuffer;
std::array<float, config::constants::fftFrameSize> magnitudeBuffer;
std::array<float, config::constants::fftFrameSize> frequencyBuffer;
};

class IAnalysis
Expand Down
13 changes: 6 additions & 7 deletions seele/seeleCore/inc/seeleCore/PitchShifter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ namespace hidonash
SynthesisPtr synthesis_;

float pitchFactor_;
double gainCompensation_;

long sampleCounter_;

std::unique_ptr<juce::dsp::FFT> fft_;
std::array<juce::dsp::Complex<float>, 2 * config::constants::analysisSize> fftWorkspace_;
std::array<juce::dsp::Complex<float>, config::constants::fftFrameSize> fftWorkspace_;

std::array<float, config::constants::fftFrameSize> fifoIn_;
std::array<float, config::constants::fftFrameSize> fifoOut_;
std::array<float, config::constants::fftFrameSize> outputAccumulationBuffer_;

std::array<float, config::constants::analysisSize> fifoIn_;
std::array<float, config::constants::analysisSize> fifoOut_;
std::array<float, 2 * config::constants::analysisSize> outputAccumulationBuffer_;
size_t sampleCounter_;
};
}
6 changes: 3 additions & 3 deletions seele/seeleCore/inc/seeleCore/Synthesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace hidonash
AnalysisPtr analysis_;
int freqPerBin_;

std::array<float, config::constants::analysisSize / 2 + 1> sumPhase_;
std::array<float, config::constants::analysisSize> frequencyBuffer_;
std::array<float, config::constants::analysisSize> magnitudeBuffer_;
std::array<float, config::constants::fftFrameSize / 2 + 1> sumPhase_;
std::array<float, config::constants::fftFrameSize> frequencyBuffer_;
std::array<float, config::constants::fftFrameSize> magnitudeBuffer_;
};

}
2 changes: 1 addition & 1 deletion seele/seeleCore/mocks/inc/DelayProcessorMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace hidonash
public:
~DelayProcessorMock() = default;

MOCK_METHOD(void, setDelayInSeconds, (int) );
MOCK_METHOD(void, setDelayInSeconds, (float) );

MOCK_METHOD(void, process, (core::IAudioBuffer::IChannel&) );
};
Expand Down
2 changes: 1 addition & 1 deletion seele/seeleCore/src/DelayProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace hidonash
void DelayProcessor::process(core::IAudioBuffer::IChannel& input)
{
const auto bufferSize = input.size();
for (auto sa = 0; sa < bufferSize; ++sa)
for (size_t sa = 0; sa < bufferSize; ++sa)
{
circularBuffer_[writeIndex_] = input[sa];

Expand Down
18 changes: 3 additions & 15 deletions seele/seeleCore/src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,19 @@

namespace hidonash
{
namespace
{
int convertMsToSamples(const int ms, double sampleRate)
{
if (ms >= 0)
return 0;

return std::floor(static_cast<float>(ms / 1000.f * sampleRate));
}
}

Engine::Engine(const IMemberParameterSet& memberParameterSet, double sampleRate, int samplesPerBlock,
size_t numChannels, FactoryPtr factory)
: memberParameterSet_(memberParameterSet)
, accumulationBuffer_(numChannels, samplesPerBlock)
, numChannels_(numChannels)
, sampleRate_(sampleRate)
{
delayProcessors_.resize(numChannels_);
gainProcessors_.resize(numChannels_);
for (auto n = 0; n < config::constants::numMembers; ++n)
{
pitchShifterManagers_.emplace_back(factory->createPitchShifterManager(sampleRate, numChannels_, *factory));
audioBuffers_.emplace_back(factory->createAudioBuffer(numChannels_, samplesPerBlock));
for (auto ch = 0; ch < numChannels_; ++ch)
for (size_t ch = 0; ch < numChannels_; ++ch)
{
delayProcessors_[ch].emplace_back(
factory->createDelayProcessor(config::parameters::maxDistanceInSeconds, 0.0f, sampleRate));
Expand All @@ -47,14 +35,14 @@ namespace hidonash
accumulationBuffer_.fill(0.0f);

int activeMembers = 0;
for (auto n = 0; n < config::constants::numMembers; ++n)
for (size_t n = 0; n < config::constants::numMembers; ++n)
if (memberParameterSet_.getSummonState(n))
{
audioBuffers_[n]->copyFrom(inputBuffer);
pitchShifterManagers_[n]->setPitchRatio(memberParameterSet_.getSanctity(n));
pitchShifterManagers_[n]->process(*audioBuffers_[n]);

for (auto ch = 0; ch < numChannels_; ++ch)
for (size_t ch = 0; ch < numChannels_; ++ch)
{
delayProcessors_[ch][n]->setDelayInSeconds(memberParameterSet_.getDistance(n));
delayProcessors_[ch][n]->process(*audioBuffers_[n]->getChannel(ch));
Expand Down
2 changes: 1 addition & 1 deletion seele/seeleCore/src/GainProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace hidonash

void GainProcessor::process(core::IAudioBuffer::IChannel& input)
{
for (auto sa = 0; sa < input.size(); ++sa)
for (size_t sa = 0; sa < input.size(); ++sa)
{
input[sa] *= gainValue_;
gainValue_++;
Expand Down
Loading

0 comments on commit d148661

Please sign in to comment.