本文整理匯總了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
}