History

Added multiband compander effect

cbagwell committed 22 years ago

Commit fec8e041 parent bd0eddd10 files · +79 −16Browse files

Unified · Split

10 files
  1. Changelog +2 −0
  2. scripts/fmsim +18 −0
  3. sox.1 +16 −0
  4. sox.txt +28 −11
  5. src/Makefile.dos +1 −1
  6. src/Makefile.gcc +2 −2
  7. src/Makefile.in +1 −1
  8. src/handlers.c +3 −0
  9. src/play.in +1 −1
  10. src/st_i.h +7 −0
Changelog+2−0
@@ -49,6 +49,8 @@ sox-12.17.6 · 48 unmodified lines
4949 o Added patch from Eric Benson that attempts to do a seek()
5050 if the first effect is trim. This greatly speeds up
5151 processing large files.
52+ o Daniel Pouzzner implemented a multi-band compander (using
53+ the butterworth filters to split the audio into bands).
5254
5355 sox-12.17.5
5456 -----------
scripts/fmsim+18−0
@@ -0,0 +1,18 @@
1+#!/bin/sh
2+#
3+# fmsim - simulates FM radio sound (or broadcast signal condition if the
4+# lowp at the end is skipped - not that the pipeline is set up with
5+# US-style 75us preemphasis).
6+#
7+# Thats signed 32-bit 44100Hz audio from stdin and outputs to stdout.
8+
9+
10+../src/sox -V -t raw -r 44100 -s -w -c 2 - -t raw -r 44100 -s -l -c 2 \
11+ - vol -3 db filter 8000- 32 100 mcompand ".005,.1 \
12+ -47,-40,-34,-34,-17,-33 0 0 0" 100 ".003,.05 \
13+ -47,-40,-34,-34,-17,-33 0 0 0" 400 ".000625,.0125 \
14+ -47,-40,-34,-34,-15,-33 0 0 0" 1600 ".0001,.025 \
15+ -47,-40,-34,-34,-31,-31,-0,-30 0 0 0" 6400 \
16+ "0,.025 -38,-31,-28,-28,-0,-25 0 0 0" vol 27 db vol -12 \
17+ db highpass 22 highpass 22 filter -17500 256 vol +12 db \
18+ vol -3 db lowp 17801
sox.1+16−0
@@ -93,6 +93,12 @@ sox \- Sound eXchange : universal sound sample translator · 92 unmodified lines
9393 \fBlowpass\fR \fIfrequency\fR
9494 .br
9595 \fBmask\fR
96+.br
97+ \fBmcompand\fR "\fIattack1\fR,\fIdecay1\fR[,\fIattack2\fR,\fIdecay2\fR...]
98+.br
99+ \fIin-dB1\fR,\fIout-dB1\fR[,\fIin-dB2\fR,\fIout-dB2\fR...]
100+.br
101+ [ \fIgain\fR [ \fIinitial-volume\fR [ \fIdelay\fR ] ] ]" xover_freq
96102 .br
97103 \fBpan\fR \fIdirection\fR
98104 .br
@@ -907,6 +913,16 @@ created by the process of playing a sound digitally. · 808 unmodified lines
907913 It tends to mask buzzing voices, for example.
908914 It adds 1/2 bit of noise to the sound file at the
909915 output bit depth.
916+.TP
917+mcompand "\fIattack1,decay1\fR[,\fIattack2,decay2\fR...]
918+.TP
919+ \fIin-dB1,out-dB1\fR[,\fIin-dB2,out-dB2\fR...]
920+.TP 10
921+ [\fIgain\fR [\fIinitial-volume\fR [\fIdelay\fR ] ] ]" \fIxover_freq\fR
922+
923+Multi-band compander is similar to the single band compander but
924+the audio file is first divided up into bands and then the compander
925+is ran on each band. See the \fBcompand\fR effect for definition of its options. Compand options are specified between double quotes and the crossover frequency for that band is specefied seperately with \fIxover_fre\fR. This can be repeated multiple times to create multiple bands.
910926 .TP 10
911927 pan \fIdirection\fB
912928 Pan the sound of an audio file from one channel to another. This is done by
sox.txt+28−11
@@ -54,6 +54,9 @@ SYNOPSIS · 53 unmodified lines
5454 lowp frequency
5555 lowpass frequency
5656 mask
57+ mcompand "attack1,decay1[,attack2,decay2...]
58+ in-dB1,out-dB1[,in-dB2,out-dB2...]
59+ [ gain [ initial-volume [ delay ] ] ]" xover_freq
5760 pan direction
5861 phaser gain-in gain-out delay decay speed < -s | -t >
5962 pick [ -1 | -2 | -3 | -4 | -l | -r | -f | -b ]
@@ -192,9 +195,9 @@ OPTIONS · 132 unmodified lines
192195 ADPCM, IMA_ADPCM, GSM, or Floating-point.
193196 U-law (actually shorthand for mu-law) and A-law are the U.S.
194197 and international standards for logarithmic telephone sound
195− compression. When uncompressed u-law has roughly the preci-
196− sion of 14-bit PCM audio and A-law has roughly the precision
197− of 13-bit PCM audio.
198+ compression. When uncompressed u-law has roughly the
199+ precision of 14-bit PCM audio and A-law has roughly the pre-
200+ cision of 13-bit PCM audio.
198201 A-law and u-law data is sometimes encoded using a reversed
199202 bit-ordering (ie. MSB becomes LSB). Internally, SoX under-
200203 stands how to work with this encoding but there is currently
@@ -605,11 +608,11 @@ EFFECTS · 404 unmodified lines
605608 the fourth (optional) parameter is an initial volume to be
606609 assumed for each channel when the effect starts. This per-
607610 mits the user to supply a nominal level initially, so that,
608− for example, a very large gain is not applied to initial sig-
609− nal levels before the companding action has begun to operate:
610− it is quite probable that in such an event, the output would
611− be severely clipped while the compander gain properly adjusts
612− itself.
611+ for example, a very large gain is not applied to initial
612+ signal levels before the companding action has begun to oper-
613+ ate: it is quite probable that in such an event, the output
614+ would be severely clipped while the compander gain properly
615+ adjusts itself.
613616
614617 The fifth (optional) parameter is a delay in seconds. The
615618 input signal is analyzed immediately to control the compan-
@@ -674,9 +677,9 @@ EFFECTS · 58 unmodified lines
674677 stop-time is not specified.
675678 All times can be specified in either periods of time or sam-
676679 ple counts. To specify time periods use the format
677− hh:mm:ss.frac format. To specify using sample counts, spec-
678− ify the number of samples and append the letter ’s’ to the
679− sample count (for example 8000s).
680+ hh:mm:ss.frac format. To specify using sample counts,
681+ specify the number of samples and append the letter ’s’ to
682+ the sample count (for example 8000s).
680683 An optional type can be specified to change the type of enve-
681684 lope. Choices are q for quarter of a sinewave, h for half a
682685 sinewave, t for linear slope, l for logarithmic, and p for
@@ -734,6 +737,20 @@ EFFECTS · 51 unmodified lines
734737 tends to mask buzzing voices, for example. It adds 1/2 bit
735738 of noise to the sound file at the output bit depth.
736739
740+ mcompand "attack1,decay1[,attack2,decay2...]
741+
742+ in-dB1,out-dB1[,in-dB2,out-dB2...]
743+
744+ [gain [initial-volume [delay ] ] ]" xover_freq
745+
746+ Multi-band compander is similar to the single band compander
747+ but the audio file is first divided up into bands and then
748+ the compander is ran on each band. See the compand effect
749+ for definition of its options. Compand options are specified
750+ between double quotes and the crossover frequency for that
751+ band is specefied seperately with xover_fre. This can be
752+ repeated multiple times to create multiple bands.
753+
737754 pan direction
738755 Pan the sound of an audio file from one channel to another.
739756 This is done by changing the volume of the input channels so
src/Makefile.dos+1−1
@@ -22,7 +22,7 @@ FOBJ = 8svx.obj adpcm.obj aiff.obj alsa.obj au.obj auto.obj \ · 21 unmodified lines
2222 EOBJ = avg.obj band.obj bandpass.obj breject.obj btrworth.obj chorus.obj \
2323 compand.obj copy.obj dcshift.obj deemphas.obj earwax.o \
2424 echo.obj echos.obj fade.obj filter.obj flanger.obj highp.obj \
25− highpass.obj lowp.obj lowpass.obj mask.obj phaser.obj \
25+ highpass.obj lowp.obj lowpass.obj mask.obj mcompand.obj phaser.obj \
2626 pitch.obj pan.obj polyphase.obj rate.obj repeat.obj resample.obj \
2727 reverb.obj reverse.obj silence.obj speed.obj stat.obj \
2828 stretch.obj swap.obj synth.obj trim.obj vibro.obj vol.obj
src/Makefile.gcc+2−2
@@ -28,8 +28,8 @@ FOBJ = 8svx.o adpcm.o aiff.o alsa.o au.o auto.o avr.o cdr.o cvsd.o dat.o \ · 27 unmodified lines
2828 EOBJ = avg.o band.o bandpass.o breject.o btrworth.o chorus.o compand.o \
2929 copy.o dcshift.o deemphas.o earwax.o echo.o echos.o fade.o \
3030 filter.o flanger.o highp.o highpass.o lowp.o lowpass.o \
31− mask.o pan.o phaser.o pitch.o polyphas.o rate.o repeat.o \
32− resample.o reverb.o reverse.o silence.o speed.o \
31+ mask.o mcompand.o pan.o phaser.o pitch.o polyphas.o rate.o \
32+ repeat.o resample.o reverb.o reverse.o silence.o speed.o \
3333 stat.o stretch.o swap.o synth.o trim.o vibro.o vol.o
3434
3535 SOUNDLIB = libst.a
src/Makefile.in+1−1
@@ -49,7 +49,7 @@ FOBJ = 8svx.o adpcm.o aiff.o au.o auto.o avr.o cdr.o \ · 48 unmodified lines
4949 EOBJ = avg.o band.o bandpass.o breject.o btrworth.o chorus.o compand.o \
5050 copy.o dcshift.o deemphas.o earwax.o echo.o echos.o \
5151 fade.o filter.o flanger.o highp.o highpass.o lowp.o \
52− lowpass.o mask.o pan.o phaser.o pitch.o polyphas.o \
52+ lowpass.o mask.o mcompand.o pan.o phaser.o pitch.o polyphas.o \
5353 rate.o repeat.o resample.o reverb.o reverse.o silence.o speed.o \
5454 stat.o stretch.o swap.o synth.o trim.o vibro.o vol.o
5555
src/handlers.c+3−0
@@ -465,6 +465,9 @@ st_effect_t st_effects[] = { · 464 unmodified lines
465465 {"mask", ST_EFF_MCHAN,
466466 st_mask_getopts, st_effect_nothing, st_mask_flow,
467467 st_effect_nothing_drain, st_effect_nothing},
468+ {"mcompand", ST_EFF_MCHAN,
469+ st_mcompand_getopts, st_mcompand_start, st_mcompand_flow,
470+ st_mcompand_drain, st_mcompand_stop},
468471 {"pan", ST_EFF_MCHAN | ST_EFF_CHAN,
469472 st_pan_getopts, st_pan_start, st_pan_flow,
470473 st_effect_nothing_drain, st_pan_stop},
src/play.in+1−1
@@ -72,7 +72,7 @@ formats, and effect options." · 71 unmodified lines
7272 # loop over arguments
7373 while [ $# -ne 0 ]; do
7474 case "$1" in
75− avg|band|bandpass|bandreject|chorus|compand|copy|cut|deemph|earwax|echo|echos|fade|filter|flanger|highp|highpass|lowp|lowpass|map|mask|pan|phaser|pick|pitch|polyphase|rate|repeat|resample|reverb|reverse|silence|speed|split|stat|stretch|swap|trim|vibro|vol)
75+ avg|band|bandpass|bandreject|chorus|compand|copy|cut|deemph|earwax|echo|echos|fade|filter|flanger|highp|highpass|lowp|lowpass|map|mask|mcompand|pan|phaser|pick|pitch|polyphase|rate|repeat|resample|reverb|reverse|silence|speed|split|stat|stretch|swap|trim|vibro|vol)
7676 effects="$@"
7777 break
7878 ;;
src/st_i.h+7−0
@@ -487,6 +487,13 @@ int st_mask_getopts(eff_t effp, int argc, char **argv); · 486 unmodified lines
487487 int st_mask_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
488488 st_size_t *isamp, st_size_t *osamp);
489489
490+int st_mcompand_getopts(eff_t effp, int argc, char **argv);
491+int st_mcompand_start(eff_t effp);
492+int st_mcompand_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
493+ st_size_t *isamp, st_size_t *osamp);
494+int st_mcompand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
495+int st_mcompand_stop(eff_t effp);
496+
490497 int st_pan_getopts(eff_t effp, int argc, char **argv);
491498 int st_pan_start(eff_t effp);
492499 int st_pan_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,

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