本文整理汇总了Golang中github.com/kierdavis/gosound/sound.Context.LinearEnvelope方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.LinearEnvelope方法的具体用法?Golang Context.LinearEnvelope怎么用?Golang Context.LinearEnvelope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kierdavis/gosound/sound.Context
的用法示例。
在下文中一共展示了Context.LinearEnvelope方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: genSlideEnvelope
func genSlideEnvelope(ctx sound.Context, from, to music.Note, duration time.Duration) (stream chan float64) {
return ctx.LinearEnvelope(
from.Frequency(),
duration*1/10,
from.Frequency(),
duration*8/10,
to.Frequency(),
duration*1/10,
to.Frequency(),
)
}
示例2: SequenceTreble
func SequenceTreble(ctx sound.Context) (seq *sound.Sequencer) {
melody := GenerateTrebleMelody()
seq = sound.NewSequencer(ctx)
var pos time.Duration
for i := 0; i < NumBars*3; i++ {
var freqInput chan float64
var duration time.Duration
if rand.Float64() < 0.01 {
from := (<-melody).Frequency()
to := (<-melody).Frequency()
freqInput = ctx.LinearEnvelope(
from,
NoteDuration*1/5,
from,
NoteDuration*8/5,
to,
NoteDuration*1/5+time.Millisecond,
to,
)
duration = NoteDuration * 2
} else {
freqInput = ctx.Const((<-melody).Frequency())
duration = NoteDuration
}
note := PlayTrebleNote(ctx, freqInput, duration)
seq.Add(pos, note)
pos += duration
}
return seq
}