Add linear fade-out to IRs with --fade-ms option (default 5ms); update README and CLI
This commit is contained in:
@@ -322,3 +322,22 @@ func Resample(data []float64, fromSampleRate, toSampleRate int) []float64 {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FadeOutLinear applies a linear fade-out to the last fadeSamples of the data.
|
||||
// fadeSamples is the number of samples over which to fade to zero.
|
||||
func FadeOutLinear(data []float64, fadeSamples int) []float64 {
|
||||
if fadeSamples <= 0 || len(data) == 0 {
|
||||
return data
|
||||
}
|
||||
if fadeSamples > len(data) {
|
||||
fadeSamples = len(data)
|
||||
}
|
||||
out := make([]float64, len(data))
|
||||
copy(out, data)
|
||||
start := len(data) - fadeSamples
|
||||
for i := start; i < len(data); i++ {
|
||||
fade := float64(len(data)-i) / float64(fadeSamples)
|
||||
out[i] *= fade
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user