Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ADM Coordinate conversion library over internal impl #295

Merged
merged 6 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@
[submodule "submodules/bear"]
path = submodules/bear
url = https://github.com/ebu/bear.git
[submodule "submodules/adm_coordinate_conversion"]
path = submodules/adm_coordinate_conversion
url = https://github.com/ebu/adm_coordinate_conversion.git
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Note: This release bumps the minimum required REAPER version from v6.11 to v6.37
* Fix occasional crash bug in start up of Binaural Monitoring plugin [#277](https://github.com/ebu/ear-production-suite/issues/277) [#278](https://github.com/ebu/ear-production-suite/pull/278)
* Fix fail to render when non-VST plugins are in FX chains [#279](https://github.com/ebu/ear-production-suite/issues/279) [#280](https://github.com/ebu/ear-production-suite/pull/280)
* Update BEAR [#287](https://github.com/ebu/ear-production-suite/pull/287)
* Use ADM Coordinate Conversion lib over internal implementation [#293](https://github.com/ebu/ear-production-suite/issues/293) [#295](https://github.com/ebu/ear-production-suite/pull/295)

Version 1.1.0b

Expand Down
4 changes: 2 additions & 2 deletions reaper-adm-extension/src/reaper_adm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ set(EXTENSION_SOURCES
reaperhost.cpp
track.cpp
update_check.cpp
coordinate_conversion/coord_conv.cpp
progress/importdialog.cpp
progress/importlistener.cpp
progress/importprogress.cpp
Expand Down Expand Up @@ -155,7 +154,6 @@ set(EXTENSION_HEADERS
track.h
update_check.h
win_mem_debug.h
coordinate_conversion/coord_conv.hpp
progress/importdialog.h
progress/importlistener.h
progress/importprogress.h
Expand Down Expand Up @@ -201,6 +199,7 @@ target_include_directories(reaper_adm_object
$<TARGET_PROPERTY:WDL::swell,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:IRT::bw64,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:adm,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:AdmCoordConv,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:nng::nng,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Juce::core,INTERFACE_INCLUDE_DIRECTORIES>
${EPS_SHARED_DIR}
Expand All @@ -211,6 +210,7 @@ target_link_libraries(reaper_adm_dependencies
$<TARGET_OBJECTS:reaper_adm_object>
IRT::bw64
adm
AdmCoordConv
WDL::swell
Boost::filesystem
nng::nng
Expand Down
56 changes: 45 additions & 11 deletions reaper-adm-extension/src/reaper_adm/admextraction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "coordinate_conversion/coord_conv.hpp"
#include <adm_coord_conv/adm_coord_conv.hpp>
#include "admextraction.h"

using namespace admplug::detail;
Expand All @@ -22,16 +22,38 @@ bool RoomCartesianToSpherical::hasExtent() {
block.has<adm::Depth>();
}


void RoomCartesianToSpherical::calculate() {
if(!position && block.has<adm::CartesianPosition>()) {
auto inputPosition = block.get<adm::CartesianPosition>();
if(hasExtent()) {
auto inputExtent = std::make_tuple(getValueOrDefault<adm::Width>(),
getValueOrDefault<adm::Height>(),
getValueOrDefault<adm::Depth>());
std::tie(position, extent) = adm::cartToPolar(std::make_tuple(inputPosition, inputExtent));
} else {
position = adm::pointCartToPolar(inputPosition);

auto admInputPosition = block.get<adm::CartesianPosition>();
adm::coords::CartesianSource inputSource{ {
admInputPosition.get<adm::X>().get(),
admInputPosition.get<adm::Y>().get(),
admInputPosition.get<adm::Z>().get()
} };

if (hasExtent()) {
inputSource.extent = adm::coords::CartesianExtent{
getValueOrDefault<adm::Width>().get(),
getValueOrDefault<adm::Height>().get(),
getValueOrDefault<adm::Depth>().get()
};
}

auto convSource = adm::coords::convert(inputSource);
position = adm::SphericalPosition(
adm::Azimuth(convSource.position.azimuth),
adm::Elevation(convSource.position.elevation),
adm::Distance(convSource.position.distance)
);

if (convSource.extent.has_value()) {
extent = std::make_tuple(
adm::Width(convSource.extent->width),
adm::Height(convSource.extent->height),
adm::Depth(convSource.extent->depth)
);
}
}
}
Expand Down Expand Up @@ -59,8 +81,20 @@ RoomCartesianToSphericalSpeaker::RoomCartesianToSphericalSpeaker(

void RoomCartesianToSphericalSpeaker::calculate() {
if(!position) {
auto inputPosition = block.get<adm::CartesianSpeakerPosition>();
position = adm::pointCartToPolar(inputPosition);

auto admInputPosition = block.get<adm::CartesianSpeakerPosition>();
adm::coords::CartesianPosition inputPosition{
getParamValueOrZero<adm::X>(admInputPosition),
getParamValueOrZero<adm::Y>(admInputPosition),
getParamValueOrZero<adm::Z>(admInputPosition)
};

auto convPosition = adm::coords::convert(inputPosition);
position = adm::SphericalSpeakerPosition(
adm::Azimuth(convPosition.azimuth),
adm::Elevation(convPosition.elevation),
adm::Distance(convPosition.distance)
);
}
}

Expand Down
8 changes: 8 additions & 0 deletions reaper-adm-extension/src/reaper_adm/admextraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ auto getAdmComponent(adm::AudioBlockFormatDirectSpeakers const& block) {
return getOptionalAdmComponent<adm::AudioBlockFormatDirectSpeakers, ParameterChain...>(block);
}

template<typename Param, typename T>
float getParamValueOrZero(T const& element) {
if (element.template has<Param>()) {
return element.template get<Param>().get();
}
return 0;
}

using ns = std::chrono::nanoseconds;

template<typename TimedParameterT, typename BlockT>
Expand Down
Loading
Loading