Add volume filter
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-03-06 16:05:18 +01:00
parent 3cdb593d2c
commit 7aa672a616

View file

@ -88,6 +88,38 @@ func (f RealTimeFilter) Process(source Source) Source {
}
}
type VolumeFilter struct {
adjustement float32
}
func NewVolumeFilter(adjustement float32) VolumeFilter {
return VolumeFilter{
adjustement: adjustement,
}
}
func (f VolumeFilter) Process(source Source) Source {
outBlocks := make(chan []float32)
go func() {
defer close(outBlocks)
for block := range source.Blocks {
out := make([]float32, len(block))
for i := range block {
out[i] = block[i] * f.adjustement
}
outBlocks <- out
}
}()
return Source{
Channels: source.Channels,
SampleRate: source.SampleRate,
Blocks: outBlocks,
}
}
type StereoFilter struct {
}