1 Star 1 Fork 0

wulala乌啦啦 / hwpack

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gain.go 769 Bytes
一键复制 编辑 原始数据 按行查看 历史
wulala乌啦啦 提交于 2021-08-14 14:59 . 增加音频播放的接口
package effects
import "gitee.com/wulalade/hwpack/music/beep"
// Gain amplifies the wrapped Streamer. The output of the wrapped Streamer gets multiplied by
// 1+Gain.
//
// Note that gain is not equivalent to the human perception of volume. Human perception of volume is
// roughly exponential, while gain only amplifies linearly.
type Gain struct {
Streamer beep.Streamer
Gain float64
}
// Stream streams the wrapped Streamer amplified by Gain.
func (g *Gain) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = g.Streamer.Stream(samples)
for i := range samples[:n] {
samples[i][0] *= 1 + g.Gain
samples[i][1] *= 1 + g.Gain
}
return n, ok
}
// Err propagates the wrapped Streamer's errors.
func (g *Gain) Err() error {
return g.Streamer.Err()
}
1
https://gitee.com/wulalade/hwpack.git
git@gitee.com:wulalade/hwpack.git
wulalade
hwpack
hwpack
d22efa2ac7c9

搜索帮助

53164aa7 5694891 3bd8fe86 5694891