-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsoundtouch.patch
More file actions
125 lines (115 loc) · 4.16 KB
/
Copy pathsoundtouch.patch
File metadata and controls
125 lines (115 loc) · 4.16 KB
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
diff --git a/source/SoundTouch/SoundTouch.cpp b/source/SoundTouch/SoundTouch.cpp
index 1618884..d1a59f7 100644
--- a/source/SoundTouch/SoundTouch.cpp
+++ b/source/SoundTouch/SoundTouch.cpp
@@ -227,24 +227,7 @@ void SoundTouch::calcEffectiveRateAndTempo()
if (!TEST_FLOAT_EQUAL(tempo, oldTempo)) pTDStretch->setTempo(tempo);
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
- if (rate <= 1.0f)
- {
- if (output != pTDStretch)
- {
- FIFOSamplePipe *tempoOut;
-
- assert(output == pRateTransposer);
- // move samples in the current output buffer to the output of pTDStretch
- tempoOut = pTDStretch->getOutput();
- tempoOut->moveSamples(*output);
- // move samples in pitch transposer's store buffer to tempo changer's input
- // deprecated : pTDStretch->moveSamples(*pRateTransposer->getStore());
-
- output = pTDStretch;
- }
- }
- else
-#endif
+ if (rate > 1.0f)
{
if (output != pRateTransposer)
{
@@ -260,6 +243,23 @@ void SoundTouch::calcEffectiveRateAndTempo()
output = pRateTransposer;
}
}
+ else
+#endif
+ {
+ if (output != pTDStretch)
+ {
+ FIFOSamplePipe *tempoOut;
+
+ assert(output == pRateTransposer);
+ // move samples in the current output buffer to the output of pTDStretch
+ tempoOut = pTDStretch->getOutput();
+ tempoOut->moveSamples(*output);
+ // move samples in pitch transposer's store buffer to tempo changer's input
+ // deprecated : pTDStretch->moveSamples(*pRateTransposer->getStore());
+
+ output = pTDStretch;
+ }
+ }
}
@@ -290,21 +290,21 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
samplesExpectedOut += (double)nSamples / ((double)rate * (double)tempo);
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
- if (rate <= 1.0f)
- {
- // transpose the rate down, output the transposed sound to tempo changer buffer
- assert(output == pTDStretch);
- pRateTransposer->putSamples(samples, nSamples);
- pTDStretch->moveSamples(*pRateTransposer);
- }
- else
-#endif
+ if (rate > 1.0f)
{
// evaluate the tempo changer, then transpose the rate up,
assert(output == pRateTransposer);
pTDStretch->putSamples(samples, nSamples);
pRateTransposer->moveSamples(*pTDStretch);
}
+ else
+#endif
+ {
+ // transpose the rate down, output the transposed sound to tempo changer buffer
+ assert(output == pTDStretch);
+ pRateTransposer->putSamples(samples, nSamples);
+ pTDStretch->moveSamples(*pRateTransposer);
+ }
}
@@ -429,13 +429,16 @@ int SoundTouch::getSetting(int settingId) const
int size = pTDStretch->getInputSampleReq();
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
- if (rate <= 1.0)
+ if (rate > 1.0)
+ {
+ return size;
+ }
+ else
+#endif
{
// transposing done before timestretch, which impacts latency
return (int)(size * rate + 0.5);
}
-#endif
- return size;
}
case SETTING_NOMINAL_OUTPUT_SEQUENCE :
@@ -456,15 +459,15 @@ int SoundTouch::getSetting(int settingId) const
int latency_tr = pRateTransposer->getLatency();
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
- if (rate <= 1.0)
+ if (rate > 1.0)
{
- // transposing done before timestretch, which impacts latency
- latency = (latency + latency_tr) * rate;
+ latency += (double)latency_tr / rate;
}
else
#endif
{
- latency += (double)latency_tr / rate;
+ // transposing done before timestretch, which impacts latency
+ latency = (latency + latency_tr) * rate;
}
return (int)(latency + 0.5);