mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 12:14:41 +02:00
update OpenAL-Soft to 1.24.3.
This commit is contained in:
@@ -1,52 +1,46 @@
|
||||
#ifndef MAKEMHR_H
|
||||
#define MAKEMHR_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
|
||||
#include "alcomplex.h"
|
||||
#include "alspan.h"
|
||||
#include "polyphase_resampler.h"
|
||||
|
||||
|
||||
// The maximum path length used when processing filenames.
|
||||
enum { MAX_PATH_LEN = 256u };
|
||||
inline constexpr auto MAX_PATH_LEN = 256u;
|
||||
|
||||
// The limit to the number of 'distances' listed in the data set definition.
|
||||
// Must be less than 256
|
||||
enum { MAX_FD_COUNT = 16u };
|
||||
inline constexpr auto MAX_FD_COUNT = 16u;
|
||||
|
||||
// The limits to the number of 'elevations' listed in the data set definition.
|
||||
// Must be less than 256.
|
||||
enum {
|
||||
MIN_EV_COUNT = 5u,
|
||||
MAX_EV_COUNT = 181u
|
||||
};
|
||||
inline constexpr auto MIN_EV_COUNT = 5u;
|
||||
inline constexpr auto MAX_EV_COUNT = 181u;
|
||||
|
||||
// The limits for each of the 'azimuths' listed in the data set definition.
|
||||
// Must be less than 256.
|
||||
enum {
|
||||
MIN_AZ_COUNT = 1u,
|
||||
MAX_AZ_COUNT = 255u
|
||||
};
|
||||
inline constexpr auto MIN_AZ_COUNT = 1u;
|
||||
inline constexpr auto MAX_AZ_COUNT = 255u;
|
||||
|
||||
// The limits for the 'distance' from source to listener for each field in
|
||||
// the definition file.
|
||||
inline constexpr double MIN_DISTANCE{0.05};
|
||||
inline constexpr double MAX_DISTANCE{2.50};
|
||||
inline constexpr auto MIN_DISTANCE = 0.05;
|
||||
inline constexpr auto MAX_DISTANCE = 2.50;
|
||||
|
||||
// The limits for the sample 'rate' metric in the data set definition and for
|
||||
// resampling.
|
||||
enum {
|
||||
MIN_RATE = 32000u,
|
||||
MAX_RATE = 96000u
|
||||
};
|
||||
inline constexpr auto MIN_RATE = 32000u;
|
||||
inline constexpr auto MAX_RATE = 96000u;
|
||||
|
||||
// The limits for the HRIR 'points' metric in the data set definition.
|
||||
enum {
|
||||
MIN_POINTS = 16u,
|
||||
MAX_POINTS = 8192u
|
||||
};
|
||||
inline constexpr auto MIN_POINTS = 16u;
|
||||
inline constexpr auto MAX_POINTS = 8192u;
|
||||
|
||||
|
||||
using uint = unsigned int;
|
||||
@@ -78,7 +72,7 @@ struct HrirAzT {
|
||||
double mAzimuth{0.0};
|
||||
uint mIndex{0u};
|
||||
std::array<double,2> mDelays{};
|
||||
std::array<double*,2> mIrs{};
|
||||
std::array<al::span<double>,2> mIrs{};
|
||||
};
|
||||
|
||||
struct HrirEvT {
|
||||
@@ -118,19 +112,31 @@ struct HrirDataT {
|
||||
bool PrepareHrirData(const al::span<const double> distances,
|
||||
const al::span<const uint,MAX_FD_COUNT> evCounts,
|
||||
const al::span<const std::array<uint,MAX_EV_COUNT>,MAX_FD_COUNT> azCounts, HrirDataT *hData);
|
||||
void MagnitudeResponse(const uint n, const complex_d *in, double *out);
|
||||
|
||||
/* Calculate the magnitude response of the given input. This is used in
|
||||
* place of phase decomposition, since the phase residuals are discarded for
|
||||
* minimum phase reconstruction. The mirrored half of the response is also
|
||||
* discarded.
|
||||
*/
|
||||
inline void MagnitudeResponse(const al::span<const complex_d> in, const al::span<double> out)
|
||||
{
|
||||
static constexpr double Epsilon{1e-9};
|
||||
for(size_t i{0};i < out.size();++i)
|
||||
out[i] = std::max(std::abs(in[i]), Epsilon);
|
||||
}
|
||||
|
||||
// Performs a forward FFT.
|
||||
inline void FftForward(const uint n, complex_d *inout)
|
||||
{ forward_fft(al::span{inout, n}); }
|
||||
|
||||
// Performs an inverse FFT.
|
||||
// Performs an inverse FFT, scaling the result by the number of elements.
|
||||
inline void FftInverse(const uint n, complex_d *inout)
|
||||
{
|
||||
inverse_fft(al::span{inout, n});
|
||||
double f{1.0 / n};
|
||||
for(uint i{0};i < n;i++)
|
||||
inout[i] *= f;
|
||||
const auto values = al::span{inout, n};
|
||||
inverse_fft(values);
|
||||
|
||||
const double f{1.0 / n};
|
||||
std::for_each(values.begin(), values.end(), [f](complex_d &value) { value *= f; });
|
||||
}
|
||||
|
||||
// Performs linear interpolation.
|
||||
|
||||
Reference in New Issue
Block a user