 
     /// Instantiate the table as a sawtooth wave
     mutating func positiveSawtoothWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase * size)
-        for i in 0 ..< size {
-            values[i] = Float((i + phaseOffset) % size) / Float(size)
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            values[i] = Float((i + phaseOffset) % count) / Float(count)
         }
     }
 
     /// Instantiate the table as a reverse sawtooth wave
     mutating func positiveReverseSawtoothWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase * size)
-        for i in 0 ..< size {
-            values[i] = 1.0 - Float((i + phaseOffset) % size) / Float(size)
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            values[i] = 1.0 - Float((i + phaseOffset) % count) / Float(count)
         }
     }
 
     /// Instantiate the table as a sine wave
     mutating func positiveSineWave() {
-        values = [Float](zeroes: size)
-        let phaseOffset = Int(phase*size)
-        for i in 0 ..< size {
-            values[i] = 0.5 + 0.5 * sin(2 * 3.14159265 * Float(i + phaseOffset) / Float(size))
+        values = [Float](zeroes: count)
+        let phaseOffset = Int(phase * count)
+        for i in indices {
+            values[i] = 0.5 + 0.5 * sin(2 * 3.14159265 * Float(i + phaseOffset) / Float(count))
         }
     }
 }

}

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

    // MARK: - Properties



    /// Instantiate the table as a sawtooth wave
    mutating func standardSawtoothWave() {
        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: 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: 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: 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: 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
