示例#1
0
func playBassSynth(ctx sound.Context, freqInput chan float64) (stream chan float64) {
	return ctx.Add(
		ctx.Mul(
			ctx.Square(
				freqInput,
				ctx.Const(0.8),
			),
		),
	)
}
示例#2
0
func PlayBassNote(ctx sound.Context, freqInput chan float64, duration time.Duration) (stream chan float64) {
	return ctx.TakeDuration(
		ctx.Add(
			ctx.Mul(
				ctx.Square(
					freqInput,
					ctx.Const(0.8),
				),
			),
		),
		duration,
		true,
	)
}
示例#3
0
func playMelodySynth(ctx sound.Context, freqInput chan float64) (stream chan float64) {
	freqInput1, freqInput2 := ctx.Fork2(freqInput)

	return ctx.Add(
		ctx.Mul(
			ctx.Square(
				freqInput1,
				ctx.Const(0.5),
			),
			ctx.Const(0.75),
		),
		ctx.Mul(
			ctx.Saw(
				ctx.Mul(freqInput2, ctx.Const(2)),
			),
			ctx.Const(0.25),
		),
	)
}
示例#4
0
func PlayTrebleNote(ctx sound.Context, freqInput chan float64, duration time.Duration) (stream chan float64) {
	freqInput1, freqInput2 := ctx.Fork2(freqInput)

	return ctx.TakeDuration(
		ctx.Add(
			ctx.Mul(
				ctx.Square(
					freqInput1,
					ctx.Const(0.5),
				),
				ctx.Const(0.75),
			),
			ctx.Mul(
				ctx.Saw(
					ctx.Mul(freqInput2, ctx.Const(2)),
				),
				ctx.Const(0.25),
			),
		),
		duration,
		true,
	)
}