This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmoz-libsoundtouch.patch
536 lines (439 loc) · 15.4 KB
/
moz-libsoundtouch.patch
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
--- /src/cpu_detect_x86.cpp
+++ /src/cpu_detect_x86.cpp
@@ -43,18 +43,23 @@
#include "STTypes.h"
#if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
-
- #if defined(__GNUC__) && defined(__i386__)
- // gcc
+ #if defined(__GNUC__) && defined (HAVE_CPUID_H)
+ // gcc and clang
#include "cpuid.h"
#elif defined(_M_IX86)
// windows non-gcc
#include <intrin.h>
- #define bit_MMX (1 << 23)
- #define bit_SSE (1 << 25)
- #define bit_SSE2 (1 << 26)
#endif
-
+ // If we still don't have the macros, define them (Windows, MacOS)
+ #ifndef bit_MMX
+ #define bit_MMX (1 << 23)
+ #endif
+ #ifndef bit_SSE
+ #define bit_SSE (1 << 25)
+ #endif
+ #ifndef bit_SSE2
+ #define bit_SSE2 (1 << 26)
+ #endif
#endif
@@ -101,18 +106,7 @@
uint res = 0;
-#if defined(__GNUC__)
- // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
- uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
-
- // Check if no cpuid support.
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
-
- if (edx & bit_MMX) res = res | SUPPORT_MMX;
- if (edx & bit_SSE) res = res | SUPPORT_SSE;
- if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
-
-#else
+#if !defined(__GNUC__)
// Window / VS version of cpuid. Notice that Visual Studio 2005 or later required
// for __cpuid intrinsic support.
int reg[4] = {-1};
@@ -125,7 +119,19 @@
if ((unsigned int)reg[3] & bit_MMX) res = res | SUPPORT_MMX;
if ((unsigned int)reg[3] & bit_SSE) res = res | SUPPORT_SSE;
if ((unsigned int)reg[3] & bit_SSE2) res = res | SUPPORT_SSE2;
+#elif defined(HAVE_CPUID_H)
+ // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
+ uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
+
+ // Check if no cpuid support.
+ if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
+ if (edx & bit_MMX) res = res | SUPPORT_MMX;
+ if (edx & bit_SSE) res = res | SUPPORT_SSE;
+ if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
+#else
+ // Compatible with GCC but no cpuid.h.
+ return 0;
#endif
return res & ~_dwDisabledISA;
--- /src/STTypes.h 2012-08-02 10:04:06.301691592 -0700
+++ /src/STTypes.h
@@ -42,21 +42,13 @@
typedef unsigned int uint;
typedef unsigned long ulong;
-#ifdef __GNUC__
- // In GCC, include soundtouch_config.h made by config scritps
- #include "soundtouch_config.h"
-#endif
-
-#ifndef _WINDEF_
- // if these aren't defined already by Windows headers, define now
-
- typedef int BOOL;
-
- #define FALSE 0
- #define TRUE 1
-
-#endif // _WINDEF_
+#include "soundtouch_config.h"
+#ifdef WIN32
+#define EXPORT __declspec(dllexport)
+#else
+#define EXPORT
+#endif
namespace soundtouch
{
@@ -82,7 +74,7 @@
/// also in GNU environment, then please #undef the INTEGER_SAMPLE
/// and FLOAT_SAMPLE defines first as in comments above.
//#define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples
- #define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples
+ #define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples
#endif
@@ -144,10 +136,10 @@
#endif // SOUNDTOUCH_INTEGER_SAMPLES
-};
+}
// define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
-// #define ST_NO_EXCEPTION_HANDLING 1
+#define ST_NO_EXCEPTION_HANDLING 1
#ifdef ST_NO_EXCEPTION_HANDLING
// Exceptions disabled. Throw asserts instead if enabled.
#include <assert.h>
--- /src/SoundTouch.h 2012-08-02 10:04:06.301691592 -0700
+++ /src/SoundTouch.h
@@ -141,7 +141,7 @@
/// tempo/pitch/rate/samplerate settings.
#define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
-class SoundTouch : public FIFOProcessor
+class EXPORT SoundTouch : public FIFOProcessor
{
private:
/// Rate transposer class instance
@@ -160,7 +160,7 @@
float virtualPitch;
/// Flag: Has sample rate been set?
- BOOL bSrateSet;
+ bool bSrateSet;
/// Calculates effective rate & tempo valuescfrom 'virtualRate', 'virtualTempo' and
/// 'virtualPitch' parameters.
@@ -247,8 +247,8 @@
/// Changes a setting controlling the processing system behaviour. See the
/// 'SETTING_...' defines for available setting ID's.
///
- /// \return 'TRUE' if the setting was succesfully changed
- BOOL setSetting(int settingId, ///< Setting ID number. see SETTING_... defines.
+ /// \return 'true' if the setting was succesfully changed
+ bool setSetting(int settingId, ///< Setting ID number. see SETTING_... defines.
int value ///< New setting value.
);
--- /src/RateTransposer.cpp
+++ /src/RateTransposer.cpp
@@ -120,17 +120,17 @@ RateTransposer *RateTransposer::newInsta
#endif
}
// Constructor
RateTransposer::RateTransposer() : FIFOProcessor(&outputBuffer)
{
numChannels = 2;
- bUseAAFilter = TRUE;
+ bUseAAFilter = true;
fRate = 0;
// Instantiates the anti-alias filter with default tap length
// of 32
pAAFilter = new AAFilter(32);
}
@@ -138,24 +138,24 @@ RateTransposer::RateTransposer() : FIFOP
RateTransposer::~RateTransposer()
{
delete pAAFilter;
}
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
-void RateTransposer::enableAAFilter(BOOL newMode)
+void RateTransposer::enableAAFilter(bool newMode)
{
bUseAAFilter = newMode;
}
/// Returns nonzero if anti-alias filter is enabled.
-BOOL RateTransposer::isAAFilterEnabled() const
+bool RateTransposer::isAAFilterEnabled() const
{
return bUseAAFilter;
}
AAFilter *RateTransposer::getAAFilter()
{
return pAAFilter;
@@ -281,17 +281,17 @@ void RateTransposer::processSamples(cons
uint count;
uint sizeReq;
if (nSamples == 0) return;
assert(pAAFilter);
// If anti-alias filter is turned off, simply transpose without applying
// the filter
- if (bUseAAFilter == FALSE)
+ if (bUseAAFilter == false)
{
sizeReq = (uint)((float)nSamples / fRate + 1.0f);
count = transpose(outputBuffer.ptrEnd(sizeReq), src, nSamples);
outputBuffer.putSamples(count);
return;
}
// Transpose with anti-alias filter
--- /src/RateTransposer.h
+++ /src/RateTransposer.h
@@ -76,17 +76,17 @@ protected:
FIFOSampleBuffer storeBuffer;
/// Buffer for keeping samples between transposing & anti-alias filter
FIFOSampleBuffer tempBuffer;
/// Output sample buffer
FIFOSampleBuffer outputBuffer;
- BOOL bUseAAFilter;
+ bool bUseAAFilter;
virtual void resetRegisters() = 0;
virtual uint transposeStereo(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples) = 0;
virtual uint transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
@@ -126,20 +126,20 @@ public:
/// Returns the store buffer object
FIFOSamplePipe *getStore() { return &storeBuffer; };
/// Return anti-alias filter object
AAFilter *getAAFilter();
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
- void enableAAFilter(BOOL newMode);
+ void enableAAFilter(bool newMode);
/// Returns nonzero if anti-alias filter is enabled.
- BOOL isAAFilterEnabled() const;
+ bool isAAFilterEnabled() const;
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
/// rate, larger faster rates.
virtual void setRate(float newRate);
/// Sets the number of channels, 1 = mono, 2 = stereo
void setChannels(int channels);
--- /src/SoundTouch.cpp
+++ /src/SoundTouch.cpp
@@ -106,17 +106,17 @@ SoundTouch::SoundTouch()
virtualPitch =
virtualRate =
virtualTempo = 1.0;
calcEffectiveRateAndTempo();
channels = 0;
- bSrateSet = FALSE;
+ bSrateSet = false;
}
SoundTouch::~SoundTouch()
{
delete pRateTransposer;
delete pTDStretch;
@@ -277,27 +277,27 @@ void SoundTouch::calcEffectiveRateAndTem
}
}
}
// Sets sample rate.
void SoundTouch::setSampleRate(uint srate)
{
- bSrateSet = TRUE;
+ bSrateSet = true;
// set sample rate, leave other tempo changer parameters as they are.
pTDStretch->setParameters((int)srate);
}
// Adds 'numSamples' pcs of samples from the 'samples' memory position into
// the input of the object.
void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
{
- if (bSrateSet == FALSE)
+ if (bSrateSet == false)
{
ST_THROW_RT_ERROR("SoundTouch : Sample rate not defined");
}
else if (channels == 0)
{
ST_THROW_RT_ERROR("SoundTouch : Number of channels not defined");
}
@@ -382,57 +382,57 @@ void SoundTouch::flush()
pTDStretch->clearInput();
// yet leave the 'tempoChanger' output intouched as that's where the
// flushed samples are!
}
// Changes a setting controlling the processing system behaviour. See the
// 'SETTING_...' defines for available setting ID's.
-BOOL SoundTouch::setSetting(int settingId, int value)
+bool SoundTouch::setSetting(int settingId, int value)
{
int sampleRate, sequenceMs, seekWindowMs, overlapMs;
// read current tdstretch routine parameters
pTDStretch->getParameters(&sampleRate, &sequenceMs, &seekWindowMs, &overlapMs);
switch (settingId)
{
case SETTING_USE_AA_FILTER :
// enables / disabless anti-alias filter
- pRateTransposer->enableAAFilter((value != 0) ? TRUE : FALSE);
- return TRUE;
+ pRateTransposer->enableAAFilter((value != 0) ? true : false);
+ return true;
case SETTING_AA_FILTER_LENGTH :
// sets anti-alias filter length
pRateTransposer->getAAFilter()->setLength(value);
- return TRUE;
+ return true;
case SETTING_USE_QUICKSEEK :
// enables / disables tempo routine quick seeking algorithm
- pTDStretch->enableQuickSeek((value != 0) ? TRUE : FALSE);
- return TRUE;
+ pTDStretch->enableQuickSeek((value != 0) ? true : false);
+ return true;
case SETTING_SEQUENCE_MS:
// change time-stretch sequence duration parameter
pTDStretch->setParameters(sampleRate, value, seekWindowMs, overlapMs);
- return TRUE;
+ return true;
case SETTING_SEEKWINDOW_MS:
// change time-stretch seek window length parameter
pTDStretch->setParameters(sampleRate, sequenceMs, value, overlapMs);
- return TRUE;
+ return true;
case SETTING_OVERLAP_MS:
// change time-stretch overlap length parameter
pTDStretch->setParameters(sampleRate, sequenceMs, seekWindowMs, value);
- return TRUE;
+ return true;
default :
- return FALSE;
+ return false;
}
}
// Reads a setting controlling the processing system behaviour. See the
// 'SETTING_...' defines for available setting ID's.
//
// Returns the setting value.
--- /src/TDStretch.cpp
+++ /src/TDStretch.cpp
@@ -81,25 +81,25 @@ static const short _scanOffsets[5][24]={
*
* Implementation of the class 'TDStretch'
*
*****************************************************************************/
TDStretch::TDStretch() : FIFOProcessor(&outputBuffer)
{
- bQuickSeek = FALSE;
+ bQuickSeek = false;
channels = 2;
pMidBuffer = NULL;
pMidBufferUnaligned = NULL;
overlapLength = 0;
- bAutoSeqSetting = TRUE;
- bAutoSeekSetting = TRUE;
+ bAutoSeqSetting = true;
+ bAutoSeekSetting = true;
// outDebt = 0;
skipFract = 0;
tempo = 1.0f;
setParameters(44100, DEFAULT_SEQUENCE_MS, DEFAULT_SEEKWINDOW_MS, DEFAULT_OVERLAP_MS);
setTempo(1.0f);
@@ -129,33 +129,33 @@ void TDStretch::setParameters(int aSampl
{
// accept only positive parameter values - if zero or negative, use old values instead
if (aSampleRate > 0) this->sampleRate = aSampleRate;
if (aOverlapMS > 0) this->overlapMs = aOverlapMS;
if (aSequenceMS > 0)
{
this->sequenceMs = aSequenceMS;
- bAutoSeqSetting = FALSE;
+ bAutoSeqSetting = false;
}
else if (aSequenceMS == 0)
{
// if zero, use automatic setting
- bAutoSeqSetting = TRUE;
+ bAutoSeqSetting = true;
}
if (aSeekWindowMS > 0)
{
this->seekWindowMs = aSeekWindowMS;
- bAutoSeekSetting = FALSE;
+ bAutoSeekSetting = false;
}
else if (aSeekWindowMS == 0)
{
// if zero, use automatic setting
- bAutoSeekSetting = TRUE;
+ bAutoSeekSetting = true;
}
calcSeqParameters();
calculateOverlapLength(overlapMs);
// set tempo to recalculate 'sampleReq'
setTempo(tempo);
@@ -229,24 +229,24 @@ void TDStretch::clear()
outputBuffer.clear();
clearInput();
}
// Enables/disables the quick position seeking algorithm. Zero to disable, nonzero
// to enable
-void TDStretch::enableQuickSeek(BOOL enable)
+void TDStretch::enableQuickSeek(bool enable)
{
bQuickSeek = enable;
}
// Returns nonzero if the quick seeking algorithm is enabled.
-BOOL TDStretch::isQuickSeekEnabled() const
+bool TDStretch::isQuickSeekEnabled() const
{
return bQuickSeek;
}
// Seeks for the optimal overlap-mixing position.
int TDStretch::seekBestOverlapPosition(const SAMPLETYPE *refPos)
{
--- /src/TDStretch.h
+++ /src/TDStretch.h
@@ -120,24 +120,24 @@ protected:
int seekLength;
int seekWindowLength;
int overlapDividerBits;
int slopingDivider;
float nominalSkip;
float skipFract;
FIFOSampleBuffer outputBuffer;
FIFOSampleBuffer inputBuffer;
- BOOL bQuickSeek;
+ bool bQuickSeek;
int sampleRate;
int sequenceMs;
int seekWindowMs;
int overlapMs;
- BOOL bAutoSeqSetting;
- BOOL bAutoSeekSetting;
+ bool bAutoSeqSetting;
+ bool bAutoSeekSetting;
void acceptNewOverlapLength(int newOverlapLength);
virtual void clearCrossCorrState();
void calculateOverlapLength(int overlapMs);
virtual double calcCrossCorr(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare) const;
@@ -188,20 +188,20 @@ public:
/// Clears the input buffer
void clearInput();
/// Sets the number of channels, 1 = mono, 2 = stereo
void setChannels(int numChannels);
/// Enables/disables the quick position seeking algorithm. Zero to disable,
/// nonzero to enable
- void enableQuickSeek(BOOL enable);
+ void enableQuickSeek(bool enable);
/// Returns nonzero if the quick seeking algorithm is enabled.
- BOOL isQuickSeekEnabled() const;
+ bool isQuickSeekEnabled() const;
/// Sets routine control parameters. These control are certain time constants
/// defining how the sound is stretched to the desired duration.
//
/// 'sampleRate' = sample rate of the sound
/// 'sequenceMS' = one processing sequence length in milliseconds
/// 'seekwindowMS' = seeking window length for scanning the best overlapping
/// position