File: AmbisonicMicrophone.cpp

package info (click to toggle)
libspatialaudio 0.3.0+git20180730+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 464 kB
  • sloc: cpp: 2,293; ansic: 1,247; makefile: 5
file content (59 lines) | stat: -rw-r--r-- 2,179 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*############################################################################*/
/*#                                                                          #*/
/*#  Ambisonic C++ Library                                                   #*/
/*#  CAmbisonicMicrophone - Ambisonic Microphone                             #*/
/*#  Copyright © 2007 Aristotel Digenis                                      #*/
/*#                                                                          #*/
/*#  Filename:      AmbisonicMicrophone.cpp                                  #*/
/*#  Version:       0.1                                                      #*/
/*#  Date:          19/05/2007                                               #*/
/*#  Author(s):     Aristotel Digenis                                        #*/
/*#  Licence:       MIT                                                      #*/
/*#                                                                          #*/
/*############################################################################*/


#include "AmbisonicMicrophone.h"

CAmbisonicMicrophone::CAmbisonicMicrophone()
{
    m_fDirectivity = 1.f;
}

CAmbisonicMicrophone::~CAmbisonicMicrophone()
{ }

void CAmbisonicMicrophone::Refresh()
{
    CAmbisonicSource::Refresh();

    m_pfCoeff[0] *= (2.f - m_fDirectivity) * sqrtf(2.f);
}

void CAmbisonicMicrophone::Process(CBFormat* pBFSrc, unsigned nSamples, float* pfDst)
{
    unsigned niChannel = 0;
    unsigned niSample = 0;
    float fTempA = 0;
    float fTempB = 0;
    for(niSample = 0; niSample < nSamples; niSample++)
    {
        fTempA = pBFSrc->m_ppfChannels[0][niSample] * m_pfCoeff[0];
        fTempB = 0;
        for(niChannel = 1; niChannel < m_nChannelCount; niChannel++)
        {
            fTempB += pBFSrc->m_ppfChannels[niChannel][niSample] * m_pfCoeff[niChannel];
        }
        pfDst[niSample] = 0.5f * (fTempA + fTempB * m_fDirectivity);
    }
}

void CAmbisonicMicrophone::SetDirectivity(float fDirectivity)
{
    m_fDirectivity = fDirectivity;
}

float CAmbisonicMicrophone::GetDirectivity()
{
    return m_fDirectivity;
}