7 #include "polyphase_resampler.h"
10 // The maximum path length used when processing filenames.
11 #define MAX_PATH_LEN (256)
13 // The limit to the number of 'distances' listed in the data set definition.
14 // Must be less than 256
15 #define MAX_FD_COUNT (16)
17 // The limits to the number of 'elevations' listed in the data set definition.
18 // Must be less than 256.
19 #define MIN_EV_COUNT (5)
20 #define MAX_EV_COUNT (181)
22 // The limits for each of the 'azimuths' listed in the data set definition.
23 // Must be less than 256.
24 #define MIN_AZ_COUNT (1)
25 #define MAX_AZ_COUNT (255)
27 // The limits for the 'distance' from source to listener for each field in
28 // the definition file.
29 #define MIN_DISTANCE (0.05)
30 #define MAX_DISTANCE (2.50)
32 // The limits for the sample 'rate' metric in the data set definition and for
34 #define MIN_RATE (32000)
35 #define MAX_RATE (96000)
37 // The limits for the HRIR 'points' metric in the data set definition.
38 #define MIN_POINTS (16)
39 #define MAX_POINTS (8192)
42 using uint
= unsigned int;
44 /* Complex double type. */
45 using complex_d
= std::complex<double>;
48 enum ChannelModeT
: bool {
49 CM_AllowStereo
= false,
53 // Sample and channel type enum values.
59 // Certain iterations rely on these integer enum values.
66 // Structured HRIR storage for stereo azimuth pairs, elevations, and fields.
70 double mDelays
[2]{0.0, 0.0};
71 double *mIrs
[2]{nullptr, nullptr};
75 double mElevation
{0.0};
78 HrirAzT
*mAzs
{nullptr};
82 double mDistance
{0.0};
86 HrirEvT
*mEvs
{nullptr};
89 // The HRIR metrics and data set used when loading, processing, and storing
90 // the resulting HRTF.
93 SampleTypeT mSampleType
{ST_S24
};
94 ChannelTypeT mChannelType
{CT_NONE
};
102 std::vector
<double> mHrirsBase
;
103 std::vector
<HrirEvT
> mEvsBase
;
104 std::vector
<HrirAzT
> mAzsBase
;
106 std::vector
<HrirFdT
> mFds
;
110 int PrepareHrirData(const uint fdCount
, const double (&distances
)[MAX_FD_COUNT
], const uint (&evCounts
)[MAX_FD_COUNT
], const uint azCounts
[MAX_FD_COUNT
* MAX_EV_COUNT
], HrirDataT
*hData
);
111 void MagnitudeResponse(const uint n
, const complex_d
*in
, double *out
);
112 void FftForward(const uint n
, complex_d
*inout
);
113 void FftInverse(const uint n
, complex_d
*inout
);
116 // Performs linear interpolation.
117 inline double Lerp(const double a
, const double b
, const double f
)
118 { return a
+ f
* (b
- a
); }
120 #endif /* MAKEMHR_H */