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

Just fix various warnings, without messing with CI #62

Merged
merged 11 commits into from
Jan 26, 2024
2 changes: 1 addition & 1 deletion examples/objects_gains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using namespace ear;

int main(int argc, char **argv) {
int main(int, char **) {
// make the gain calculator
Layout layout = getLayout("0+5+0");
GainCalculatorObjects gc(layout);
Expand Down
60 changes: 60 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "nixpkgs/nixos-23.11";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};

devtools = [
pkgs.clang-tools
pkgs.cmake-format
pkgs.nixpkgs-fmt
];
in
rec {
packages.xsimd = pkgs.xsimd.overrideAttrs rec {
version = "12.1.1";
src = pkgs.fetchFromGitHub {
owner = "xtensor-stack";
repo = "xsimd";
rev = "12.1.1";
sha256 = "sha256-ofUFieeRtpnzNv3Ad5oYwKWb2XcqQHoj601TIhydJyI=";
};
};
packages.libear = pkgs.callPackage ./nix/libear.nix { src = ./.; xsimd = packages.xsimd; };
packages.default = packages.libear;

packages.libear_clang = packages.libear.override { stdenv = pkgs.clangStdenv; };

devShells.libear = packages.libear.overrideAttrs (attrs: {
nativeBuildInputs = attrs.nativeBuildInputs ++ devtools;
});
devShells.default = devShells.libear;
}
);
}

23 changes: 23 additions & 0 deletions nix/libear.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ lib, buildPackages, stdenv, cmake, src, ninja, boost, eigen, xsimd }:
let
isCross = stdenv.buildPlatform != stdenv.hostPlatform;
in
(stdenv.mkDerivation {
name = "libear";
inherit src;
nativeBuildInputs = [
cmake
ninja
];
buildInputs = [ boost eigen xsimd ];
cmakeFlags = [
"-DEAR_USE_INTERNAL_EIGEN=OFF"
"-DEAR_USE_INTERNAL_XSIMD=OFF"
"-DEAR_UNIT_TESTS=ON"
]
++ lib.optionals isCross [
"-DCMAKE_CROSSCOMPILING_EMULATOR=${stdenv.hostPlatform.emulator buildPackages}"
];

doCheck = true;
})
9 changes: 0 additions & 9 deletions src/common/channel_lock.hpp

This file was deleted.

5 changes: 3 additions & 2 deletions src/common/point_source_panner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ namespace ear {
return ret + 1;
}

PointSourcePanner::~PointSourcePanner() {}

PointSourcePannerDownmix::PointSourcePannerDownmix(
std::shared_ptr<PointSourcePanner> psp, Eigen::MatrixXd downmix)
: _psp(psp), _downmix(downmix){};
Expand Down Expand Up @@ -388,8 +390,7 @@ namespace ear {
return boost::none;
}

boost::optional<Eigen::VectorXd> AllocentricPanner::handle(
Eigen::Vector3d position) {
boost::optional<Eigen::VectorXd> AllocentricPanner::handle(Eigen::Vector3d) {
return boost::none;
}

Expand Down
2 changes: 2 additions & 0 deletions src/common/point_source_panner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ namespace ear {
virtual boost::optional<Eigen::VectorXd> handle(
Eigen::Vector3d position) = 0;
virtual int numberOfOutputChannels() const = 0;

virtual ~PointSourcePanner();
};

/** @brief Wrapper around multiple regions.
Expand Down
14 changes: 0 additions & 14 deletions src/common/screen_scale.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions src/conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ namespace ear {
// wrappers for OTM

struct guess_cartesian_flag : public boost::static_visitor<bool> {
bool operator()(const PolarPosition &pos) const { return false; }
bool operator()(const PolarPosition &) const { return false; }

bool operator()(const CartesianPosition &pos) const { return true; }
bool operator()(const CartesianPosition &) const { return true; }
};

void toPolar(ObjectsTypeMetadata &otm) {
Expand Down
6 changes: 1 addition & 5 deletions src/object_based/gain_calculator_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@ namespace ear {
GainCalculatorObjectsImpl::GainCalculatorObjectsImpl(const Layout& layout)
: _layout(layout),
_pointSourcePanner(configurePolarPanner(_layout.withoutLfe())),
_screenEdgeLockHandler(ScreenEdgeLockHandler(_layout.screen())),
_screenScaleHandler(ScreenScaleHandler(_layout.screen())),
_channelLockHandler(ChannelLockHandler(_layout.withoutLfe())),
_polarExtentPanner(_pointSourcePanner),
_zoneExclusionHandler(ZoneExclusionHandler(_layout.withoutLfe())),
_isLfe(copy_vector<decltype(_isLfe)>(layout.isLfe())),
_pvTmp(_pointSourcePanner->numberOfOutputChannels()){};

void GainCalculatorObjectsImpl::calculate(const ObjectsTypeMetadata& metadata,
OutputGains& direct,
OutputGains& diffuse,
const WarningCB& warning_cb) {
const WarningCB&) {
if (metadata.cartesian) throw not_implemented("cartesian");
boost::apply_visitor(throw_if_not_implemented(), metadata.position);
boost::apply_visitor(throw_if_not_implemented(), metadata.objectDivergence);
Expand Down
8 changes: 0 additions & 8 deletions src/object_based/gain_calculator_objects.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#pragma once
#include <memory>
#include "../common/channel_lock.hpp"
#include "../common/point_source_panner.hpp"
#include "../common/screen_edge_lock.hpp"
#include "../common/screen_scale.hpp"
#include "ear/common_types.hpp"
#include "ear/helpers/output_gains.hpp"
#include "ear/layout.hpp"
#include "ear/metadata.hpp"
#include "ear/warnings.hpp"
#include "polar_extent.hpp"
#include "zone_exclusion.hpp"

namespace ear {

Expand All @@ -33,11 +29,7 @@ namespace ear {
private:
Layout _layout;
std::shared_ptr<PointSourcePanner> _pointSourcePanner;
ScreenEdgeLockHandler _screenEdgeLockHandler;
ScreenScaleHandler _screenScaleHandler;
ChannelLockHandler _channelLockHandler;
PolarExtent _polarExtentPanner;
ZoneExclusionHandler _zoneExclusionHandler;
Eigen::Array<bool, Eigen::Dynamic, 1> _isLfe;
Eigen::VectorXd _pvTmp;
};
Expand Down
9 changes: 0 additions & 9 deletions src/object_based/zone_exclusion.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion submodules/xsimd
Submodule xsimd updated 202 files
1 change: 0 additions & 1 deletion tests/conversion_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ static void check_extent_equal(const ExtentParams &p1, const ExtentParams &p2) {
}

TEST_CASE("conversion_cartesian_polar_loop") {
double eps = 1e-6;
for (double az : {0.0, -10.0, 10.0, 90.0, -90.0, 150.0, -150.0})
for (double el : {0.0, -10.0, 10.0, -45.0, 45.0, -90.0, 90.0})
for (double dist : {0.5, 1.0}) {
Expand Down
6 changes: 3 additions & 3 deletions tests/gain_calculator_direct_speakers_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ TEST_CASE("test_speaker_label") {
Layout layout = getLayout("4+5+0");
GainCalculatorDirectSpeakers p(layout);

// DirectSpeakersTypeMetadata metadata;
Gains actual(layout.channels().size());
for (const std::string& prefix :
{"", "urn:itu:bs:2051:0:speaker:", "urn:itu:bs:2051:1:speaker:"}) {
std::vector<std::string> prefixes = {
"", "urn:itu:bs:2051:0:speaker:", "urn:itu:bs:2051:1:speaker:"};
for (const std::string& prefix : prefixes) {
// normal case
p.calculate(tmWithLabels(std::vector<std::string>{prefix + "M+000"}),
actual);
Expand Down
44 changes: 29 additions & 15 deletions tests/point_source_panner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,36 @@ TEST_CASE("extra_pos_vertical_nominal") {
REQUIRE(downmix == expectedDownmix);
};

SECTION("4+5+0/4+5+1") {
for (const std::string& layoutName : {"4+5+0", "4+5+1"}) {
Layout layout = getLayout("4+5+0").withoutLfe();
std::tie(extraChannels, downmix) = extraPosVerticalNominal(layout);
std::vector<PolarPosition> expectedPositions = {
PolarPosition(30.0, -30.0, 1.0), PolarPosition(-30.0, -30.0, 1.0),
PolarPosition(0.0, -30.0, 1.0), PolarPosition(110.0, -30.0, 1.0),
PolarPosition(-110.0, -30.0, 1.0)};
REQUIRE(extraChannels.size() == expectedPositions.size());
for (size_t i = 0; i < extraChannels.size(); ++i) {
REQUIRE(extraChannels[i].polarPosition() == expectedPositions[i]);
}
Eigen::MatrixXd expectedDownmix = createDownmixMatrixFromIndices(
std::vector<int>{0, 1, 2, 3, 4}, layout.channels().size());
REQUIRE(downmix == expectedDownmix);
SECTION("4+5+0") {
Layout layout = getLayout("4+5+0").withoutLfe();
std::tie(extraChannels, downmix) = extraPosVerticalNominal(layout);
std::vector<PolarPosition> expectedPositions = {
PolarPosition(30.0, -30.0, 1.0), PolarPosition(-30.0, -30.0, 1.0),
PolarPosition(0.0, -30.0, 1.0), PolarPosition(110.0, -30.0, 1.0),
PolarPosition(-110.0, -30.0, 1.0)};
REQUIRE(extraChannels.size() == expectedPositions.size());
for (size_t i = 0; i < extraChannels.size(); ++i) {
REQUIRE(extraChannels[i].polarPosition() == expectedPositions[i]);
}
Eigen::MatrixXd expectedDownmix = createDownmixMatrixFromIndices(
std::vector<int>{0, 1, 2, 3, 4}, layout.channels().size());
REQUIRE(downmix == expectedDownmix);
};

SECTION("4+5+1") {
Layout layout = getLayout("4+5+1").withoutLfe();
std::tie(extraChannels, downmix) = extraPosVerticalNominal(layout);
std::vector<PolarPosition> expectedPositions = {
PolarPosition(110.0, -30.0, 1.0),
PolarPosition(-110.0, -30.0, 1.0),
};
REQUIRE(extraChannels.size() == expectedPositions.size());
for (size_t i = 0; i < extraChannels.size(); ++i) {
REQUIRE(extraChannels[i].polarPosition() == expectedPositions[i]);
}
Eigen::MatrixXd expectedDownmix = createDownmixMatrixFromIndices(
std::vector<int>{3, 4}, layout.channels().size());
REQUIRE(downmix == expectedDownmix);
};

SECTION("3+7+0") {
Expand Down
Loading