neverlib 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. neverlib/.claude/settings.local.json +9 -0
  2. neverlib/Docs/audio_aug/test_volume.ipynb +416 -0
  3. neverlib/Docs/audio_aug_test/test_volume.ipynb +289 -0
  4. neverlib/Docs/filter/biquad.ipynb +129 -0
  5. neverlib/Docs/filter/filter_family.ipynb +450 -0
  6. neverlib/Docs/filter/highpass.ipynb +139 -0
  7. neverlib/Docs/filter/scipy_filter_family.ipynb +110 -0
  8. neverlib/Docs/vad/VAD_Energy.ipynb +167 -0
  9. neverlib/Docs/vad/VAD_Silero.ipynb +325 -0
  10. neverlib/Docs/vad/VAD_WebRTC.ipynb +189 -0
  11. neverlib/Docs/vad/VAD_funasr.ipynb +192 -0
  12. neverlib/Docs/vad/VAD_rvADfast.ipynb +162 -0
  13. neverlib/Docs/vad/VAD_statistics.ipynb +532 -0
  14. neverlib/Docs/vad/VAD_tenVAD.ipynb +292 -0
  15. neverlib/Docs/vad/VAD_vadlib.ipynb +168 -0
  16. neverlib/Docs/vad/VAD_whisper.ipynb +404 -0
  17. neverlib/QA/gen_init.py +117 -0
  18. neverlib/QA/get_fun.py +19 -0
  19. neverlib/__init__.py +21 -4
  20. neverlib/audio_aug/HarmonicDistortion.py +19 -13
  21. neverlib/audio_aug/__init__.py +30 -12
  22. neverlib/audio_aug/audio_aug.py +19 -14
  23. neverlib/audio_aug/clip_aug.py +15 -18
  24. neverlib/audio_aug/coder_aug.py +44 -24
  25. neverlib/audio_aug/coder_aug2.py +54 -37
  26. neverlib/audio_aug/loss_packet_aug.py +7 -7
  27. neverlib/audio_aug/quant_aug.py +19 -17
  28. neverlib/data/000_short_enhance.wav +0 -0
  29. neverlib/data/3956_speech.wav +0 -0
  30. neverlib/data/3956_sweep.wav +0 -0
  31. neverlib/data/vad_example.wav +0 -0
  32. neverlib/data/white.wav +0 -0
  33. neverlib/data/white_EQ.wav +0 -0
  34. neverlib/data/white_matched.wav +0 -0
  35. neverlib/data_analyze/__init__.py +25 -20
  36. neverlib/data_analyze/dataset_analyzer.py +109 -114
  37. neverlib/data_analyze/quality_metrics.py +87 -89
  38. neverlib/data_analyze/rms_distrubution.py +23 -42
  39. neverlib/data_analyze/spectral_analysis.py +43 -46
  40. neverlib/data_analyze/statistics.py +76 -76
  41. neverlib/data_analyze/temporal_features.py +15 -6
  42. neverlib/data_analyze/visualization.py +208 -144
  43. neverlib/filter/__init__.py +17 -20
  44. neverlib/filter/auto_eq/__init__.py +18 -35
  45. neverlib/filter/auto_eq/de_eq.py +0 -2
  46. neverlib/filter/common.py +24 -5
  47. neverlib/metrics/DNSMOS/bak_ovr.onnx +0 -0
  48. neverlib/metrics/DNSMOS/model_v8.onnx +0 -0
  49. neverlib/metrics/DNSMOS/sig.onnx +0 -0
  50. neverlib/metrics/DNSMOS/sig_bak_ovr.onnx +0 -0
  51. neverlib/metrics/__init__.py +23 -0
  52. neverlib/metrics/dnsmos.py +4 -15
  53. neverlib/metrics/pDNSMOS/sig_bak_ovr.onnx +0 -0
  54. neverlib/metrics/pesq_c/PESQ +0 -0
  55. neverlib/metrics/pesq_c/dsp.c +553 -0
  56. neverlib/metrics/pesq_c/dsp.h +138 -0
  57. neverlib/metrics/pesq_c/pesq.h +294 -0
  58. neverlib/metrics/pesq_c/pesqdsp.c +1047 -0
  59. neverlib/metrics/pesq_c/pesqio.c +392 -0
  60. neverlib/metrics/pesq_c/pesqmain.c +610 -0
  61. neverlib/metrics/pesq_c/pesqmod.c +1417 -0
  62. neverlib/metrics/pesq_c/pesqpar.h +297 -0
  63. neverlib/metrics/snr.py +5 -1
  64. neverlib/metrics/spec.py +31 -21
  65. neverlib/metrics/test_pesq.py +0 -4
  66. neverlib/tests/test_imports.py +17 -0
  67. neverlib/utils/__init__.py +26 -15
  68. neverlib/utils/audio_split.py +5 -1
  69. neverlib/utils/checkGPU.py +17 -9
  70. neverlib/utils/lazy_expose.py +29 -0
  71. neverlib/utils/utils.py +40 -12
  72. neverlib/vad/__init__.py +33 -25
  73. neverlib/vad/class_get_speech.py +1 -1
  74. neverlib/vad/class_vad.py +3 -3
  75. neverlib/vad/img.png +0 -0
  76. {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/METADATA +20 -17
  77. {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/RECORD +80 -37
  78. {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/WHEEL +0 -0
  79. {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/licenses/LICENSE +0 -0
  80. {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,553 @@
1
+ /*****************************************************************************
2
+
3
+ Perceptual Evaluation of Speech Quality (PESQ)
4
+ ITU-T Recommendation P.862.
5
+ Version 1.2 - 2 August 2002.
6
+
7
+ ****************************************
8
+ PESQ Intellectual Property Rights Notice
9
+ ****************************************
10
+
11
+ DEFINITIONS:
12
+ ------------
13
+ For the purposes of this Intellectual Property Rights Notice
14
+ the terms �Perceptual Evaluation of Speech Quality Algorithm�
15
+ and �PESQ Algorithm� refer to the objective speech quality
16
+ measurement algorithm defined in ITU-T Recommendation P.862;
17
+ the term �PESQ Software� refers to the C-code component of P.862.
18
+
19
+ NOTICE:
20
+ -------
21
+ All copyright, trade marks, trade names, patents, know-how and
22
+ all or any other intellectual rights subsisting in or used in
23
+ connection with including all algorithms, documents and manuals
24
+ relating to the PESQ Algorithm and or PESQ Software are and remain
25
+ the sole property in law, ownership, regulations, treaties and
26
+ patent rights of the Owners identified below. The user may not
27
+ dispute or question the ownership of the PESQ Algorithm and
28
+ or PESQ Software.
29
+
30
+ OWNERS ARE:
31
+ -----------
32
+
33
+ 1. British Telecommunications plc (BT), all rights assigned
34
+ to Psytechnics Limited
35
+ 2. Royal KPN NV, all rights assigned to OPTICOM GmbH
36
+
37
+ RESTRICTIONS:
38
+ -------------
39
+
40
+ The user cannot:
41
+
42
+ 1. alter, duplicate, modify, adapt, or translate in whole or in
43
+ part any aspect of the PESQ Algorithm and or PESQ Software
44
+ 2. sell, hire, loan, distribute, dispose or put to any commercial
45
+ use other than those permitted below in whole or in part any
46
+ aspect of the PESQ Algorithm and or PESQ Software
47
+
48
+ PERMITTED USE:
49
+ --------------
50
+
51
+ The user may:
52
+
53
+ 1. Use the PESQ Software to:
54
+ i) understand the PESQ Algorithm; or
55
+ ii) evaluate the ability of the PESQ Algorithm to perform
56
+ its intended function of predicting the speech quality
57
+ of a system; or
58
+ iii) evaluate the computational complexity of the PESQ Algorithm,
59
+ with the limitation that none of said evaluations or its
60
+ results shall be used for external commercial use.
61
+
62
+ 2. Use the PESQ Software to test if an implementation of the PESQ
63
+ Algorithm conforms to ITU-T Recommendation P.862.
64
+
65
+ 3. With the prior written permission of both Psytechnics Limited
66
+ and OPTICOM GmbH, use the PESQ Software in accordance with the
67
+ above Restrictions to perform work that meets all of the following
68
+ criteria:
69
+ i) the work must contribute directly to the maintenance of an
70
+ existing ITU recommendation or the development of a new ITU
71
+ recommendation under an approved ITU Study Item; and
72
+ ii) the work and its results must be fully described in a
73
+ written contribution to the ITU that is presented at a formal
74
+ ITU meeting within one year of the start of the work; and
75
+ iii) neither the work nor its results shall be put to any
76
+ commercial use other than making said contribution to the ITU.
77
+ Said permission will be provided on a case-by-case basis.
78
+
79
+
80
+ ANY OTHER USE OR APPLICATION OF THE PESQ SOFTWARE AND/OR THE PESQ
81
+ ALGORITHM WILL REQUIRE A PESQ LICENCE AGREEMENT, WHICH MAY BE OBTAINED
82
+ FROM EITHER OPTICOM GMBH OR PSYTECHNICS LIMITED.
83
+
84
+ EACH COMPANY OFFERS OEM LICENSE AGREEMENTS, WHICH COMBINE OEM
85
+ IMPLEMENTATIONS OF THE PESQ ALGORITHM TOGETHER WITH A PESQ PATENT LICENSE
86
+ AGREEMENT. PESQ PATENT-ONLY LICENSE AGREEMENTS MAY BE OBTAINED FROM OPTICOM.
87
+
88
+
89
+ ***********************************************************************
90
+ * OPTICOM GmbH * Psytechnics Limited *
91
+ * Am Weichselgarten 7, * Fraser House, 23 Museum Street, *
92
+ * D- 91058 Erlangen, Germany * Ipswich IP1 1HN, England *
93
+ * Phone: +49 (0) 9131 691 160 * Phone: +44 (0) 1473 261 800 *
94
+ * Fax: +49 (0) 9131 691 325 * Fax: +44 (0) 1473 261 880 *
95
+ * E-mail: info@opticom.de, * E-mail: info@psytechnics.com, *
96
+ * www.opticom.de * www.psytechnics.com *
97
+ ***********************************************************************
98
+
99
+ Further information is also available from www.pesq.org
100
+
101
+ *****************************************************************************/
102
+
103
+ #include <math.h>
104
+ #include <stdio.h>
105
+ #include <stdlib.h>
106
+ #include <limits.h>
107
+ #include "dsp.h"
108
+
109
+ #ifndef TWOPI
110
+ #define TWOPI 6.283185307179586f
111
+ #endif
112
+
113
+ unsigned long FFTSwapInitialised = 0;
114
+ unsigned long FFTLog2N;
115
+ unsigned long * FFTButter;
116
+ unsigned long * FFTBitSwap;
117
+ float * FFTPhi;
118
+
119
+ long total_malloced = 0;
120
+
121
+ void *safe_malloc (unsigned long size) {
122
+ void *result;
123
+ total_malloced += size;
124
+ result = malloc (size);
125
+ if (result == NULL) {
126
+ printf ("malloc failed!\n");
127
+ }
128
+ return result;
129
+ }
130
+
131
+ void safe_free (void *p) {
132
+ free (p);
133
+ }
134
+
135
+
136
+ unsigned long nextpow2(unsigned long X)
137
+ {
138
+ unsigned long C = 1;
139
+ while( (C < ULONG_MAX) && (C < X) )
140
+ C <<= 1;
141
+
142
+ return C;
143
+ }
144
+
145
+ int ispow2(unsigned long X)
146
+ {
147
+ unsigned long C = 1;
148
+ while( (C < ULONG_MAX) && (C < X) )
149
+ C <<= 1;
150
+
151
+ return (C == X);
152
+ }
153
+
154
+ int intlog2(unsigned long X)
155
+ {
156
+ return (int)floor( log( 1.0 * X ) / log( 2.0 ) + 0.5 );
157
+ }
158
+
159
+ void FFTInit(unsigned long N)
160
+ {
161
+ unsigned long C, L, K;
162
+ float Theta;
163
+ float * PFFTPhi;
164
+
165
+ if( (FFTSwapInitialised != N) && (FFTSwapInitialised != 0) )
166
+ FFTFree();
167
+
168
+ if( FFTSwapInitialised == N )
169
+ {
170
+ return;
171
+ }
172
+ else
173
+ {
174
+ C = N;
175
+ for( FFTLog2N = 0; C > 1; C >>= 1 )
176
+ FFTLog2N++;
177
+
178
+ C = 1;
179
+ C <<= FFTLog2N;
180
+ if( N == C )
181
+ FFTSwapInitialised = N;
182
+
183
+ FFTButter = (unsigned long *) safe_malloc( sizeof(unsigned long) * (N >> 1) );
184
+ FFTBitSwap = (unsigned long *) safe_malloc( sizeof(unsigned long) * N );
185
+ FFTPhi = (float *) safe_malloc( 2 * sizeof(float) * (N >> 1) );
186
+
187
+ PFFTPhi = FFTPhi;
188
+ for( C = 0; C < (N >> 1); C++ )
189
+ {
190
+ Theta = (TWOPI * C) / N;
191
+ (*(PFFTPhi++)) = (float) cos( Theta );
192
+ (*(PFFTPhi++)) = (float) sin( Theta );
193
+ }
194
+
195
+ FFTButter[0] = 0;
196
+ L = 1;
197
+ K = N >> 2;
198
+ while( K >= 1 )
199
+ {
200
+ for( C = 0; C < L; C++ )
201
+ FFTButter[C+L] = FFTButter[C] + K;
202
+ L <<= 1;
203
+ K >>= 1;
204
+ }
205
+ }
206
+ }
207
+
208
+ void FFTFree(void)
209
+ {
210
+ if( FFTSwapInitialised != 0 )
211
+ {
212
+ safe_free( FFTButter );
213
+ safe_free( FFTBitSwap );
214
+ safe_free( FFTPhi );
215
+ FFTSwapInitialised = 0;
216
+ }
217
+ }
218
+
219
+ void FFT(float * x, unsigned long N)
220
+ {
221
+ unsigned long Cycle, C, S, NC;
222
+ unsigned long Step = N >> 1;
223
+ unsigned long K1, K2;
224
+ register float R1, I1, R2, I2;
225
+ float ReFFTPhi, ImFFTPhi;
226
+
227
+ if( N > 1 )
228
+ {
229
+ FFTInit( N );
230
+
231
+ for( Cycle = 1; Cycle < N; Cycle <<= 1, Step >>= 1 )
232
+ {
233
+ K1 = 0;
234
+ K2 = Step << 1;
235
+
236
+ for( C = 0; C < Cycle; C++ )
237
+ {
238
+ NC = FFTButter[C] << 1;
239
+ ReFFTPhi = FFTPhi[NC];
240
+ ImFFTPhi = FFTPhi[NC+1];
241
+ for( S = 0; S < Step; S++ )
242
+ {
243
+ R1 = x[K1];
244
+ I1 = x[K1+1];
245
+ R2 = x[K2];
246
+ I2 = x[K2+1];
247
+
248
+ x[K1++] = R1 + ReFFTPhi * R2 + ImFFTPhi * I2;
249
+ x[K1++] = I1 - ImFFTPhi * R2 + ReFFTPhi * I2;
250
+ x[K2++] = R1 - ReFFTPhi * R2 - ImFFTPhi * I2;
251
+ x[K2++] = I1 + ImFFTPhi * R2 - ReFFTPhi * I2;
252
+ }
253
+ K1 = K2;
254
+ K2 = K1 + (Step << 1);
255
+ }
256
+ }
257
+
258
+ NC = N >> 1;
259
+ for( C = 0; C < NC; C++ )
260
+ {
261
+ FFTBitSwap[C] = FFTButter[C] << 1;
262
+ FFTBitSwap[C+NC] = 1 + FFTBitSwap[C];
263
+ }
264
+ for( C = 0; C < N; C++ )
265
+ if( (S = FFTBitSwap[C]) != C )
266
+ {
267
+ FFTBitSwap[S] = S;
268
+ K1 = C << 1;
269
+ K2 = S << 1;
270
+ R1 = x[K1];
271
+ x[K1++] = x[K2];
272
+ x[K2++] = R1;
273
+ R1 = x[K1];
274
+ x[K1] = x[K2];
275
+ x[K2] = R1;
276
+ }
277
+ }
278
+ }
279
+
280
+ void IFFT(float * x, unsigned long N)
281
+ {
282
+ unsigned long Cycle, C, S, NC;
283
+ unsigned long Step = N >> 1;
284
+ unsigned long K1, K2;
285
+ register float R1, I1, R2, I2;
286
+ float ReFFTPhi, ImFFTPhi;
287
+
288
+ if( N > 1 )
289
+ {
290
+ FFTInit( N );
291
+
292
+ for( Cycle = 1; Cycle < N; Cycle <<= 1, Step >>= 1 )
293
+ {
294
+ K1 = 0;
295
+ K2 = Step << 1;
296
+
297
+ for( C = 0; C < Cycle; C++ )
298
+ {
299
+ NC = FFTButter[C] << 1;
300
+ ReFFTPhi = FFTPhi[NC];
301
+ ImFFTPhi = FFTPhi[NC+1];
302
+ for( S = 0; S < Step; S++ )
303
+ {
304
+ R1 = x[K1];
305
+ I1 = x[K1+1];
306
+ R2 = x[K2];
307
+ I2 = x[K2+1];
308
+
309
+ x[K1++] = R1 + ReFFTPhi * R2 - ImFFTPhi * I2;
310
+ x[K1++] = I1 + ImFFTPhi * R2 + ReFFTPhi * I2;
311
+ x[K2++] = R1 - ReFFTPhi * R2 + ImFFTPhi * I2;
312
+ x[K2++] = I1 - ImFFTPhi * R2 - ReFFTPhi * I2;
313
+ }
314
+ K1 = K2;
315
+ K2 = K1 + (Step << 1);
316
+ }
317
+ }
318
+
319
+ NC = N >> 1;
320
+ for( C = 0; C < NC; C++ )
321
+ {
322
+ FFTBitSwap[C] = FFTButter[C] << 1;
323
+ FFTBitSwap[C+NC] = 1 + FFTBitSwap[C];
324
+ }
325
+ for( C = 0; C < N; C++ )
326
+ if( (S = FFTBitSwap[C]) != C )
327
+ {
328
+ FFTBitSwap[S] = S;
329
+ K1 = C << 1;
330
+ K2 = S << 1;
331
+ R1 = x[K1];
332
+ x[K1++] = x[K2];
333
+ x[K2++] = R1;
334
+ R1 = x[K1];
335
+ x[K1] = x[K2];
336
+ x[K2] = R1;
337
+ }
338
+
339
+ NC = N << 1;
340
+ for( C = 0; C < NC; )
341
+ x[C++] /= N;
342
+ }
343
+ }
344
+
345
+ void RealFFT(float *x, unsigned long N)
346
+ {
347
+ float *y;
348
+ unsigned long i;
349
+
350
+ y = (float *) safe_malloc (2 * N * sizeof (float));
351
+
352
+ for (i = 0; i < N; i++) {
353
+ y [2 * i] = x [i];
354
+ y [2 * i + 1] = 0.0f;
355
+ }
356
+
357
+ FFT (y, N);
358
+
359
+ for (i = 0; i <= N / 2; i++) {
360
+ x [2 * i] = y [2 * i];
361
+ x [2 * i + 1] = y [2 * i + 1];
362
+ }
363
+
364
+ safe_free (y);
365
+ }
366
+
367
+ void RealIFFT(float *x, unsigned long N)
368
+ {
369
+
370
+ float *y;
371
+ unsigned long i;
372
+
373
+ y = (float *) safe_malloc (2 * N * sizeof (float));
374
+
375
+ for (i = 0; i <= N / 2; i++) {
376
+ y [2 * i] = x [2 * i];
377
+ y [2 * i + 1] = x [2 * i + 1];
378
+ }
379
+ for (i = N / 2 + 1; i < N; i++) {
380
+ int j = N - i;
381
+ y [2 * i] = x [2 * j];
382
+ y [2 * i + 1] = -x [2 * j + 1];
383
+ }
384
+
385
+ IFFT (y, N);
386
+
387
+ for (i = 0; i < N; i++) {
388
+ x [i] = y [2 * i];
389
+ }
390
+
391
+ safe_free (y);
392
+ }
393
+
394
+ unsigned long FFTNXCorr(
395
+ float * x1, unsigned long n1,
396
+ float * x2, unsigned long n2,
397
+ float * y )
398
+ {
399
+ register float r1, i1;
400
+ float * tmp1;
401
+ float * tmp2;
402
+ long C, D, Nx, Ny;
403
+
404
+ Nx = nextpow2( max(n1, n2) );
405
+ tmp1 = (float *) safe_malloc(sizeof(float) * (2 * Nx + 2));
406
+ tmp2 = (float *) safe_malloc(sizeof(float) * (2 * Nx + 2));
407
+
408
+ for( C = n1 - 1; C >= 0; C-- )
409
+ {
410
+ tmp1[C] = *(x1++);
411
+ }
412
+ for( C = n1; C < 2 * Nx; C++ )
413
+ tmp1[C] = 0.0;
414
+
415
+ RealFFT( tmp1, 2*Nx );
416
+
417
+ for( C = 0; C < (long) n2; C++ )
418
+ {
419
+ tmp2[C] = x2[C];
420
+ }
421
+ for( C = n2; C < 2 * Nx; C++ )
422
+ tmp2[C] = 0.0;
423
+
424
+ RealFFT( tmp2, 2*Nx );
425
+
426
+ for( C = 0; C <= Nx; C++ )
427
+ {
428
+ D = C << 1; r1 = tmp1[D]; i1 = tmp1[1 + D];
429
+ tmp1[D] = r1 * tmp2[D] - i1 * tmp2[1 + D];
430
+ tmp1[1 + D] = r1 * tmp2[1 + D] + i1 * tmp2[D];
431
+ }
432
+
433
+ RealIFFT( tmp1, 2*Nx );
434
+ Ny = n1 + n2 - 1;
435
+ for( C = 0; C < Ny; C++ )
436
+ y[C] = tmp1[C];
437
+
438
+ safe_free( tmp1 );
439
+ safe_free( tmp2 );
440
+
441
+ return Ny;
442
+ }
443
+
444
+ void IIRsos(
445
+ float * x, unsigned long Nx,
446
+ float b0, float b1, float b2, float a1, float a2,
447
+ float * tz1, float * tz2 )
448
+ {
449
+ register float z0;
450
+ register float z1;
451
+ register float z2;
452
+
453
+ if( tz1 == NULL ) z1 = 0.0f; else z1 = *tz1;
454
+ if( tz2 == NULL ) z2 = 0.0f; else z2 = *tz2;
455
+
456
+ if( (a1 != 0.0f) || (a2 != 0.0f) )
457
+ {
458
+ if( (b1 != 0.0f) || (b2 != 0.0f) )
459
+ {
460
+ while( (Nx) > 0 )
461
+ {
462
+ Nx--;
463
+ z0 = (*x) - a1 * z1 - a2 * z2;
464
+ *(x++) = b0 * z0 + b1 * z1 + b2 * z2;
465
+ z2 = z1;
466
+ z1 = z0;
467
+ }
468
+ }
469
+ else
470
+ {
471
+ if( b0 != 1.0f )
472
+ {
473
+ while( (Nx) > 0 )
474
+ {
475
+ Nx--;
476
+ z0 = (*x) - a1 * z1 - a2 * z2;
477
+ *(x++) = b0 * z0;
478
+ z2 = z1;
479
+ z1 = z0;
480
+ }
481
+ }
482
+ else
483
+ {
484
+ while( (Nx) > 0 )
485
+ {
486
+ Nx--;
487
+ z0 = (*x) - a1 * z1 - a2 * z2;
488
+ *(x++) = z0;
489
+ z2 = z1;
490
+ z1 = z0;
491
+ }
492
+ }
493
+ }
494
+ }
495
+ else
496
+ {
497
+ if( (b1 != 0.0f) || (b2 != 0.0f) )
498
+ {
499
+ while( (Nx) > 0 )
500
+ {
501
+ Nx--;
502
+ z0 = (*x);
503
+ *(x++) = b0 * z0 + b1 * z1 + b2 * z2;
504
+ z2 = z1;
505
+ z1 = z0;
506
+ }
507
+ }
508
+ else
509
+ {
510
+ if( b0 != 1.0f )
511
+ {
512
+ while( (Nx) > 0 )
513
+ {
514
+ Nx--;
515
+ *x = b0 * (*x);
516
+ x++;
517
+ }
518
+ }
519
+ }
520
+ }
521
+
522
+ if( tz1 != NULL ) (*tz1) = z1;
523
+ if( tz2 != NULL ) (*tz2) = z2;
524
+ }
525
+
526
+ void IIRFilt(
527
+ float * h, unsigned long Nsos, float * z,
528
+ float * x, unsigned long Nx, float * y )
529
+ {
530
+ unsigned long C;
531
+
532
+ if( y == NULL )
533
+ y = x;
534
+ else
535
+ {
536
+ for( C = 0; C < Nx; C++ )
537
+ y[C] = x[C];
538
+ }
539
+
540
+
541
+ for( C = 0; C < Nsos; C++ )
542
+ {
543
+ if( z != NULL )
544
+ {
545
+ IIRsos( y, Nx, h[0], h[1], h[2], h[3], h[4], z, z+1 );
546
+ z += 2;
547
+ }
548
+ else
549
+ IIRsos( y, Nx, h[0], h[1], h[2], h[3], h[4], NULL, NULL );
550
+ h += 5;
551
+ }
552
+ }
553
+ /* END OF FILE */
@@ -0,0 +1,138 @@
1
+ /*****************************************************************************
2
+
3
+ Perceptual Evaluation of Speech Quality (PESQ)
4
+ ITU-T Recommendation P.862.
5
+ Version 1.2 - 2 August 2002.
6
+
7
+ ****************************************
8
+ PESQ Intellectual Property Rights Notice
9
+ ****************************************
10
+
11
+ DEFINITIONS:
12
+ ------------
13
+ For the purposes of this Intellectual Property Rights Notice
14
+ the terms �Perceptual Evaluation of Speech Quality Algorithm�
15
+ and �PESQ Algorithm� refer to the objective speech quality
16
+ measurement algorithm defined in ITU-T Recommendation P.862;
17
+ the term �PESQ Software� refers to the C-code component of P.862.
18
+
19
+ NOTICE:
20
+ -------
21
+ All copyright, trade marks, trade names, patents, know-how and
22
+ all or any other intellectual rights subsisting in or used in
23
+ connection with including all algorithms, documents and manuals
24
+ relating to the PESQ Algorithm and or PESQ Software are and remain
25
+ the sole property in law, ownership, regulations, treaties and
26
+ patent rights of the Owners identified below. The user may not
27
+ dispute or question the ownership of the PESQ Algorithm and
28
+ or PESQ Software.
29
+
30
+ OWNERS ARE:
31
+ -----------
32
+
33
+ 1. British Telecommunications plc (BT), all rights assigned
34
+ to Psytechnics Limited
35
+ 2. Royal KPN NV, all rights assigned to OPTICOM GmbH
36
+
37
+ RESTRICTIONS:
38
+ -------------
39
+
40
+ The user cannot:
41
+
42
+ 1. alter, duplicate, modify, adapt, or translate in whole or in
43
+ part any aspect of the PESQ Algorithm and or PESQ Software
44
+ 2. sell, hire, loan, distribute, dispose or put to any commercial
45
+ use other than those permitted below in whole or in part any
46
+ aspect of the PESQ Algorithm and or PESQ Software
47
+
48
+ PERMITTED USE:
49
+ --------------
50
+
51
+ The user may:
52
+
53
+ 1. Use the PESQ Software to:
54
+ i) understand the PESQ Algorithm; or
55
+ ii) evaluate the ability of the PESQ Algorithm to perform
56
+ its intended function of predicting the speech quality
57
+ of a system; or
58
+ iii) evaluate the computational complexity of the PESQ Algorithm,
59
+ with the limitation that none of said evaluations or its
60
+ results shall be used for external commercial use.
61
+
62
+ 2. Use the PESQ Software to test if an implementation of the PESQ
63
+ Algorithm conforms to ITU-T Recommendation P.862.
64
+
65
+ 3. With the prior written permission of both Psytechnics Limited
66
+ and OPTICOM GmbH, use the PESQ Software in accordance with the
67
+ above Restrictions to perform work that meets all of the following
68
+ criteria:
69
+ i) the work must contribute directly to the maintenance of an
70
+ existing ITU recommendation or the development of a new ITU
71
+ recommendation under an approved ITU Study Item; and
72
+ ii) the work and its results must be fully described in a
73
+ written contribution to the ITU that is presented at a formal
74
+ ITU meeting within one year of the start of the work; and
75
+ iii) neither the work nor its results shall be put to any
76
+ commercial use other than making said contribution to the ITU.
77
+ Said permission will be provided on a case-by-case basis.
78
+
79
+
80
+ ANY OTHER USE OR APPLICATION OF THE PESQ SOFTWARE AND/OR THE PESQ
81
+ ALGORITHM WILL REQUIRE A PESQ LICENCE AGREEMENT, WHICH MAY BE OBTAINED
82
+ FROM EITHER OPTICOM GMBH OR PSYTECHNICS LIMITED.
83
+
84
+ EACH COMPANY OFFERS OEM LICENSE AGREEMENTS, WHICH COMBINE OEM
85
+ IMPLEMENTATIONS OF THE PESQ ALGORITHM TOGETHER WITH A PESQ PATENT LICENSE
86
+ AGREEMENT. PESQ PATENT-ONLY LICENSE AGREEMENTS MAY BE OBTAINED FROM OPTICOM.
87
+
88
+
89
+ ***********************************************************************
90
+ * OPTICOM GmbH * Psytechnics Limited *
91
+ * Am Weichselgarten 7, * Fraser House, 23 Museum Street, *
92
+ * D- 91058 Erlangen, Germany * Ipswich IP1 1HN, England *
93
+ * Phone: +49 (0) 9131 691 160 * Phone: +44 (0) 1473 261 800 *
94
+ * Fax: +49 (0) 9131 691 325 * Fax: +44 (0) 1473 261 880 *
95
+ * E-mail: info@opticom.de, * E-mail: info@psytechnics.com, *
96
+ * www.opticom.de * www.psytechnics.com *
97
+ ***********************************************************************
98
+
99
+ Further information is also available from www.pesq.org
100
+
101
+ *****************************************************************************/
102
+
103
+ #ifndef min
104
+ #define min(a,b) (((a) < (b)) ? (a) : (b))
105
+ #endif
106
+
107
+ #ifndef max
108
+ #define max(a,b) (((a) > (b)) ? (a) : (b))
109
+ #endif
110
+
111
+ #ifndef DSP_INCLUDED
112
+ #define DSP_INCLUDED
113
+ void *safe_malloc (unsigned long);
114
+ void safe_free (void *);
115
+
116
+ void IIRFilt(
117
+ float * h, unsigned long Nsos, float * z,
118
+ float * x, unsigned long Nx, float * y );
119
+
120
+ unsigned long nextpow2(unsigned long X);
121
+ int ispow2(unsigned long X);
122
+ int intlog2(unsigned long X);
123
+ void FFTInit(unsigned long N);
124
+ void FFTFree(void);
125
+ void RealFFT(float * x, unsigned long N);
126
+ void RealIFFT(float * x, unsigned long N);
127
+ unsigned long FFTNXCorr(
128
+ float * x1, unsigned long n1, float * x2, unsigned long n2, float * y );
129
+ void IIRsos(
130
+ float * x, unsigned long Nx,
131
+ float b0, float b1, float b2, float a1, float a2,
132
+ float * tz1, float * tz2 );
133
+ void IIRFilt(
134
+ float * h, unsigned long Nsos, float * z,
135
+ float * x, unsigned long Nx, float * y );
136
+ #endif
137
+
138
+ /* END OF FILE */