# Audio Time Stretching Using Fuzzy Classification of Spectral Bins
## 3 Novel Time-Scale Modification Technique
### Transient Detection and Preservation
#### 3.2.2 Transient Preservation  
To prevent transient smearing, it is necessary to concentrate the transient energy in time. A single transient contributes energy to multiple analysis frames, because the frames are overlapping. During the synthesis, the phases of the STFT bins are modified, and the synthesis frames are relocated in time, which results in smearing of the transient energy.  
To remove this effect, transients are detected as the analysis window slides over them. When a transient onset has been detected using the method described above, the energy in the STFT bins is suppressed according to their estimated transientness:  
\[|Y[m,k]|=(1-R_{t}[m,k])|X[m,k]|. \tag{16}\]  
This gain is only applied to bins whose estimated transientness is larger than 0.5. Similar to [23], the bins to which this gain has been applied are kept in a non-contracting set of transient bins \(K_{t}\). When it is detected that the analysis window is centered on a transient, as explained above, a phase reset is performed on the transient bins. That is, the original analysis phases are kept during synthesis for the transient bins. Subsequently, as the analysis window slides over the transient, the same gain reduction is applied for the transient bins, as during the onset of the transient (16). The bins are retained in the set of transient bins until their transientness decays to a value smaller than 0.5, or until the analysis frame slides completely away from the detected transient center. Finally, since the synthesis frames  
Figure 6: Illustration of the proposed transient detection. (**a**) Frame transientness. Locations of the detected transients are marked with purple circles; (**b**) Time derivative of the frame transientness. Detected transient onsets are marked with orange crosses. The red dashed line shows the transient detection threshold.  
before and after the center of the transient do not contribute to the transients' energy, the magnitudes of the transient bins are compensated by  
\[|Y[m_{t},k_{t}]|=\frac{\sum_{m\in\mathbb{Z}}w^{2}[(m_{t}-m)H_{s}]}{w^{2}[0]}\frac {\sum_{k\in K_{t}}R_{t}[m_{t},k]}{|K_{t}|}|X[m_{t},k_{t}]|, \tag{17}\]  
where \(m_{t}\) is the transient frame index, \(|K_{t}|\) denotes the number of elements in the set \(K_{t}\), and \(k_{t}\in K_{t}\), which is the defined set of transient bins.  
This method aims to prevent the smearing of both the transient onsets and offsets during TSM. In effect, the transients are separated from the input audio, and relocated in time according to the TSM factor. However, in contrast to methods where transients are explicitly separated from the input audio [13; 14; 28; 34], the proposed method is more likely to keep transients perceptually intact with other components of the sound. Since the transients are kept in the same STFT representation, phase modifications in subsequent frames are dependent on the phases of the transient bins. This suggests that transients related to the onsets of harmonic sounds, such as the pluck of a note while strumming a guitar, should blend smoothly with the following tonal component of the sound. Furthermore, the soft manner in which the amplitudes of the transient bins are attenuated during onsets and offsets should prevent strong artifacts arising from errors in the transient detection.  
Figure 7 shows an example of a transient processed with the proposed method. The original audio shown in Figure 7a consists of a solo violin overlaid with a castanet click. Figure 7b shows the time-scale modified sample with TSM factor \(\alpha=1.5\), using the standard phase vocoder. In the modified sample, the energy of the castanet click is spread over time. This demonstrates the well known transient smearing artifact of standard phase vocoder TSM. Figure 7c shows the time-scale modified sample using the proposed method. It can be seen that while the duration of the signal has changed, the castanet click in the modified audio resembles the one in the original, without any visible transient smearing.