OpenDAFF C++ API  v1.7
Directional Audio File Format
DAFFUtils.h
Go to the documentation of this file.
1 /*
2  * -------------------------------------------------------------------------------------
3  *
4  * OpenDAFF - A free, open source software package for directional audio data
5  * Copyright 2016 Institute of Technical Acoustics, RWTH Aachen University
6  * OpenDAFF is distributed under the Apache License Version 2.0.
7  *
8  * ------------------------------------------------------------------------------------
9  *
10  */
11 
12 #ifndef IW_DAFF_UTILS
13 #define IW_DAFF_UTILS
14 
15 #include <DAFFDefs.h>
16 
17 #include <string>
18 #include <cmath>
19 
20 namespace DAFF
21 {
22  static const float PI_F = acos( -1.0f );
23  static const double PI_D = acos( -1.0f );
24  static const float HALF_PI_F = PI_F / 2.0f;
25  static const float TWO_PI_F = 2.0f * PI_F;
26  static const double EPSILON_D = 1.0e-6;
27 }
28 
30 
36 {
37 public:
39  static void getLibraryVersion( DAFFVersion& version );
40 
42 
46  static std::string StrDirection( int iView, double dAngle1Deg, double dAngle2Deg, int precision = 9, int leadingzeros = 3 );
47 
49 
53  static std::string StrDirectionCompact( int iView, double dAngle1Deg, double dAngle2Deg, int precision = 9, int leadingzeros = 3 );
54 
56  static std::string StrError( int iErrorcode );
57 
59  static std::string StrContentType( int iContentType );
60 
62  static std::string StrShortContentType( int iContentType );
63 
65  static std::string StrMetadataKeyType( int iKeyType );
66 
68  static std::string StrQuantizationType( int iQuantizationType );
69 
71 
81  static void NormalizeDirection( int iView, float fAngle1DegIn, float fAngle2DegIn, float& fAngle1DegOut, float& fAngle2DegOut);
82 
84 
87  static std::string Float2StrNice( float f, int precision, bool showpos, int leadingzeros = 0 );
88 
90 
93  static std::string Double2StrNice( double d, int precision, bool showpos, int leadingzeros=0 );
94 
95 
96 
97  // --= Angle conversion and normalization =--
98 
99  inline static float grad2radf( float phi )
100  {
101  return phi * DAFF::PI_F / 180.0f;
102  };
103 
104  inline static float rad2gradf( float phi )
105  {
106  return phi * 180.0f / DAFF::PI_F;
107  };
108 
109  inline static double grad2rad( double phi )
110  {
111  return phi * DAFF::PI_D / 180.0f;
112  };
113 
114  inline static double rad2grad( double phi )
115  {
116  return phi * 180.0f / DAFF::PI_D;
117  };
118 
119 private:
120  inline DAFFUtils() {};
121  inline DAFFUtils( const DAFFUtils& ) {};
122  inline ~DAFFUtils() {};
123 };
124 
125 #endif // IW_DAFF_UTILS
static float rad2gradf(float phi)
Definition: DAFFUtils.h:104
#define DAFF_API
Definition: DAFFDefs.h:29
Pure data class that covers version information.
Definition: DAFFDefs.h:113
static double rad2grad(double phi)
Definition: DAFFUtils.h:114
static float grad2radf(float phi)
Definition: DAFFUtils.h:99
Definition: DAFFUtils.h:20
Collection of utility functions.
Definition: DAFFUtils.h:35
static double grad2rad(double phi)
Definition: DAFFUtils.h:109
OpenDAFF is a project from the Institute of Technical Acoustics, RWTH Aachen University, Germany.