drc#
- diffsptk.DRC#
alias of
DynamicRangeCompression
- class diffsptk.DynamicRangeCompression(threshold, ratio, attack_time, release_time, sample_rate, makeup_gain=0, abs_max=1, learnable=False)[source]#
See this page for details.
- Parameters:
- thresholdfloat <= 0
Threshold in dB.
- ratiofloat > 1
Input/output ratio.
- attack_timefloat > 0
Attack time in msec.
- release_timefloat > 0
Release time in msec.
- sample_rateint >= 1
Sample rate in Hz.
- makeup_gainfloat >= 0
Make-up gain in dB.
- abs_maxfloat > 0
Absolute maximum value of input.
- learnablebool
Whether to make the DRC parameters learnable.
References
[1]C.-Y. Yu et al., “Differentiable all-pole filters for time-varying audio systems,” Proceedings of DAFx, pp. 345-352, 2024.
- forward(x)[source]#
Perform dynamic range compression.
- Parameters:
- xTensor [shape=(…, T)]
Input signal.
- Returns:
- outTensor [shape=(…, T)]
Compressed signal.
Examples
>>> x = torch.randn(16000) >>> x.abs().max() tensor(4.2224) >>> drc = diffsptk.DynamicRangeCompression(-20, 4, 10, 100, 16000) >>> y = drc(x) >>> y.abs().max() tensor(2.5779)
- diffsptk.functional.drc(x, threshold, ratio, attack_time, release_time, sample_rate, makeup_gain=0, abs_max=1)[source]#
Apply dynamic range compression.
- Parameters:
- xTensor [shape=(…, T)]
Input signal.
- thresholdfloat <= 0
Threshold in dB.
- ratiofloat > 1
Input/output ratio.
- attack_timefloat > 0
Attack time in msec.
- release_timefloat > 0
Release time in msec.
- sample_rateint >= 1
Sample rate in Hz.
- makeup_gainfloat >= 0
Make-up gain in dB.
- abs_maxfloat > 0
Absolute maximum value of input.
- Returns:
- outTensor [shape=(…, T)]
Compressed signal.