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
4040 Matthew Hodgson.
4141 o Add fix to WAV handler to only return data in multiples
4242 of sample_size*channels to better handle corrupt files.
43− o Fixed bug where "-4" option didn't work with avg effect.
44− (Tom Christie)
43+ o Fixed bug where "-4" option didn't work with avg
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.
4550
4651 sox-12.17.8
4752 -----------
scripts/crossfade.sh+1−1
@@ -57,7 +57,7 @@ fi · 56 unmodified lines
5757
5858 fade_first_opts=
5959 if [ "$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"
6161 fi
6262
6363 fade_second_opts=
scripts/crossfade_cat.sh+1−1
@@ -49,7 +49,7 @@ fi · 48 unmodified lines
4949
5050 fade_first_opts=
5151 if [ "$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"
5353 fi
5454
5555 fade_second_opts=
src/fade.c+26−9
@@ -34,7 +34,7 @@ typedef struct fadestuff · 33 unmodified lines
3434 int endpadwarned;
3535 } *fade_t;
3636
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"
3838
3939 /* prototypes */
4040 static 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
182182
183183 }
184184 else
185− /* If no start time specified, assume everything
186− * after fadein.
185+ /* If user doesn't specify fade out length then
186+ * use same length as input side. This is stored
187+ * in in_stop.
187188 */
188− fade->out_start = fade->in_stop;
189+ fade->out_start = fade->out_stop - fade->in_stop;
189190 }
190191 else
191− /* If not specified then user doesn't wants to process all
192+ /* If not specified then user wants to process all
192193 * of file. Use a value of zero to indicate this.
193194 */
194195 fade->out_stop = 0;
@@ -205,6 +206,8 @@ int st_fade_start(eff_t effp) · 10 unmodified lines
205206
206207 fade->endpadwarned = 0;
207208
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+
208211 return(ST_SUCCESS);
209212 }
210213
@@ -217,7 +220,7 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 6 unmodified lines
217220 {
218221 fade_t fade = (fade_t) effp->priv;
219222 /* 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;
221224 st_sample_t t_ibuf;
222225
223226 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
225228 *osamp = 0;
226229 *isamp = 0;
227230
228− for(; len; len--)
231+ for(; len && more_output; len--)
229232 {
230233 t_ibuf = (fade->samplesdone < 0 ? 0 : *ibuf);
231234
@@ -252,6 +255,9 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 20 unmodified lines
252255 fade->out_fadetype);
253256 } /* endif fade-out */
254257
258+ if (!(!fade->do_out || fade->samplesdone < fade->out_stop))
259+ more_output = 0;
260+
255261 t_output = 1;
256262 }
257263 else
@@ -282,7 +288,14 @@ int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, · 24 unmodified lines
282288 fade->samplesdone += 1;
283289 } /* endif all channels */
284290 } /* 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;
286299 }
287300
288301 /*
@@ -317,7 +330,11 @@ int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp) · 28 unmodified lines
317330 t_chan = 0;
318331 } /* endif channels */
319332 } /* 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;
321338 }
322339
323340 /*

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