如果我只将AKOscillator用于特定目的,我是否应该在启动/停止振荡器时使用包络类来避免振幅滴答声?或者还有其他更简单的方法吗?
发布于 2019-10-04 02:41:47
一种“轻”方法是将参数ramp设置为非零值,将振幅从零开始,然后设置振幅。但是,所有参数的渐变都是相同的值,因此,根据您是否希望在不同的渐变上更改频率,您可能需要在渐变达到所需的振幅后再次更改渐变。
下面是一个示例游乐场:
import AudioKitPlaygrounds
import AudioKit
let oscillator = AKOscillator(waveform: AKTable(.sine), amplitude: 0)
oscillator.rampDuration = 0.2
AudioKit.output = oscillator
try AudioKit.start()
oscillator.start()
oscillator.amplitude = 1.0
sleep(1)
oscillator.amplitude = 0发布于 2019-10-09 21:38:36
我用了你的代码,它没有帮助,但我发现这个‘点击’出现在最后,当振荡器停止。因此,即使rampDuration是0.0,在开头也没有‘单击’,唯一的‘单击’在结尾。以下是我的代码(它在IOS应用程序中):
类ViewController: UIViewController {
var osc = AKOscillator(waveform: AKTable(.sine), amplitude: 0)
@IBAction func buttonTapped(_ sender: UIButton) { //when button in App is pressed
osc.rampDuration = 0.2
AudioKit.output = osc
osc.frequency = Double.random(in: 100.0...1000.0)
try? AudioKit.start()
osc.start()
osc.amplitude = 0.5
osc.rampDuration = 0.0 //to avoid frequency glide effect
sleep(1)
//osc.rampDuration - I tried to change rampDuration before oscillator stop, but it
//did not help
osc.stop() //here is amplitude 'click' appears
try? AudioKit.stop()
}那么,就像我假设我必须使用信封一样?
https://stackoverflow.com/questions/58209753
复制相似问题