Sndtrim seems to be broken Sat Aug 17 17:32:23 PDT 2002
Sndtrim attempts to split a given soundfile into
separate soundfiles, one for each voiced section
of the input.  It is useful when sampling an instrument.
One can record a soundfile containing many individual
events or notes, each separated by a small section
which is close to silence.  Sndtrim will identify
the individual sections that contain sound that
is louder than a certain gate level, and split these
sections in to individual soundfiles, while automating
the "fade in" and "fade out" processes in order to 
provide smooth transitions to and from the points
where the gate is crossed.

Suppose the crude graph below represents the
absolute amplitutde of an input soundfile.
We have a gate threshold that marks the quietest
sound that should not be concidered silence (noise).
sndtrim will read through the input, discarding
all samples until one reaches the level of the gate.  
At that point, it backs up in the input a duration 
given by the -l (lead padding) flag.  It then opens 
a new soundfile, and begins copying the input to the 
output, "fading in" the section up to where the gate 
was found.  After this, samples are copied exactly 
until such time as the gate has not been met for 
-q (min quiet dur) seconds.  It will then back up 
to the first sample below the gate that headed the 
quiet section, and continue copying and "fading out" 
samples to the output for a duration of 
-t (tail padding) seconds.


                         ...~~~~...                           ....````...
                        /          \                         /           \
GATE: ----->           /            \                       /
                      /              \                     /  
..-...-...-.......--~'                '-..-......-.......-'
-----------------------------------------------------------------------------
                |<-L->|<--   F   -->|<-T->|
                   E	     L         A
                   A         A         I                                             
                   D         T         L                                    
                                                                            
                   P         O         P                                    
                   A         U         A                                    
                   D         T         D                                    
                   D         P         D                                    
                   I         U         I                                    
                   N         T         N                                    
                   G                   G                                  
                                                                           

This process is repeated, creating new outpt files
as needed, until the input is exhausted.  Each output
file is a sequential integer folowed by the original
input file name with an underscore in between. For 
example, after running sndtrim on a file 'test', you
might be left with '0_test', '1_test' and '2_test'
in the current directory.  Each one of these files
will contain a trimmed and faded copy of one event or
note from the original soundfile.

FLAGS:

	-g 
		This is a number between 0 and 1, and represents the linear 
		portion of the input file's maximum amplitude that should be
		used to delineate beteen silence and sound.  If this value
		is too low, sndtrim will mistake background or machine noise
		for event content, and the splicing will be inaccurate.  If
		it is set too high, Then meaningful sound may be skipped,
		resulting in the need for long fade in and fade out times
		needed in order to capture the entirety of an event.

	-l 
		Time in seconds to pad and fade in a sound *before* the gate
		level is hit.

	-t 
		Time in seconds to pad and fade out a sound *after* the first
		sample that begins a section of -q seconds containing no 
		samples above the gate.

	-q 
		Smallest time needed with no -level samples to trigger
		the transition from voiced section to silent section.


Toby Shepard
toby@tobiah.org