SAL
A C++ library for spatial audio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
kemarmic.h
Go to the documentation of this file.
1 /*
2  kemarmic.h
3  Spatial Audio Library (SAL)
4  Copyright (c) 2015, Enzo De Sena
5  All rights reserved.
6 
7  Authors: Enzo De Sena, enzodesena@gmail.com
8 
9  */
10 
11 #ifndef SAL_KEMARMIC_H
12 #define SAL_KEMARMIC_H
13 
14 #define FULL_LENGTH_KEMAR 128
15 #define NUM_ELEVATIONS_KEMAR 14
16 #define NORMALISING_VALUE_KEMAR 30000.0
17 
18 #include <map>
19 #include <vector>
20 #include "microphone.h"
21 #include "saltypes.h"
22 #include "array.h"
23 #include "binauralmic.h"
24 #include "salconstants.h"
25 
26 namespace sal {
27 
28 
29 class KemarMic : public DatabaseBinauralMic {
30 public:
37  KemarMic(const mcl::Point& position,
38  const mcl::Quaternion orientation,
39  const std::string directory = "",
40  const Int num_samples = kFullBrirLength,
41  const Int update_length = 0,
42  const HeadRefOrientation reference_orientation = HeadRefOrientation::standard,
43  const Time sampling_frequency = 44100.0);
44 
45  static const int kFullBrirLength = -1;
46 
47  static bool IsDatabaseAvailable(const std::string directory);
48 
49  static void PrintParsedDatabase(const Ear ear,
50  const std::string directory,
51  const Int num_samples,
52  std::string variable_name);
53 
54  static bool Test();
55 private:
56  virtual Signal GetBrir(const Ear ear, const mcl::Point& point) noexcept;
57 
58  static
59  std::vector<std::vector<Signal> > Load(const Ear ear,
60  const std::string directory);
61 
62  static std::vector<std::vector<Signal> > LoadEmbedded(const Ear ear);
63 
64  static void LoadEmbeddedData(const Ear ear,
65  std::vector<std::vector<Signal> >& data);
66 
71  Int FindElevationIndex(Angle elevation);
72 
73 
78  Int FindAzimuthIndex(Angle azimuth, Int elevation_index);
79 
80  static Array<mcl::Int, NUM_ELEVATIONS_KEMAR> GetNumMeasurements() noexcept;
81  static Array<mcl::Int, NUM_ELEVATIONS_KEMAR> GetElevations() noexcept;
82 
83  Array<mcl::Int, NUM_ELEVATIONS_KEMAR> num_measurements_;
84  Array<mcl::Int, NUM_ELEVATIONS_KEMAR> elevations_;
85 
86  static std::string GetFilePath(const Angle elevation, const Angle angle,
87  const std::string directory) noexcept;
88 };
89 
90 
91 
92 } // namespace sal
93 
94 //#ifndef DO_NOT_LOAD_EMBEDDED_KEMAR
95 // #include "kemarmicdata.h"
96 //#endif
97 
98 #endif