History

Fix fade effect's fade-out-length to align with man page.

cbagwell committed 21 years ago

Commit 5cb0ea01 parent 3dd31964 files · +35 −13Browse files

Unified · Split

4 files
  1. Changelog +7 −2
  2. scripts/crossfade.sh +1 −1
  3. scripts/crossfade_cat.sh +1 −1
  4. src/fade.c +26 −9
Changelog+7−2
@@ -40,8 +40,13 @@ sox-12.17.9 · 39 unmodified lines
40 Matthew Hodgson.40 Matthew Hodgson.
41 o Add fix to WAV handler to only return data in multiples41 o Add fix to WAV handler to only return data in multiples
42 of sample_size*channels to better handle corrupt files.42 of sample_size*channels to better handle corrupt files.
43 o Fixed bug where "-4" option didn't work with avg effect.43 o Fixed bug where "-4" option didn't work with avg
44 (Tom Christie)44 effect (Tom Christie).
45 o Fixed fade's fade-out-length to match man page
46 description as noted by Geoff Kuenning. This required
47 updates to the sample crossfade scripts. Also modified fade
48 effect to report when no more samples will be produced to
49 prevent unneeded reading of whole file.
45 50
46sox-12.17.851sox-12.17.8
47-----------52-----------
scripts/crossfade.sh+1−1
@@ -57,7 +57,7 @@ fi · 56 unmodified lines
57 57
58fade_first_opts=58fade_first_opts=
59if [ "$fade_first" != "no" ]; then59if [ "$fade_first" != "no" ]; then
60 fade_first_opts="fade t 0 0:0:$fade_length"60 fade_first_opts="fade t 0 0:0:$fade_length 0:0:$fade_length"
61fi61fi
62 62
63fade_second_opts=63fade_second_opts=
scripts/crossfade_cat.sh+1−1
@@ -49,7 +49,7 @@ fi · 48 unmodified lines
49 49
50fade_first_opts=50fade_first_opts=
51if [ "$fade_first" != "no" ]; then51if [ "$fade_first" != "no" ]; then
52 fade_first_opts="fade t 0 0:0:$fade_length"52 fade_first_opts="fade t 0 0:0:$fade_length 0:0:$fade_length"
53fi53fi
54 54
55fade_second_opts=55fade_second_opts=
src/fade.c+26−9
@@ -34,7 +34,7 @@ typedef struct fadestuff · 33 unmodified lines
34 int endpadwarned;34 int endpadwarned;
35} *fade_t;35} *fade_t;
36 36
37#define FADE_USAGE "Usage: fade [ type ] fade-in-length [ stop-time [ fade-out-length ] ]\nTimes is hh:mm:ss.fac format.\nFade type one of q, h, t, l or p.\n"37#define FADE_USAGE "Usage: fade [ type ] fade-in-length [ stop-time [ fade-out-length ] ]\nTime is in hh:mm:ss.frac format.\nFade type one of q, h, t, l or p.\n"
38 38
39/* prototypes */39/* prototypes */
40static double fade_gain(st_size_t index, st_size_t range, char fadetype);40static double fade_gain(st_size_t index, st_size_t range, char fadetype);
@@ -182,13 +182,14 @@ int st_fade_start(eff_t effp) · 141 unmodified lines
182 182
183 }183 }
184 else184 else
185 /* If no start time specified, assume everything185 /* If user doesn't specify fade out length then
186 * after fadein.186 * use same length as input side. This is stored
187 * in in_stop.
187 */188 */
188 fade->out_start = fade->in_stop;189 fade->out_start = fade->out_stop - fade->in_stop;
189 }190 }
190 else191 else
191 /* If not specified then user doesn't wants to process all 192 /* If not specified then user wants to process all
192 * of file. Use a value of zero to indicate this.193 * of file. Use a value of zero to indicate this.
193 */194 */
194 fade->out_stop = 0;195 fade->out_stop = 0;
@@ -205,6 +206,8 @@ int st_fade_start(eff_t effp) · 10 unmodified lines
205 206
206 fade->endpadwarned = 0;207 fade->endpadwarned = 0;
207 208
209 /* fprintf(stderr, "fade: in_start = %d in_stop = %d out_start = %d out_stop = %d\n", fade->in_start, fade->in_stop, fade->out_start, fade->out_stop); */
210
208 return(ST_SUCCESS);211 return(ST_SUCCESS);
209}212}
210 213
@@ -217,7 +220,7 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 6 unmodified lines
217{220{
218 fade_t fade = (fade_t) effp->priv;221 fade_t fade = (fade_t) effp->priv;
219 /* len is total samples, chcnt counts channels */222 /* len is total samples, chcnt counts channels */
220 int len = 0, chcnt = 0, t_output = 0;223 int len = 0, chcnt = 0, t_output = 1, more_output = 1;
221 st_sample_t t_ibuf;224 st_sample_t t_ibuf;
222 225
223 len = ((*isamp > *osamp) ? *osamp : *isamp);226 len = ((*isamp > *osamp) ? *osamp : *isamp);
@@ -225,7 +228,7 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 1 unmodified line
225 *osamp = 0;228 *osamp = 0;
226 *isamp = 0;229 *isamp = 0;
227 230
228 for(; len; len--)231 for(; len && more_output; len--)
229 {232 {
230 t_ibuf = (fade->samplesdone < 0 ? 0 : *ibuf);233 t_ibuf = (fade->samplesdone < 0 ? 0 : *ibuf);
231 234
@@ -252,6 +255,9 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 20 unmodified lines
252 fade->out_fadetype);255 fade->out_fadetype);
253 } /* endif fade-out */256 } /* endif fade-out */
254 257
258 if (!(!fade->do_out || fade->samplesdone < fade->out_stop))
259 more_output = 0;
260
255 t_output = 1;261 t_output = 1;
256 }262 }
257 else263 else
@@ -282,7 +288,14 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 24 unmodified lines
282 fade->samplesdone += 1;288 fade->samplesdone += 1;
283 } /* endif all channels */289 } /* endif all channels */
284 } /* endfor */290 } /* endfor */
285 return(ST_SUCCESS);291
292 /* If not more samples will be returned, let application know
293 * this.
294 */
295 if (fade->do_out && fade->samplesdone >= fade->out_stop)
296 return ST_EOF;
297 else
298 return ST_SUCCESS;
286}299}
287 300
288/*301/*
@@ -317,7 +330,11 @@ int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp) · 28 unmodified lines
317 t_chan = 0;330 t_chan = 0;
318 } /* endif channels */331 } /* endif channels */
319 } /* endfor */332 } /* endfor */
320 return(ST_SUCCESS);333
334 if (fade->do_out && fade->samplesdone >= fade->out_stop)
335 return ST_EOF;
336 else
337 return ST_SUCCESS;
321}338}
322 339
323/*340/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t