Talk:Truncate Silence

{{ednote|1= Gale24Aug14: Proofread.
 * Corrected some apparent mistakes where I think "below" meant "at or below" or "longer than" meant "this length or longer".
 * I found the repetitions of "specified" a bit wearying and thought it could be hard for user to know which control was being referred to so I tried to make that clear.
 * I made clearer exactly when "Truncate to" and "Compress to" are available.
 * Steve 24Aug14:
 * "Silence" means "below" the threshold level (Line 223 of TruncSilence.cpp: if (fabs(buffer[i]) < truncDbSilenceThreshold) {).
 * "this length or longer" is correct regarding 'detection': if (silentFrames >= minSilenceFrames), however there is a logical/linguistic quirk in that if the detected silence is exactly the specified duration, then although it is detected "Compress by" will be compressing 0 seconds by a percentage. Any percent of 0 is still 0, so there will still be no shortening, even though the silence is detected.
 * I think this reads OK now, but please check.


 * Gale 24Aug14: At first read, removing all the "at or below" instances (including the ones that were there originally) seems very confusing. If user sets Level of say -40 dB, they need to know if this means audio at -40 dB will be truncated, or if audio at -40 dB will be left alone and only audio below -40 dB will be truncated. Clearly the effect does truncate audio "at" -40 dB if level is set to -40 dB. In the first "compress" example, Steve now says "Silences that were originally less than 2 seconds duration will be unaffected. All silences that were longer than 2 seconds are shortened." But that doesn't say what happens to silences of exactly 2 seconds, so can't be right. I think the original which I did not change " Silences that were originally 2 seconds or less will be unaffected. All silences that were longer than 2 seconds are shortened." is more correct. That description sidesteps that silences that are "exactly" 2 seconds will be "detected" but not acted on, which I thought would be confusing to point out, but if we must say that, I think that is better than not saying what happens to silence of 2 seconds.
 * Steve 24Aug14: "Clearly the effect does truncate audio "at" -40 dB if level is set to -40 dB."
 * It is difficult to prove this due to floating point rounding errors, but the Audacity code clearly says that detection occurs "below" the threshold. In practical terms, is there any difference between truncation occurring "at" 0.01 linear or at "0.0099999998"? Both of these values round to -40 dB, but 0.0099999998 is clearly "less than" 0.01. It is just unfortunate that there is no exact binary representation of the decimal value "0.01" (-40 dB). Strictly speaking, the "-40 dB" choice should say "-40.0000001737 dB" (the closest representation of 0.01 converted to dB in binary). The "actual" levels that are tested are defined in Shuttle.cpp line 84.
 * Gale 25Aug14: I suspect we may have the same problem with thresholds "at or below" in other effects. Despite what the code says, the "at or below" solution is more understandable to someone seeing what the effect does. Isn't every threshold expressible as both "below" or "at or below (the next measurable step down)? What do the other level settings do? Do they all act as "at or below" in respect of the displayed amplitude in Amplify, like -40 dB does, or does behavior differ?
 * Steve 25Aug14: The case in Truncate Silence is probably more contentious than in other effects due to the relatively low precision of the dB settings (only accurate to 3 significant figures). Regarding other effects, they would need checking individually, but as a general point I think that a "threshold" should be thought of as a "divide" rather than as a "value". As an example, we have "before noon" and "after noon", but if we have unlimited precision, is it ever "exactly" noon?
 * Gale 26Aug14: I checked many of the levels and all but one I checked (-30 dB) "appear" to truncate at the Level specified in this effect. I don't think we can avoid facing that, so I added a note in the Level control that this may happen due to rounding. Does that satisfy everyone?
 * Steve 26Aug14: Considering that Truncate Silence is in steps of 5 dB, I wouldn't have thought it particularly important to consider the case of tiny fractions of a dB, but I've no problem what you've put - it looks correct to me.
 * In the case of the first "Compress by" example, I think it's a close call as to which is clearer. Is it clearer now with the "exact" case described?
 * Gale 25Aug14: Yes, that's OK.

}}
 * Peter 29Aug14: Gale - does this mean the P2 is fixed.
 * Gale 29Aug14: Yes I am happy with this page now, removed the P2.

Text of page as of 2.0.5 and previous
{{ednote|1=

Threshold for silence
Audio at or below this amplitude will be regarded as "silence", so will be truncated. White space between audio clips is in effect absolute silence, so will always be truncated.

Ignore silence less than
Specifies the shortest length of silence that will be truncated by the effect. Silent passages of this length or greater will be truncated. Silent passages of less than this length will be left unchanged.

Compress silence by
A compression factor which proportionally reduces silences in the waveform that are longer than the "Ignore silence less than" length. Compression is only applied to that part of the silence that is in excess of the ignored duration, so for the default compression factor of 4:1 that "excess" silence would be compressed to a quarter of its original length. A ratio of 1:1 disables compression.

This setting has no effect if the "truncate to" length (below) is the same as or less than the "ignore" length.

and then truncate to
If the duration of a detected silence after compression is still greater than the "truncate to" length, it will be truncated to the "truncate to" length. The final duration of the detected silence will be this length unless it is already shorter. It may be convenient to think of "then truncate to" as the maximum length after compression/truncation. Compression or truncation is achieved by deletion from the middle of the detected silence.
 * Setting the "truncate to" length to the same as the "Ignore" length will always reduce the truncated silences to this length.
 * Silences longer than the "truncate to" length will remain if they were ignored by Truncate Silence because they were shorter than the "Ignore" length.

Examples

 * Simple usage: Setting both the "Ignore" and "truncate to" lengths to 5 milliseconds (ms) will truncate the silence to 5 ms. This is less than the length of a detectable silence, so will effectively eliminate it.


 * Truncate length only: Set the "Compress silence by" factor to 1. Now any silence longer than both the "Ignore" and "truncate to" length will be reduced to the "truncate to" length and never any less than that.


 * Proportional length only: Set the "Truncate to" length to some large value, like 1000000. Now that part of any silence greater than the "Ignore" length will always be compressed by the "Compress silence by" factor.


 * Proportional truncation with compression factor: The resulting silence is calculated according to the following formula:


 * (output length) = ((ignore silence length) + (waveform silence length - ignore silence length)/compression)

 with the constraint that output length can't be more than the "truncate to" length.

So, setting the minimum to 33 ms and compression to 5:1, a silent passage 1033 ms long would be truncated to 233ms (33 + (1033-33/5)), unless "truncate to" was set to less than 233 ms (in which case truncation would be to that "truncate to" length). As a real world example, setting the minimum to 100 ms, the maximum to 5000 ms and the compression factor to 4:1 will have the effect of doubling the speed of a speech track with no pitch change, while keeping about the same cadence as the original.  }}

Suggestions for reworking Truncate Silence dialog
Steve 17Jul11: It is not particularly clear what the Min and Max controls actually do and a user can easily fall into the trap of thinking that they refer to the minimum and maximum duration of the resulting silence(s). See bug 433

This proposal is that the GUI is split into sections so as to make it clear that Min silence duration: refers to the minimum silence duration that is detected, and that Max silence duration: constrains the maximum duration of the processed silence.

The one additional control in this example is the Multi-track mode: which is to enable the user to select whether silences are detected based on silence that is common to all selected tracks (Combined Tracks option) or based on the silence in individual tracks (Independent Tracks option). See bug 52. This control may need modifying according to how bug 52 is resolved.


 * [[image:Proposed_Truncate_Silence_GUI.png‎|Proposed Truncate Silence dialog]]

James: +1 on sections and naming. Am now OK with min>max as this layout makes it clear what's going on, and the 'nudge' from the forum gives a motivation for allowing it. The multi-track mode drop-down requires some new code rather than just a small change to the UX, so I see it as a separate change. A nice-to-have that can be independent of the relabeling.

Truncate Silence automatically reduces the length of passages where the volume is below a set threshold level.
 * Accessed by: Effect > Truncate Silence...
 * [[image:TruncateSilence.png|Truncate Silence dialog]]

Throughout this description the words "silence" and "silent" mean sounds that are below the Threshold setting.

Settings

 * Min silence duration: Specifies the shortest allowable resulting silence. Truncate Silence will never shorten silent audio to less than than this length, and silent passages shorter than this length will not be altered. Default: 200 milliseconds. If the selection to be truncated begins with silence, that silence will be truncated to this minimum value.
 * Max silence duration: Specifies the longest allowable resulting silence. Setting this to the same as Min will therefore always reduce the silence to this length. Default: 1000 milliseconds.


 * Silence compression: A compression factor which proportionally reduces periods of silence that are longer than the minimum. This therefore has no effect unless Max exceeds Min. Default: 4:1, which compresses the silence in excess of min to a quarter of its original length.


 * Threshold for silence: Audio at or below this amplitude will be regarded as "silence", so will be truncated. Default: -40 dB.

Examples

 * Simple usage: Setting both the Min and Max lengths to 5 milliseconds (ms) will truncate the silence to 5 ms. This is less than the length of a detectable silence, so will effectively eliminate it.


 * Proportional truncation with compression factor: The resulting silence is calculated according to the following formula:


 * (output silence length) = ((min) + ((input silence length) - min))/compression)

 with the constraint that output must be less than the maximum length.

So, setting the minimum to 33 ms and compression to 5:1, a silent passage 1033 ms long would be truncated to 233ms (33 + (1033-33/5)), unless the maximum was set to less than 233 ms. As a real world example, setting the minimum to 100 ms, the maximum to 5000 ms and the compression factor to 4:1 will have the effect of doubling the speed of a speech track with no pitch change, while keeping about the same cadence as the original.

Limitations
Truncate Silence only removes audio, it does not reduce or eliminate noise in the silent sections that it keeps.

Avoid using Truncate Silence on selections which have fade-outs or fade-ins. If you need to add fades, apply Truncate Silence before adding fades.