File: AmbisonicCommons.h

package info (click to toggle)
libspatialaudio 0.3.0%2Bgit20180730%2Bdfsg1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 468 kB
  • sloc: cpp: 2,293; ansic: 1,247; makefile: 5
file content (94 lines) | stat: -rw-r--r-- 2,923 bytes parent folder | download | duplicates (2)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*############################################################################*/
/*#                                                                          #*/
/*#  Ambisonic C++ Library                                                   #*/
/*#  Copyright © 2007 Aristotel Digenis                                      #*/
/*#  Copyright © 2017 Videolabs                                              #*/
/*#                                                                          #*/
/*#  Filename:      AmbisonicCommons.h                                       #*/
/*#  Version:       0.2                                                      #*/
/*#  Date:          19/05/2007                                               #*/
/*#  Author(s):     Aristotel Digenis, Peter Stitt                           #*/
/*#  Licence:       LGPL                                                     #*/
/*#                                                                          #*/
/*############################################################################*/


#ifndef _AMBISONICCOMMONS_H
#define    _AMBISONICCOMMONS_H

#define _USE_MATH_DEFINES
#include <math.h>
#include <memory.h>

#define DEFAULT_ORDER    1
#define    DEFAULT_HEIGHT    true
#define DEFAULT_BFORMAT_SAMPLECOUNT    512
#define DEFAULT_SAMPLERATE 44100
#define DEFAULT_BLOCKSIZE 512
#define DEFAULT_HRTFSET_DIFFUSED false


//TODO
enum BFormatChannels3D
{
    kW,
    kY, kZ, kX,
    kV, kT, kR, kS, kU,
    kQ, kO, kM, kK, kL, kN, kP,
    kNumOfBformatChannels3D
};

/*enum BFormatChannels2D
{
    kW,
    kX, kY,
    kU, kV,
    kP, kQ,
    kNumOfBformatChannels2D
};*/

/// Struct for source positioning in soundfield.
typedef struct PolarPoint
{
    /** horizontal positioning */
    float fAzimuth;
    /** vertical positioning */
    float fElevation;
    /** distance from centre of soundfield (radius)*/
    float fDistance;
} PolarPoint;

/**
    Convert degrees to radians.
*/
float DegreesToRadians(float fDegrees);

/**
    Convert radians to degrees.
*/
float RadiansToDegrees(float fRadians);

/**
    Get the number of BFormat components for a given BFormat configuration.
*/
unsigned OrderToComponents(unsigned nOrder, bool b3D);

/**
    Returns the index component of a BFormat stream where components of a given
    configuration start. For example, in a BFormat stream, the components of a
    2nd order 3D configuration, would start at index 4.
*/
unsigned OrderToComponentPosition(unsigned nOrder, bool b3D);

/**
    Get the recommended minimum speakers needed to decode a BFormat stream of
    a given configuration.
*/
unsigned OrderToSpeakers(unsigned nOrder, bool b3D);

/**
    Get the label for a given index component in a BFormat stream.
*/
char ComponentToChannelLabel(unsigned nComponent, bool b3D);

#endif //_AMBISONICCOMMONS_H