File: mit_hrtf_lib.c

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 (454 lines) | stat: -rw-r--r-- 20,799 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/*############################################################################*/
/*#                                                                          #*/
/*#  MIT HRTF C Library                                                      #*/
/*#  Copyright � 2007 Aristotel Digenis                                      #*/
/*#                                                                          #*/
/*#  Filename:  mit_hrtf_lib.c                                               #*/
/*#  Version:   0.1                                                          #*/
/*#  Date:      04/05/2007                                                   #*/
/*#  Author(s): Aristotel Digenis                                            #*/
/*#  Credit:    Bill Gardner and Keith Martin                                #*/
/*#  Licence:   MIT                                                          #*/
/*#                                                                          #*/
/*############################################################################*/

#include "config.h"

#ifdef HAVE_MIT_HRTF

#include "../include/mit_hrtf_lib.h"
#include "normal/mit_hrtf_normal_44100.h"
#include "normal/mit_hrtf_normal_48000.h"
#include "normal/mit_hrtf_normal_88200.h"
#include "normal/mit_hrtf_normal_96000.h"



/*    Internal functions for handling the indexing of the -/+40 degree elevation
    data which has irregular azimuth positions. */
int mit_hrtf_findAzimuthFor40Elev(int azimuth);
int mit_hrtf_findIndexFor40Elev(int azimuth);



unsigned int mit_hrtf_availability(int azimuth, int elevation, unsigned int samplerate)
{
    if(elevation > 90 || elevation < -40)
        return 0;

    if(azimuth > 180 || azimuth < -180)
        return 0;

    if(samplerate == 44100)
        return MIT_HRTF_44_TAPS;
    else if(samplerate == 48000)
        return MIT_HRTF_48_TAPS;
    else if(samplerate == 88200)
        return MIT_HRTF_88_TAPS;
    else if(samplerate == 96000)
        return MIT_HRTF_96_TAPS;

    return 0;
}



unsigned int mit_hrtf_get(int* pAzimuth, int* pElevation, unsigned int samplerate, short* psLeft, short* psRight)
{
    int nInternalElevation = 0;
    float fAzimuthIncrement = 0;
    int nInternalAzimuth = 0;
    int nSwitchLeftRight = 0;
    int nAzimuthIndex = 0;
    const mit_hrtf_filter_set_44* pFilter44 = 0;
    const mit_hrtf_filter_set_48* pFilter48 = 0;
    const mit_hrtf_filter_set_88* pFilter88 = 0;
    const mit_hrtf_filter_set_96* pFilter96 = 0;
    const short* psLeftTaps = 0;
    const short* psRightTaps = 0;
    const short* psTempTaps = 0;
    unsigned int nTotalTaps = 0;
    unsigned int niTap = 0;

    //Check if the requested HRTF exists
    if(!mit_hrtf_availability(*pAzimuth, *pElevation, samplerate))
        return 0;

    //Snap elevation to the nearest available elevation in the filter set
    if(*pElevation < 0)
        nInternalElevation = ((*pElevation - 5) / 10) * 10;
    else
        nInternalElevation = ((*pElevation + 5) / 10) * 10;

    // Elevation of 50 has a maximum 176 in the azimuth plane so we need to handle that.
    if(nInternalElevation == 50)
    {
        if(*pAzimuth < 0)
            *pAzimuth = *pAzimuth < -176 ? -176 : *pAzimuth;
        else
            *pAzimuth = *pAzimuth > 176 ? 176 : *pAzimuth;
    }

    //Snap azimuth to the nearest available azimuth in the filter set.
    switch(nInternalElevation)
    {
    case 0:        fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_00 - 1);        break;    // 180 5
    case 10:
    case -10:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_10 - 1);        break;    // 180 5
    case 20:
    case -20:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_20 - 1);        break;    // 180 5
    case 30:
    case -30:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_30 - 1);        break;    // 180 6
    case 40:
    case -40:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_40 - 1);        break;    // 180 6.43
    case 50:    fAzimuthIncrement = 176.f / (MIT_HRTF_AZI_POSITIONS_50 - 1);        break;    // 176 8
    case 60:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_60 - 1);        break;    // 180 10
    case 70:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_70 - 1);        break;    // 180 15
    case 80:    fAzimuthIncrement = 180.f / (MIT_HRTF_AZI_POSITIONS_80 - 1);        break;    // 180 30
    case 90:    fAzimuthIncrement = 0;                                                break;    // 0   1
    };

    if(*pAzimuth < 0)
    {
        nInternalAzimuth = (int)((int)((-*pAzimuth + fAzimuthIncrement / 2.f) / fAzimuthIncrement) * fAzimuthIncrement + 0.5f);
        nSwitchLeftRight = 1;
    }
    else
    {
        nInternalAzimuth = (int)((int)((*pAzimuth + fAzimuthIncrement / 2.f) / fAzimuthIncrement) * fAzimuthIncrement + 0.5f);
    }

    //Determine array index for azimuth based on elevation
    switch(nInternalElevation)
    {
    case 0:        nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_00 - 1));    break;
    case 10:
    case -10:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_10 - 1));    break;
    case 20:
    case -20:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_20 - 1));    break;
    case 30:
    case -30:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_30 - 1));    break;
    case 40:
    case -40:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_40 - 1));    break;
    case 50:    nAzimuthIndex = (int)((nInternalAzimuth / 176.f) * (MIT_HRTF_AZI_POSITIONS_50 - 1));    break;
    case 60:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_60 - 1));    break;
    case 70:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_70 - 1));    break;
    case 80:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_80 - 1));    break;
    case 90:    nAzimuthIndex = (int)((nInternalAzimuth / 180.f) * (MIT_HRTF_AZI_POSITIONS_90 - 1));    break;
    };

    //The azimuths for +/- elevations need special handling
    if(nInternalElevation == 40 || nInternalElevation == -40)
    {
        nInternalAzimuth = mit_hrtf_findAzimuthFor40Elev(nInternalAzimuth);
        nAzimuthIndex = mit_hrtf_findIndexFor40Elev(nInternalAzimuth);
    }

    //Assign pointer to appropriate array depending on saple rate, normal filters, elevation, and azimuth index.
    switch(samplerate)
    {
    case 44100:
        pFilter44 = &normal_44;

        switch(nInternalElevation)
        {
        case -10:    psLeftTaps = pFilter44->e_10[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e_10[nAzimuthIndex].right;        break;
        case -20:    psLeftTaps = pFilter44->e_20[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e_20[nAzimuthIndex].right;        break;
        case -30:    psLeftTaps = pFilter44->e_30[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e_30[nAzimuthIndex].right;        break;
        case -40:    psLeftTaps = pFilter44->e_40[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e_40[nAzimuthIndex].right;        break;
        case 0:        psLeftTaps = pFilter44->e00[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e00[nAzimuthIndex].right;        break;
        case 10:    psLeftTaps = pFilter44->e10[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e10[nAzimuthIndex].right;        break;
        case 20:    psLeftTaps = pFilter44->e20[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e20[nAzimuthIndex].right;        break;
        case 30:    psLeftTaps = pFilter44->e30[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e30[nAzimuthIndex].right;        break;
        case 40:    psLeftTaps = pFilter44->e40[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e40[nAzimuthIndex].right;        break;
        case 50:    psLeftTaps = pFilter44->e50[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e50[nAzimuthIndex].right;        break;
        case 60:    psLeftTaps = pFilter44->e60[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e60[nAzimuthIndex].right;        break;
        case 70:    psLeftTaps = pFilter44->e70[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e70[nAzimuthIndex].right;        break;
        case 80:    psLeftTaps = pFilter44->e80[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e80[nAzimuthIndex].right;        break;
        case 90:    psLeftTaps = pFilter44->e90[nAzimuthIndex].left;
                    psRightTaps = pFilter44->e90[nAzimuthIndex].right;        break;
        };

        //How many taps to copy later to user's buffers
        nTotalTaps = MIT_HRTF_44_TAPS;
        break;
    case 48000:
        pFilter48 = &normal_48;

        switch(nInternalElevation)
        {
        case -10:    psLeftTaps = pFilter48->e_10[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e_10[nAzimuthIndex].right;        break;
        case -20:    psLeftTaps = pFilter48->e_20[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e_20[nAzimuthIndex].right;        break;
        case -30:    psLeftTaps = pFilter48->e_30[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e_30[nAzimuthIndex].right;        break;
        case -40:    psLeftTaps = pFilter48->e_40[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e_40[nAzimuthIndex].right;        break;
        case 0:        psLeftTaps = pFilter48->e00[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e00[nAzimuthIndex].right;        break;
        case 10:    psLeftTaps = pFilter48->e10[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e10[nAzimuthIndex].right;        break;
        case 20:    psLeftTaps = pFilter48->e20[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e20[nAzimuthIndex].right;        break;
        case 30:    psLeftTaps = pFilter48->e30[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e30[nAzimuthIndex].right;        break;
        case 40:    psLeftTaps = pFilter48->e40[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e40[nAzimuthIndex].right;        break;
        case 50:    psLeftTaps = pFilter48->e50[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e50[nAzimuthIndex].right;        break;
        case 60:    psLeftTaps = pFilter48->e60[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e60[nAzimuthIndex].right;        break;
        case 70:    psLeftTaps = pFilter48->e70[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e70[nAzimuthIndex].right;        break;
        case 80:    psLeftTaps = pFilter48->e80[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e80[nAzimuthIndex].right;        break;
        case 90:    psLeftTaps = pFilter48->e90[nAzimuthIndex].left;
                    psRightTaps = pFilter48->e90[nAzimuthIndex].right;        break;
        };

        //How many taps to copy later to user's buffers
        nTotalTaps = MIT_HRTF_48_TAPS;
        break;
    case 88200:
        pFilter88 = &normal_88;

        switch(nInternalElevation)
        {
        case -10:    psLeftTaps = pFilter88->e_10[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e_10[nAzimuthIndex].right;        break;
        case -20:    psLeftTaps = pFilter88->e_20[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e_20[nAzimuthIndex].right;        break;
        case -30:    psLeftTaps = pFilter88->e_30[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e_30[nAzimuthIndex].right;        break;
        case -40:    psLeftTaps = pFilter88->e_40[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e_40[nAzimuthIndex].right;        break;
        case 0:        psLeftTaps = pFilter88->e00[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e00[nAzimuthIndex].right;        break;
        case 10:    psLeftTaps = pFilter88->e10[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e10[nAzimuthIndex].right;        break;
        case 20:    psLeftTaps = pFilter88->e20[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e20[nAzimuthIndex].right;        break;
        case 30:    psLeftTaps = pFilter88->e30[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e30[nAzimuthIndex].right;        break;
        case 40:    psLeftTaps = pFilter88->e40[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e40[nAzimuthIndex].right;        break;
        case 50:    psLeftTaps = pFilter88->e50[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e50[nAzimuthIndex].right;        break;
        case 60:    psLeftTaps = pFilter88->e60[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e60[nAzimuthIndex].right;        break;
        case 70:    psLeftTaps = pFilter88->e70[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e70[nAzimuthIndex].right;        break;
        case 80:    psLeftTaps = pFilter88->e80[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e80[nAzimuthIndex].right;        break;
        case 90:    psLeftTaps = pFilter88->e90[nAzimuthIndex].left;
                    psRightTaps = pFilter88->e90[nAzimuthIndex].right;        break;
        };

        //How many taps to copy later to user's buffers
        nTotalTaps = MIT_HRTF_88_TAPS;
        break;
    case 96000:
        pFilter96 = &normal_96;

        switch(nInternalElevation)
        {
        case -10:    psLeftTaps = pFilter96->e_10[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e_10[nAzimuthIndex].right;        break;
        case -20:    psLeftTaps = pFilter96->e_20[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e_20[nAzimuthIndex].right;        break;
        case -30:    psLeftTaps = pFilter96->e_30[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e_30[nAzimuthIndex].right;        break;
        case -40:    psLeftTaps = pFilter96->e_40[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e_40[nAzimuthIndex].right;        break;
        case 0:        psLeftTaps = pFilter96->e00[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e00[nAzimuthIndex].right;        break;
        case 10:    psLeftTaps = pFilter96->e10[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e10[nAzimuthIndex].right;        break;
        case 20:    psLeftTaps = pFilter96->e20[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e20[nAzimuthIndex].right;        break;
        case 30:    psLeftTaps = pFilter96->e30[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e30[nAzimuthIndex].right;        break;
        case 40:    psLeftTaps = pFilter96->e40[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e40[nAzimuthIndex].right;        break;
        case 50:    psLeftTaps = pFilter96->e50[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e50[nAzimuthIndex].right;        break;
        case 60:    psLeftTaps = pFilter96->e60[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e60[nAzimuthIndex].right;        break;
        case 70:    psLeftTaps = pFilter96->e70[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e70[nAzimuthIndex].right;        break;
        case 80:    psLeftTaps = pFilter96->e80[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e80[nAzimuthIndex].right;        break;
        case 90:    psLeftTaps = pFilter96->e90[nAzimuthIndex].left;
                    psRightTaps = pFilter96->e90[nAzimuthIndex].right;        break;
        };

        //How many taps to copy later to user's buffers
        nTotalTaps = MIT_HRTF_96_TAPS;
        break;
    };

    //Switch left and right ear if the azimuth is to the left of front centre (azimuth < 0)
    if(nSwitchLeftRight)
    {
        psTempTaps = psRightTaps;
        psRightTaps = psLeftTaps;
        psLeftTaps = psTempTaps;
    }

    //Copy taps to user's arrays
    for(niTap = 0; niTap < nTotalTaps; niTap++)
    {
        psLeft[niTap] = psLeftTaps[niTap];
        psRight[niTap] = psRightTaps[niTap];
    }

    //Assign the real azimuth and elevation used
    *pAzimuth = nInternalAzimuth;
    *pElevation = nInternalElevation;

    return nTotalTaps;
}



int mit_hrtf_findAzimuthFor40Elev(int azimuth)
{
    if(azimuth >= 0 && azimuth < 4)
        return 0;
    else if(azimuth >= 4 && azimuth < 10)
        return 6;
    else if(azimuth >= 10 && azimuth < 17)
        return 13;
    else if(azimuth >= 17 && azimuth < 23)
        return 19;
    else if(azimuth >= 23 && azimuth < 30)
        return 26;
    else if(azimuth >= 30 && azimuth < 36)
        return 32;
    else if(azimuth >= 36 && azimuth < 43)
        return 39;
    else if(azimuth >= 43 && azimuth < 49)
        return 45;
    else if(azimuth >= 49 && azimuth < 55)
        return 51;
    else if(azimuth >= 55 && azimuth < 62)
        return 58;
    else if(azimuth >= 62 && azimuth < 68)
        return 64;
    else if(azimuth >= 68 && azimuth < 75)
        return 71;
    else if(azimuth >= 75 && azimuth < 81)
        return 77;
    else if(azimuth >= 81 && azimuth < 88)
        return 84;
    else if(azimuth >= 88 && azimuth < 94)
        return 90;
    else if(azimuth >= 94 && azimuth < 100)
        return 96;
    else if(azimuth >= 100 && azimuth < 107)
        return 103;
    else if(azimuth >= 107 && azimuth < 113)
        return 109;
    else if(azimuth >= 113 && azimuth < 120)
        return 116;
    else if(azimuth >= 120 && azimuth < 126)
        return 122;
    else if(azimuth >= 126 && azimuth < 133)
        return 129;
    else if(azimuth >= 133 && azimuth < 139)
        return 135;
    else if(azimuth >= 139 && azimuth < 145)
        return 141;
    else if(azimuth >= 145 && azimuth < 152)
        return 148;
    else if(azimuth >= 152 && azimuth < 158)
        return 154;
    else if(azimuth >= 158 && azimuth < 165)
        return 161;
    else if(azimuth >= 165 && azimuth < 171)
        return 167;
    else if(azimuth >= 171 && azimuth < 178)
        return 174;
    else
        return 180;
};



int mit_hrtf_findIndexFor40Elev(int azimuth)
{
    if(azimuth >= 0 && azimuth < 4)
        return 0;
    else if(azimuth >= 4 && azimuth < 10)
        return 1;
    else if(azimuth >= 10 && azimuth < 17)
        return 2;
    else if(azimuth >= 17 && azimuth < 23)
        return 3;
    else if(azimuth >= 23 && azimuth < 30)
        return 4;
    else if(azimuth >= 30 && azimuth < 36)
        return 5;
    else if(azimuth >= 36 && azimuth < 43)
        return 6;
    else if(azimuth >= 43 && azimuth < 49)
        return 7;
    else if(azimuth >= 49 && azimuth < 55)
        return 8;
    else if(azimuth >= 55 && azimuth < 62)
        return 9;
    else if(azimuth >= 62 && azimuth < 68)
        return 10;
    else if(azimuth >= 68 && azimuth < 75)
        return 11;
    else if(azimuth >= 75 && azimuth < 81)
        return 12;
    else if(azimuth >= 81 && azimuth < 88)
        return 13;
    else if(azimuth >= 88 && azimuth < 94)
        return 14;
    else if(azimuth >= 94 && azimuth < 100)
        return 15;
    else if(azimuth >= 100 && azimuth < 107)
        return 16;
    else if(azimuth >= 107 && azimuth < 113)
        return 17;
    else if(azimuth >= 113 && azimuth < 120)
        return 18;
    else if(azimuth >= 120 && azimuth < 126)
        return 19;
    else if(azimuth >= 126 && azimuth < 133)
        return 20;
    else if(azimuth >= 133 && azimuth < 139)
        return 21;
    else if(azimuth >= 139 && azimuth < 145)
        return 22;
    else if(azimuth >= 145 && azimuth < 152)
        return 23;
    else if(azimuth >= 152 && azimuth < 158)
        return 24;
    else if(azimuth >= 158 && azimuth < 165)
        return 25;
    else if(azimuth >= 165 && azimuth < 171)
        return 26;
    else if(azimuth >= 171 && azimuth < 178)
        return 27;
    else
        return 28;
}

#endif