 
     /// Instantiate the table as a sawtooth wave
     mutating func standardSawtoothWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase * size)
-        for i in 0 ..< size {
-            values[i] = -1.0 + 2.0 * Float((i + phaseOffset) % size) / Float(size)
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            values[i] = -1.0 + 2.0 * Float((i + phaseOffset) % count) / Float(count)
         }
     }
 
     /// Instantiate the table as a reverse sawtooth wave
     mutating func standardReverseSawtoothWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase * size)
-        for i in 0..<size {
-            values[i] = 1.0 - 2.0 * Float((i + phaseOffset) % size) / Float(size)
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            values[i] = 1.0 - 2.0 * Float((i + phaseOffset) % count) / Float(count)
         }
     }
 
     /// Instantiate the table as a sine wave
     mutating func standardSineWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase * size)
-        for i in 0 ..< size {
-            values[i] = sin(2 * 3.14159265 * Float(i + phaseOffset) / Float(size))
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            values[i] = sin(2 * 3.14159265 * Float(i + phaseOffset) / Float(count))
         }
     }
 
     /// Instantiate the table as a triangle wave
     mutating func positiveTriangleWave() {
-        values = [Float](zeroes: size)
-        let slope = Float(2.0) / Float(size)
-        for i in 0..<size {
-            let phaseOffset = Int(phase * size)
-            if (i + phaseOffset) % size < size / 2 {
-                values[i] = slope * Float((i + phaseOffset) % size)
-            } else {
-                values[i] = slope * Float((-i - phaseOffset) % size) + 2.0
+        values = [Float](zeroes: count)
+        let slope = Float(2.0) / Float(count)
+        for i in indices {
+            let phaseOffset = Int(phase * count)
+            if (i + phaseOffset) % count < count / 2 {
+                values[i] = slope * Float((i + phaseOffset) % count)
+            } else {
+                values[i] = slope * Float((-i - phaseOffset) % count) + 2.0
             }
         }
     }
 
     /// Instantiate the table as a square wave
     mutating func positiveSquareWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase * size)
-        for i in 0 ..< size {
-            if (i + phaseOffset) % size < size / 2 {
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            if (i + phaseOffset) % count < count / 2 {
                 values[i] = 0.0
             } else {
                 values[i] = 1.0

}

/// A table of values accessible as a waveform or lookup mechanism
public struct AKTable {

    // MARK: - Properties


    
    /// Number of values stored in the table
    var size = 4096

    public var startIndex: Int {
        return values.startIndex
    }

    public var endIndex: Int {
        return values.endIndex
    }

    public subscript (index: Int) -> Float {
        return values[index]
    }

    /// Type of table
    var type: AKTableType
