Skip to content

Commit

Permalink
adjusted room dimensions to 10x10x10 meters and updated constants usa…
Browse files Browse the repository at this point in the history
…ge across the codebase
  • Loading branch information
michaelwitte committed Jun 18, 2024
1 parent 4947d5c commit 90e3b29
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
4 changes: 4 additions & 0 deletions source/Constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

constexpr float CUBE_EDGE_LENGTH = 10.0f;
constexpr float HALF_CUBE_EDGE_LENGTH = CUBE_EDGE_LENGTH / 2.0f;
13 changes: 7 additions & 6 deletions source/PluginParameters.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "PluginParameters.h"
#include "Constants.h"

juce::AudioProcessorValueTreeState::ParameterLayout PluginParameters::createParameterLayout() {
std::vector<std::unique_ptr<juce::RangedAudioParameter>> params;
Expand Down Expand Up @@ -188,9 +189,9 @@ void ParameterListener::boundRadius(float radius) {
float dz = cos(colatitudeRad);

// intersection of the line with the cube boundaries
float tX = (!juce::approximatelyEqual(dx,0.0f)) ? (10.0f / dx) : std::numeric_limits<float>::infinity();
float tY = (!juce::approximatelyEqual(dy,0.0f)) ? (10.0f / dy) : std::numeric_limits<float>::infinity();
float tZ = (!juce::approximatelyEqual(dz,0.0f)) ? (10.0f / dz) : std::numeric_limits<float>::infinity();
float tX = (!juce::approximatelyEqual(dx,0.0f)) ? (HALF_CUBE_EDGE_LENGTH / dx) : std::numeric_limits<float>::infinity();
float tY = (!juce::approximatelyEqual(dy,0.0f)) ? (HALF_CUBE_EDGE_LENGTH / dy) : std::numeric_limits<float>::infinity();
float tZ = (!juce::approximatelyEqual(dz,0.0f)) ? (HALF_CUBE_EDGE_LENGTH / dz) : std::numeric_limits<float>::infinity();

// the intersection point is the closest one to the origin
float tMin = std::min({std::abs(tX), std::abs(tY), std::abs(tZ)});
Expand Down Expand Up @@ -272,9 +273,9 @@ void ParameterListener::updateCartesianCoordinates()
float z = radius * cos(colatitudeRad);

// always limit the values to the room boundaries
x = jlimit(-10.0f, 10.0f, x);
y = jlimit(-10.0f, 10.0f, y);
z = jlimit(-10.0f, 10.0f, z);
x = jlimit(-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, x);
y = jlimit(-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, y);
z = jlimit(-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, z);

float normalizedX = PluginParameters::xRange.convertTo0to1(x);
float normalizedY = PluginParameters::yRange.convertTo0to1(y);
Expand Down
15 changes: 8 additions & 7 deletions source/PluginParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define BINAURALPANNER_PLUGINPARAMETERS_H

#include <JuceHeader.h>
#include "Constants.h"

class PluginParameters {
public:
Expand Down Expand Up @@ -82,22 +83,22 @@ class PluginParameters {

inline static juce::NormalisableRange<float> azimRange {-180.0f, 180.0f, 0.01f},
elevRange {-90.0f, 90.0f, 0.01f},
distRange {0.0f, 17.4f, 0.1f},
xRange {-10.f, 10.f, 0.1f},
yRange {-10.f, 10.f, 0.1f},
zRange {-10.f, 10.f, 0.1f},
distRange {0.0f, static_cast<float>(sqrt(pow(HALF_CUBE_EDGE_LENGTH, 2) * 3)), 0.01f},
xRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f},
yRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f},
zRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f},
xLFORateRange {0.0f, 1.5f, 0.1f},
xLFODepthRange {0.0f, 100.f, 0.1f},
xLFOPhaseRange {-180.f, 180.f, 1.f},
xLFOOffsetRange {-10.f, 10.f, 0.1f},
xLFOOffsetRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f},
yLFORateRange {0.0f, 1.5f, 0.1f},
yLFODepthRange {0.0f, 100.f, 0.1f},
yLFOPhaseRange {-180.f, 180.f, 1.f},
yLFOOffsetRange {-10.f, 10.f, 0.1f},
yLFOOffsetRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f},
zLFORateRange {0.0f, 1.5f, 0.1f},
zLFODepthRange {0.0f, 100.f, 0.1f},
zLFOPhaseRange {-180.f, 180.f, 1.f},
zLFOOffsetRange {-10.f, 10.f, 0.1f};
zLFOOffsetRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f};


private:
Expand Down
31 changes: 16 additions & 15 deletions source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PluginProcessor.h"
#include "PluginEditor.h"
#include "Constants.h"

//==============================================================================
AudioPluginAudioProcessor::AudioPluginAudioProcessor()
Expand Down Expand Up @@ -374,13 +375,13 @@ void AudioPluginAudioProcessor::processLFOs()
{
float frequency = *parameters.getRawParameterValue("param_xlfo_rate");
float phase = *parameters.getRawParameterValue("param_xlfo_phase");
float amplitude = *parameters.getRawParameterValue("param_xlfo_depth") / 10.0f;
float amplitude = (*parameters.getRawParameterValue("param_xlfo_depth") / 100) * HALF_CUBE_EDGE_LENGTH;
float offset = *parameters.getRawParameterValue("param_xlfo_offset");

xLFO->setFrequency(frequency);
float xlfoSample = amplitude * std::sin(xLFO->processSample(degreesToRadians(phase))) + offset;

xlfoSample = juce::jlimit(-10.0f, 10.0f, xlfoSample);
xlfoSample = juce::jlimit(PluginParameters::xRange.start, PluginParameters::xRange.end, xlfoSample);
float normalizedX = PluginParameters::xRange.convertTo0to1(xlfoSample);
parameters.getParameter("param_x")->setValueNotifyingHost(normalizedX);
}
Expand All @@ -389,13 +390,13 @@ void AudioPluginAudioProcessor::processLFOs()
{
float frequency = *parameters.getRawParameterValue("param_ylfo_rate");
float phase = *parameters.getRawParameterValue("param_ylfo_phase");
float amplitude = *parameters.getRawParameterValue("param_ylfo_depth") / 10.0f;
float amplitude = (*parameters.getRawParameterValue("param_ylfo_depth") / 100) * HALF_CUBE_EDGE_LENGTH;
float offset = *parameters.getRawParameterValue("param_ylfo_offset");

yLFO->setFrequency(frequency);
float ylfoSample = amplitude * std::sin(yLFO->processSample(degreesToRadians(phase))) + offset;

ylfoSample = juce::jlimit(-10.0f, 10.0f, ylfoSample);
ylfoSample = juce::jlimit(PluginParameters::yRange.start, PluginParameters::yRange.end, ylfoSample);
float normalizedY = PluginParameters::yRange.convertTo0to1(ylfoSample);
parameters.getParameter("param_y")->setValueNotifyingHost(normalizedY);
}
Expand All @@ -404,13 +405,13 @@ void AudioPluginAudioProcessor::processLFOs()
{
float frequency = *parameters.getRawParameterValue("param_zlfo_rate");
float phase = *parameters.getRawParameterValue("param_zlfo_phase");
float amplitude = *parameters.getRawParameterValue("param_zlfo_depth") / 10.0f;
float amplitude = (*parameters.getRawParameterValue("param_zlfo_depth") / 100) * HALF_CUBE_EDGE_LENGTH;
float offset = *parameters.getRawParameterValue("param_zlfo_offset");

zLFO->setFrequency(frequency);
float zlfoSample = amplitude * std::sin(zLFO->processSample(degreesToRadians(phase))) + offset;

zlfoSample = juce::jlimit(-10.0f, 10.0f, zlfoSample);
zlfoSample = juce::jlimit(PluginParameters::zRange.start, PluginParameters::zRange.end, zlfoSample);
float normalizedZ = PluginParameters::zRange.convertTo0to1(zlfoSample);
parameters.getParameter("param_z")->setValueNotifyingHost(normalizedZ);
}
Expand Down Expand Up @@ -559,7 +560,7 @@ void AudioPluginAudioProcessor::applyPreset(int presetOption)
parameters.getParameterAsValue(PluginParameters::XLFO_RATE_ID.getParamID()) = 0.1f;
parameters.getParameterAsValue(PluginParameters::XLFO_DEPTH_ID.getParamID()) = 27.3f;
parameters.getParameterAsValue(PluginParameters::XLFO_PHASE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = 6.5f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = 6.5f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::YLFO_RATE_ID.getParamID()) = 0.9f;
parameters.getParameterAsValue(PluginParameters::YLFO_DEPTH_ID.getParamID()) = 44.2f;
parameters.getParameterAsValue(PluginParameters::YLFO_PHASE_ID.getParamID()) = 0.0f;
Expand All @@ -574,11 +575,11 @@ void AudioPluginAudioProcessor::applyPreset(int presetOption)
parameters.getParameterAsValue(PluginParameters::XLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::XLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_PHASE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = 5.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = 5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::YLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::YLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_PHASE_ID.getParamID()) = 90.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = 5.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = 5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::ZLFO_RATE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_DEPTH_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_PHASE_ID.getParamID()) = 0.0f;
Expand All @@ -589,11 +590,11 @@ void AudioPluginAudioProcessor::applyPreset(int presetOption)
parameters.getParameterAsValue(PluginParameters::XLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::XLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_PHASE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = 5.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = 5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::YLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::YLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_PHASE_ID.getParamID()) = 90.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = -5.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = -5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::ZLFO_RATE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_DEPTH_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_PHASE_ID.getParamID()) = 0.0f;
Expand All @@ -604,11 +605,11 @@ void AudioPluginAudioProcessor::applyPreset(int presetOption)
parameters.getParameterAsValue(PluginParameters::XLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::XLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_PHASE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = -5.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = -5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::YLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::YLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_PHASE_ID.getParamID()) = 90.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = 5.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = 5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::ZLFO_RATE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_DEPTH_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_PHASE_ID.getParamID()) = 0.0f;
Expand All @@ -619,11 +620,11 @@ void AudioPluginAudioProcessor::applyPreset(int presetOption)
parameters.getParameterAsValue(PluginParameters::XLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::XLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_PHASE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = -5.0f;
parameters.getParameterAsValue(PluginParameters::XLFO_OFFSET_ID.getParamID()) = -5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::YLFO_RATE_ID.getParamID()) = 0.5f;
parameters.getParameterAsValue(PluginParameters::YLFO_DEPTH_ID.getParamID()) = 35.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_PHASE_ID.getParamID()) = 90.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = -5.0f;
parameters.getParameterAsValue(PluginParameters::YLFO_OFFSET_ID.getParamID()) = -5.0f * (HALF_CUBE_EDGE_LENGTH / 10.0f);
parameters.getParameterAsValue(PluginParameters::ZLFO_RATE_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_DEPTH_ID.getParamID()) = 0.0f;
parameters.getParameterAsValue(PluginParameters::ZLFO_PHASE_ID.getParamID()) = 0.0f;
Expand Down
11 changes: 6 additions & 5 deletions source/ui/PannerVisualisation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "PannerVisualisation.h"
#include "../Constants.h"

PannerVisualisation::PannerVisualisation() : isInitialized(false) {
smallCircleRadius = 10.0f;
Expand Down Expand Up @@ -86,8 +87,8 @@ void PannerVisualisation::mouseDrag(const juce::MouseEvent &event) {
}

smallCirclePosition = newPos;
float newX = - (newPos.y - center.y) / radius * 10.0f;
float newY = - (newPos.x - center.x) / radius * 10.0f;
float newX = - (newPos.y - center.y) / radius * HALF_CUBE_EDGE_LENGTH;
float newY = - (newPos.x - center.x) / radius * HALF_CUBE_EDGE_LENGTH;

listeners.call([newX, newY](Listener& l) { l.pannerChanged(newX, newY); });

Expand Down Expand Up @@ -116,11 +117,11 @@ void PannerVisualisation::setVisualPosition(float x, float y, float z) {
auto center = bounds.getCentre().toFloat();
float outerRadius = static_cast<float>(bounds.getWidth() / 2.0);

float zScale = ((z + 10) / 20.0f) * 1.5f + 0.5f;
float zScale = ((z + HALF_CUBE_EDGE_LENGTH) / CUBE_EDGE_LENGTH) * 1.5f + 0.5f;
smallCircleRadius = 10.0f * zScale;

float newX = center.x - (y / 10.0f) * outerRadius;
float newY = center.y - (x / 10.0f) * outerRadius;
float newX = center.x - (y / HALF_CUBE_EDGE_LENGTH) * outerRadius;
float newY = center.y - (x / HALF_CUBE_EDGE_LENGTH) * outerRadius;

smallCirclePosition.setXY(newX, newY);

Expand Down

0 comments on commit 90e3b29

Please sign in to comment.