VISR  0.11.1
Versatile Interactive Scene Renderer
CAP.h
Go to the documentation of this file.
1 //
2 // CAP.h
3 // Created by Dylan Menzies on 24/1/2018.
4 // Copyright (c) ISVR, University of Southampton. All rights reserved.
5 //
6 // Minimum energy Multichannel Compensated Amplitude Panning
7 // Panning compensated for head orientation, valid in ITD frequency range ~(0,1000)Hz
8 //
9 
10 #ifndef __S3A_renderer_dsp__CAP__
11 #define __S3A_renderer_dsp__CAP__
12 
13 // uncomment to enable debug output
14 // #define CAP_DEBUG_MESSAGES
15 
16 #include "defs.h"
17 #include "LoudspeakerArray.h"
18 
19 #include "export_symbols.hpp"
20 
21 #include <libefl/basic_matrix.hpp>
22 
23 namespace visr
24 {
25 namespace panning
26 {
27 
28 class VISR_PANNING_LIBRARY_SYMBOL CAP
29 {
30 private:
31 
32  LoudspeakerArray const * m_array;
34  XYZ m_listenerPos;
35  XYZ m_listenerAuralAxis; // Normal vector through ears
36  XYZ const * m_sourcePos;
37  std::size_t m_nSources;
38  Afloat m_maxGain = 10.0f;
39  Afloat m_reorientMatrix[3][3] = {{1.0f,0.0f,0.0f}, {0.0f,1.0f,0.0f}, {0.0f,0.0f,1.0f}};
40 
41 
42 public:
47  CAP();
48 
50  m_array = array;
51  m_gain.resize( m_nSources, array->getNumRegularSpeakers( ) );
52  return 0;
53  }
54 
56 
57 #ifdef CAP_DEBUG_MESSAGES
58  printf("setListenerPosition %f %f %f\n",x,y,z);
59 #endif
60 
61  m_listenerPos.set(x, y, z);
62 
63  return 0;
64  }
65 
66 
67 
68  int setListenerOrientation(Afloat yaw, Afloat pitch, Afloat roll, bool zero);
69 
70 
71 
73 
74 #ifdef CAP_DEBUG_MESSAGES
75  printf("setListenerAuralAxis %f %f %f\n",x,y,z);
76 #endif
77 
78  m_listenerAuralAxis.set(x, y, z);
79 
80  return 0;
81  }
82 
83 
84  int setSourcePositions(XYZ const *sp ) {
85  m_sourcePos = sp;
86  return 0;
87  }
88 
89  std::size_t setNumSources( std::size_t n) {
90  m_nSources = n;
91  // Take care of the fact that the loudspeaker
92  // array might not been set yet.
93  std::size_t const numSpeakers = m_array ? m_array->getNumSpeakers() : 0;
94  m_gain.resize( m_nSources, numSpeakers );
95  return n;
96  }
97 
98  int setMaxGain(Afloat mg) { m_maxGain = mg; return 0; }
99 
100  std::size_t getNumSpeakers() const { return m_array->getNumSpeakers(); }
101 
102  int calcGains();
103 
105  return m_gain;
106  }
107 
108 
109 
110 };
111 
112 } // namespace panning
113 } // namespace visr
114 
115 #endif /* defined(__S3A_renderer_dsp__CAP__) */
int setSourcePositions(XYZ const *sp)
Definition: CAP.h:84
Definition: XYZ.h:23
int setListenerPosition(Afloat x, Afloat y, Afloat z)
Definition: CAP.h:55
std::size_t getNumSpeakers() const
Definition: LoudspeakerArray.h:190
efl::BasicMatrix< Afloat > const & getGains() const
Definition: CAP.h:104
std::size_t getNumRegularSpeakers() const
Definition: LoudspeakerArray.h:195
int set(Afloat X, Afloat Y, Afloat Z, bool inf=false)
Definition: XYZ.h:53
std::size_t setNumSources(std::size_t n)
Definition: CAP.h:89
Definition: options.cpp:10
void resize(std::size_t newNumberOfRows, std::size_t newNumberOfColumns)
Definition: basic_matrix.hpp:89
Definition: LoudspeakerArray.h:42
int setListenerAuralAxis(Afloat x, Afloat y, Afloat z)
Definition: CAP.h:72
int setLoudspeakerArray(LoudspeakerArray const *array)
Definition: CAP.h:49
Definition: CAP.h:28
int setMaxGain(Afloat mg)
Definition: CAP.h:98
std::size_t getNumSpeakers() const
Definition: CAP.h:100
float Afloat
Definition: defs.h:15