[英]AudioKit 5 Amplitude Envelope no sound
I'm new here and new with music apps (and programming in general).我是新来的,刚接触音乐应用程序(以及一般的编程)。
I'm trying to build a synth app using AudioKit 5 for my final project.我正在尝试使用AudioKit 5为我的最终项目构建一个合成器应用程序。 I made an oscillator and tried to add Amplitude Envelope but no sound coming out.
我制作了一个振荡器并尝试添加振幅包络,但没有发出声音。 (If I put the oscillator in the output - there is a sound.)
(如果我将振荡器放在输出中 - 会有声音。)
I saw this question in the internet several times in different types but without any solution.我在互联网上多次看到不同类型的这个问题,但没有任何解决方案。
Does anyone know what is the problem?有谁知道是什么问题? And if not - do you have other solution for envelope?
如果没有 - 你有其他信封解决方案吗?
The code:代码:
import AudioKit
import SoundpipeAudioKit
import UIKit
class TryingViewController: UIViewController {
var osc = Oscillator(waveform: Table(.sine), frequency: 440, amplitude: 0.8)
var engine = AudioEngine()
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func onBtn(_ sender: UIButton) {
let envelope = AmplitudeEnvelope(osc)
envelope.attackDuration = 0.1
envelope.decayDuration = 0.01
envelope.sustainLevel = 0.5
envelope.releaseDuration = 0.3
osc.start()
do {
try engine.start()
} catch {
print(error, "Field")
}
engine.output = envelope
envelope.start()
}
@IBAction func offBtn(_ sender: UIButton) {
osc.stop()
}
}
Edit:编辑:
I add this code and it works now, thanks to Aurelius Prochazk!感谢 Aurelius Prochazk,我添加了这段代码,现在它可以工作了!
var isGateOpend = false
.
.
.
if isGateOpend{
envelope.closeGate()
isGateOpend = false
} else {
envelope.openGate()
isGateOpend = true
}
I still have a click, but I will open another question about it if I won't figure it out.我仍然有一个点击,但如果我不明白,我会打开另一个关于它的问题。
Thanks in advance!提前致谢!
AmplitudeEnvelope 是一个“门控”节点,这意味着它响应 openGate 和 closeGate,应该使用它们而不是开始停止,因为它们处于节点级别而不是控制级别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.