From 2e7f28999815f25e26088012e52adfaf5c65f4d2 Mon Sep 17 00:00:00 2001 From: Marian Paul Date: Mon, 3 Oct 2022 15:29:20 +0200 Subject: [PATCH] Fix history size on RollingViewData and take buffer size --- .../AudioKitUI/Visualizations/NodeRollingView.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/AudioKitUI/Visualizations/NodeRollingView.swift b/Sources/AudioKitUI/Visualizations/NodeRollingView.swift index cbe2550..1774fd4 100644 --- a/Sources/AudioKitUI/Visualizations/NodeRollingView.swift +++ b/Sources/AudioKitUI/Visualizations/NodeRollingView.swift @@ -12,11 +12,11 @@ public class RollingViewData { private var history: [Float] public init(bufferSampleCount: UInt = 128, - bufferSize: UInt, + bufferSize: UInt32, framesToRMS: UInt = 128) { self.bufferSampleCount = bufferSampleCount self.framesToRMS = framesToRMS - history = [Float](repeating: 0.0, count: 1024) + history = [Float](repeating: 0.0, count: Int(bufferSize)) } public func calculate(_ nodeTap: RawDataTap) -> [Float] { @@ -50,13 +50,13 @@ public struct NodeRollingView: ViewRepresentable { backgroundColor: Color = .clear, isCentered: Bool = false, isFilled: Bool = false, - bufferSize: Int = 1024) { + bufferSize: UInt32 = 1024) { metalFragment = FragmentBuilder(foregroundColor: color.cg, backgroundColor: backgroundColor.cg, isCentered: isCentered, isFilled: isFilled) - nodeTap = RawDataTap(node, bufferSize: UInt32(bufferSize)) - rollingData = RollingViewData(bufferSize: UInt(bufferSize)) + nodeTap = RawDataTap(node, bufferSize: bufferSize) + rollingData = RollingViewData(bufferSize: bufferSize) } var plot: FloatPlot {