14 #define roundf(x) (x<0?ceil((x)-0.5f):floor((x)+0.5f)); 31 if (showpos) ss << (f < 0.0f ?
"-" :
"+");
32 ss << std::fixed << std::setprecision(precision);
33 if (leadingzeros > 0) ss << std::setw(leadingzeros+precision+1) << std::setfill(
'0');
34 if (showpos) ss << fabs(f);
36 std::string s = ss.str();
40 while ((n>0) && (s[n-1] ==
'0')) n--;
43 if ((n>1) && (s[n-1] ==
'.')) n--;
45 return s.substr(0, n);
53 if (showpos) ss << (d < 0.0f ?
"-" :
"+");
54 ss << std::fixed << std::setprecision(precision);
55 if (leadingzeros > 0) ss << std::setw(leadingzeros+precision+1) << std::setfill(
'0');
56 if (showpos) ss << fabs(d);
58 std::string s = ss.str();
62 while ((n>0) && (s[n-1] ==
'0')) n--;
65 if ((n>1) && (s[n-1] ==
'.')) n--;
67 return s.substr(0, n);
77 <<
"( A" <<
Double2StrNice(dAngle1, precision,
false, leadingzeros)
78 <<
"\xF8, B" <<
Double2StrNice(dAngle2, precision,
false, leadingzeros) <<
"\xF8 )";
83 ss << std::fixed << std::showpos
85 <<
"\xF8, T" <<
Double2StrNice(dAngle2, precision,
true, leadingzeros) <<
"\xF8 )";
100 std::stringstream ss;
106 <<
"\xF8 B" <<
Double2StrNice(dAngle2, precision,
false, leadingzeros) <<
"\xF8";
111 ss << std::fixed << std::showpos
113 <<
"\xF8 T" <<
Double2StrNice(dAngle2, precision,
true, leadingzeros) <<
"\xF8";
131 return "Modal error";
133 return "File corrupted";
135 return "File format version not supported";
137 return "File not found";
139 return "Metadata type unkown (valid: bool, int, double, string)";
141 return "Invalid index";
143 return "Invalid main header parameter (num channels, etc. )";
145 return "Invalid file (wrong signature, etc.)";
147 return "File has unkown content type (IR, MS, DFT, etc)";
149 return "Invalid alpha angles or range problem";
151 return "Invalid beta angles or range problem";
153 return "Data uses unrecognized or wrong quantization";
155 return "Content parameter invalid (sampling rate, num supporting frequencies, etc)";
159 std::stringstream ss;
160 ss <<
"Undefined error code '" << iErrorcode <<
"' encountered";
168 switch( iContentType )
175 default:
return "Invalid";
181 switch (iContentType)
188 default:
return "Invalid";
201 default:
return "Invalid";
207 switch (iQuantizationType) {
209 case DAFF_INT16:
return "16-bit signed integer";
210 case DAFF_INT24:
return "24-bit signed integer";
213 default:
return "Invalid";
219 const float EPSILON = 0.00001F;
230 float fAlpha = fAngle1In;
231 float fBeta = fmodf(fAngle2In, 360.0f);
233 if (fBeta > 180.0f) {
238 fAlpha = fmodf(fAlpha, 360.0f);
243 if ((std::abs( fBeta ) <= EPSILON) ||
244 (std::abs( fBeta-180.0f ) <= EPSILON))
247 fAngle1Out = roundf(fAlpha*1000.0f);
248 fAngle1Out /= 1000.0f;
249 fAngle2Out = roundf(fBeta*1000.0f);
250 fAngle2Out /= 1000.0f;
263 float fAzimuth = fAngle1In;
264 float fElevation = fmodf(fAngle2In, 360.0F);
266 if ((fElevation > 90.0F) && (fElevation < 270.0F)) {
268 fElevation = 180.0F - fElevation;
272 fAzimuth = fmodf(fAzimuth + 180.0F, 360.0F) - 180.0F;
273 if (fAzimuth == -180.0F) fAzimuth = +180.0F;
276 if (std::abs(fElevation-90.0f) <= EPSILON)
278 if (std::abs(fElevation+90.0f) <= EPSILON)
281 fAngle1Out = roundf(fAzimuth*1000.0f);
282 fAngle1Out /= 1000.0f;
283 fAngle2Out = roundf(fElevation*1000.0f);
284 fAngle2Out /= 1000.0f;
File has unkown content type (IR, MS, DFT, etc)
Discrete Fourier spectrum in the frequency-domain.
Invalid alpha angles or range problem.
int iVersionMinor
Minor version (example: 7 for version 1.7)
Given metadata type is unknown, use bool, int, double, string.
Invalid index (e.g. record index)
static std::string StrError(int iErrorcode)
Return the string corresponding to an errorcode.
static void NormalizeDirection(int iView, float fAngle1DegIn, float fAngle2DegIn, float &fAngle1DegOut, float &fAngle2DegOut)
Normalize a direction (angular pair)
static std::string StrShortContentType(int iContentType)
Returns a short form string corresponding to a content type e.g. ("ir", "ms", "dft"...)
Magnitude spectrum defined at discrete frequencies.
int iVersionMajor
Major version (example: 1 for version 1.7)
static std::string StrDirection(int iView, double dAngle1Deg, double dAngle2Deg, int precision=9, int leadingzeros=3)
Format a direction (angular pair) as a string canonically.
File format version is not supported by this library version.
Invalid beta angles or range problem.
Magnitude-phase spectrum defined at discrete frequencies.
static std::string StrQuantizationType(int iQuantizationType)
Returns a string corresponding to a quantization type.
Pure data class that covers version information.
Impulse response (IR) in the time-domain.
std::string sVersion
String of version (example: "1.7" for version 1.7)
Modal error (e.g. close a file that is not opened)
static void getLibraryVersion(DAFFVersion &version)
Get the library version.
static std::string Double2StrNice(double d, int precision, bool showpos, int leadingzeros=0)
Converts a double precision floating point into nice std::string.
Data reading error of an otherwise valid DAFF file.
static std::string StrDirectionCompact(int iView, double dAngle1Deg, double dAngle2Deg, int precision=9, int leadingzeros=3)
Format a direction (angular pair) as a string canonically and in more compact form.
Content parameter invalid (sampling rate, num supporting frequencies, etc)
static std::string StrMetadataKeyType(int iKeyType)
Returns a string corresponding to a metadata key datatype.
Invalid DAFF file, i.e. wrong signature.
Data uses unrecognized or wrong quantization.
static std::string StrContentType(int iContentType)
Returns a string corresponding to a content type.
Phase spectrum defined at discrete frequencies.
File has invalid main header parameter (num channels, etc)
static std::string Float2StrNice(float f, int precision, bool showpos, int leadingzeros=0)
Converts a single precision floating point into nice std::string.
Data-related view referring to data spherical coordinates (DSC)
Object-related view referring to object spherical coordinates (OSC)