141 {
142 auto previous = &rPrevious;
143 auto origDuration = duration;
145
147
148 wxASSERT(duration > 0);
149 double speed =
150 (std::abs((s1 - s0).as_long_long())) / duration.
as_double();
151 bool adjustedSpeed = false;
152
154 wxASSERT(minSpeed == options.
minSpeed);
155
156
157 if (!adjustStart && speed > options.
maxSpeed)
158 {
159
162 adjustedSpeed = true;
163 }
164 else if (!adjustStart &&
165 previous->mGoal >= 0 &&
166 previous->mGoal == s1)
167 {
168
169
170
171
172
175 adjustedSpeed = true;
176 }
177 else
179
180 if (speed < minSpeed) {
181 if (s0 != s1 && adjustStart)
182
183 ;
184 else
185
186 duration =
188
189 speed = minSpeed;
190 adjustedSpeed = true;
191 }
192
194
195
196 adjustedSpeed = true;
197 speed = 0.0;
198 }
199
200
201
202 if (adjustedSpeed && !adjustStart)
203 {
204
206 if (s0 < s1)
207 s1 = s0 + diff;
208 else
209 s1 = s0 - diff;
210 }
211
212 bool silent = false;
213
214
215
216
217 if (s1 != s0)
218 {
219
220
223 return false;
224
227 auto newDuration = duration;
228 const auto newS1 = std::max(minSample,
std::min(maxSample, s1));
229 if(s1 != newS1)
232 duration.
as_double() * (newS1 - s0).as_double() /
233 (s1 - s0).as_double()
234 )
235 );
236 if (newDuration == 0) {
237
238 silent = true;
239 s1 = s0;
240 }
241 else if (s1 != newS1) {
242
243 duration = newDuration;
244 s1 = newS1;
245 }
246 }
247
248 if (adjustStart && !silent)
249 {
250
253 if (s0 < s1)
254 s0 = s1 - diff;
255 else
256 s0 = s1 + diff;
257 }
258
262 if (duration < origDuration)
264
265 return true;
266 }
Positions or offsets within audio files need a wide type.
PlaybackPolicy::Duration minStutterTime
static double MinAllowedScrubSpeed()