OpenDAFF C++ API  v1.7
Directional Audio File Format
DAFFPropertiesImpl.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_PROPERTIESIMPL
13 #define IW_DAFF_PROPERTIESIMPL
14 
15 #include <DAFFDefs.h>
16 #include <DAFFProperties.h>
17 #include <DAFFSCTransform.h>
18 #include <cassert>
19 #include <cstdlib>
20 
23 {
24 public:
25  // Default constructor
27  : m_iFileFormatVersion(0),
28  m_iContentType(0),
29  m_iQuantization(0),
30  m_iNumChannels(0),
31  m_iNumRecords(0),
32  m_iAlphaPoints(0),
33  m_fAlphaStart(0),
34  m_fAlphaEnd(0),
35  m_fAlphaResolution(0),
36  m_iBetaPoints(0),
37  m_fBetaStart(0),
38  m_fBetaEnd(0),
39  m_fBetaResolution(0),
40  m_pOrientationDefault(0),
41  m_pTrans(0)
42  {};
43 
45  inline DAFFPropertiesImpl(const DAFFProperties* pProps)
46  {
47  assert( pProps != NULL );
48  *this = *pProps;
49  };
50 
52  {
53  delete m_pOrientationDefault;
54  };
55 
58  {
59  m_iFileFormatVersion = oProps.getFileFormatVersion();
60  m_iContentType = oProps.getContentType();
61  m_iQuantization = oProps.getQuantization();
62  m_iNumChannels = oProps.getNumberOfChannels();
63  m_iNumRecords = oProps.getNumberOfRecords();
64  m_iAlphaPoints = oProps.getAlphaPoints();
65  m_iBetaPoints = oProps.getBetaPoints();
66  m_fAlphaStart = oProps.getAlphaStart();
67  m_fAlphaEnd = oProps.getAlphaEnd();
68  m_fAlphaResolution = oProps.getAlphaResolution();
69  m_fBetaStart = oProps.getBetaStart();
70  m_fBetaEnd = oProps.getBetaEnd();
71  m_fBetaResolution = oProps.getBetaResolution();
72 
73  m_pOrientationDefault = new DAFFOrientationYPR;
74  oProps.getDefaultOrientation(*m_pOrientationDefault);
76  oProps.getOrientation(*orient);
77  m_pTrans = new DAFFSCTransform(*orient);
78  delete orient;
79 
80  std::vector<std::string> m_vChannelLabels;
81  for (int i=0; i<oProps.getNumberOfChannels(); i++)
82  m_vChannelLabels.push_back(oProps.getChannelLabel(i));
83 
84  return *this;
85  };
86 
87  // --= Interface "DAFFProperties" =--
88 
89  inline virtual int getFileFormatVersion() const
90  {
91  return m_iFileFormatVersion;
92  };
93 
95  inline virtual int getContentType() const
96  {
97  return m_iContentType;
98  };
99 
101  inline virtual int getQuantization() const
102  {
103  return m_iQuantization;
104  };
105 
107  inline virtual int getNumberOfChannels() const
108  {
109  return m_iNumChannels;
110  };
111 
113  inline virtual int getNumberOfRecords() const
114  {
115  return m_iNumRecords;
116  };
117 
119  inline virtual std::string getChannelLabel(int iChannel) const
120  {
121  return m_vChannelLabels[iChannel];
122  };
123 
124  // -= Alpha angle =----------------------------------
125 
126  // Returns the number of measurement points of the alpha range
127  inline virtual int getAlphaPoints() const
128  {
129  return m_iAlphaPoints;
130  };
131 
132  // Returns the angular resolution of the alpha range
133  inline virtual float getAlphaResolution() const
134  {
135  return m_fAlphaResolution;
136  };
137 
138  // Returns starting angle of the alpha range
139  inline virtual float getAlphaStart() const
140  {
141  return m_fAlphaStart;
142  };
143 
144  // Returns ending angle of the alpha range
145  inline virtual float getAlphaEnd() const
146  {
147  return m_fAlphaEnd;
148  };
149 
150  // Returns the spanned alpha range
151  inline virtual float getAlphaSpan() const
152  {
153  if (m_fAlphaStart <= m_fAlphaEnd)
154  return m_fAlphaEnd - m_fAlphaStart;
155  else // wrap around 0&deg;
156  return 360 - m_fAlphaStart + m_fAlphaEnd;
157  };
158 
159  // -= Beta angle =----------------------------------
160 
161  // Returns the number of measurement points of the beta range
162  inline virtual int getBetaPoints() const
163  {
164  return m_iBetaPoints;
165  };
166 
167  // Returns the angular resolution of the beta range
168  inline virtual float getBetaResolution() const
169  {
170  return m_fBetaResolution;
171  };
172 
173  // Returns starting angle of the beta range
174  inline virtual float getBetaStart() const
175  {
176  return m_fBetaStart;
177  };
178 
179  // Returns ending angle of the beta range
180  inline virtual float getBetaEnd() const
181  {
182  return m_fBetaEnd;
183  };
184 
185  // Returns the spanned beta range
186  inline virtual float getBetaSpan() const
187  {
188  return m_fBetaEnd - m_fBetaStart;
189  };
190 
191  // -= Orientations =----------------------------------
192 
194  inline virtual void getDefaultOrientation(DAFFOrientationYPR& o) const
195  {
196  o = *m_pOrientationDefault;
197  };
198 
200  inline virtual void setDefaultOrientation()
201  {
202  m_pTrans->setOrientation(*m_pOrientationDefault);
203  };
204 
206  inline virtual void getOrientation(DAFFOrientationYPR& o) const
207  {
208  m_pTrans->getOrientation(o);
209  };
210 
212  inline virtual void setOrientation(const DAFFOrientationYPR& o)
213  {
214  m_pTrans->setOrientation(o);
215  };
216 
217  // -= Coverage =--------------------------------------
218 
220  inline virtual bool coversFullAlphaRange() const
221  {
222  // full range coverage is given only when alphastart == 0 and alphaend == 360
223  if ((m_fAlphaStart == 0) && (m_fAlphaEnd == 360))
224  return true;
225  else
226  return false;
227  };
228 
230  inline virtual bool coversFullBetaRange() const
231  {
232  // full range coverage is given only when betastart == 0 and betaend == 180
233  if ((m_fBetaStart == 0) && (m_fBetaEnd == 180))
234  return true;
235  else
236  return false;
237  };
238 
240  inline virtual bool coversFullSphere() const
241  {
243  };
244 
245  // --= Variables =--
246 
247  int m_iFileFormatVersion,
248  m_iContentType,
250  m_iNumChannels,
251  m_iNumRecords,
252  m_iAlphaPoints,
253  m_iBetaPoints;
254 
255  float m_fAlphaStart,
256  m_fAlphaEnd,
257  m_fAlphaResolution,
258  m_fBetaStart,
259  m_fBetaEnd,
260  m_fBetaResolution;
261 
264  std::vector<std::string> m_vChannelLabels;
265 
266 };
267 
268 #endif // IW_DAFF_PROPERTIESIMPL
#define DAFF_API
Definition: DAFFDefs.h:29
virtual int getQuantization() const
Returns the quantization of the data elements.
virtual int getContentType() const
Returns the content type.
virtual std::string getChannelLabel(int iChannel) const
Returns the label of a channel.
virtual std::string getChannelLabel(int iChannel) const =0
Returns the label of a channel.
virtual int getBetaPoints() const
virtual bool coversFullAlphaRange() const
Indicates whether the data covers the full alpha range [0°, 360°)
DAFFSCTransform * m_pTrans
virtual float getAlphaEnd() const
virtual float getBetaResolution() const
virtual float getBetaSpan() const
std::vector< std::string > m_vChannelLabels
virtual float getAlphaStart() const =0
virtual int getFileFormatVersion() const
Returns the DAFF version of the file format.
#define NULL
Definition: DAFFDefs.h:59
virtual float getBetaEnd() const =0
DAFFOrientationYPR * m_pOrientationDefault
virtual void getOrientation(DAFFOrientationYPR &o) const =0
Returns the current orientation of the object view.
virtual int getNumberOfChannels() const
Returns the number of channels.
virtual bool coversFullBetaRange() const
Indicates whether the data covers the full beta range [0°, 180°].
virtual float getBetaStart() const =0
virtual bool coversFullSphere() const
Indicates whether the data covers the full sphere.
virtual int getQuantization() const =0
Returns the quantization of the data elements.
virtual void setOrientation(const DAFFOrientationYPR &o)
Sets the current orientation of the object view.
virtual int getContentType() const =0
Returns the content type.
virtual int getAlphaPoints() const =0
virtual bool coversFullBetaRange() const =0
Indicates whether the data covers the full beta range [0°, 180°].
virtual float getAlphaStart() const
virtual int getNumberOfRecords() const =0
Returns the overall number of records.
virtual void getDefaultOrientation(DAFFOrientationYPR &o) const
Returns the default orientation as stored in the file.
virtual int getFileFormatVersion() const =0
Returns the DAFF version of the file format.
virtual float getBetaEnd() const
virtual int getNumberOfRecords() const
Returns the overall number of records.
virtual float getAlphaSpan() const
virtual void setDefaultOrientation()
Sets/alters the default orientation manually.
virtual float getAlphaEnd() const =0
virtual int getBetaPoints() const =0
Properties of a DAFF file that uses regular sphere grids (or parts of a regular grid) ...
virtual void getOrientation(DAFFOrientationYPR &o) const
Returns the current orientation of the object view.
virtual float getBetaStart() const
DAFFPropertiesImpl & operator=(const DAFFProperties &oProps)
Assignment operator.
virtual int getAlphaPoints() const
virtual int getNumberOfChannels() const =0
Returns the number of channels.
virtual float getAlphaResolution() const =0
virtual float getAlphaResolution() const
Implements the interface of DAFFProperties.
Data class for orientations in yaw-pitch-roll (YPR) angles (right-handed OpenGL coordinate system) ...
Definition: DAFFDefs.h:138
virtual void getDefaultOrientation(DAFFOrientationYPR &o) const =0
Returns the default orientation as stored in the file.
DAFFPropertiesImpl(const DAFFProperties *pProps)
Copy constructor.
virtual float getBetaResolution() const =0
virtual bool coversFullAlphaRange() const =0
Indicates whether the data covers the full alpha range [0°, 360°)
OpenDAFF is a project from the Institute of Technical Acoustics, RWTH Aachen University, Germany.