【问题标题】:Using AudioKit to plot Waveform of samplefile in UIView使用 AudioKit 在 UIView 中绘制样本文件的波形
【发布时间】:2018-07-13 23:04:59
【问题描述】:

我正在 Swift 和 AudioKit 中迈出第一步。我在操场上玩了一点。现在我正在尝试在 UIView 中绘制样本的波形。

我的代码不起作用。 UIView 保持空白。

@IBOutlet weak var audioOutputPlot: EZAudioPlot!

override func viewDidLoad() {
    super.viewDidLoad()

    let file = try! AKAudioFile(readFileName: "Sounds/drumloop_1.wav")
    let player = try! AKAudioPlayer(file: file)
    let plot = AKNodeOutputPlot(player, frame: audioOutputPlot.bounds)
    plot.plotType = .buffer
    plot.shouldFill = true
    plot.shouldMirror = true
    plot.color = UIColor.blue

    audioOutputPlot.addSubview(plot)

}

我已将 @IBOutlet audioOutputPlot 与 UIView 与 Interface Builder 连接起来,并在其自定义类中编写了“EZAudioPlot”。

感谢您的帮助!

【问题讨论】:

    标签: ios swift waveform audiokit


    【解决方案1】:

    我认为您已经在 viewDidLoad 中本地声明了文件、播放器和绘图,而这些都被遗忘了。

    【讨论】:

      猜你喜欢
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多