This commit is contained in:
parent
3cdb593d2c
commit
7aa672a616
|
@ -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 {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue