1 Star 1 Fork 0

wulala乌啦啦/hwpack

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
gain.go 769 Bytes
Copy Edit Raw Blame History
wulala乌啦啦 authored 2021-08-14 14:59 +08:00 . 增加音频播放的接口
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()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wulalade/hwpack.git
git@gitee.com:wulalade/hwpack.git
wulalade
hwpack
hwpack
4a210dae89ef

Search