     /// Reversed sawtooth waveform from 0-1
     case positiveReverseSawtooth
 
-
 }
 
 /// A table of values accessible as a waveform or lookup mechanism
 public struct AKTable: MutableCollection {
-
-    // MARK: - Properties
-
-    /// Values stored in the table
-    private var content = [Float]()
-
-    public var phase: Double {
+    public typealias Index = Int
+    public typealias IndexDistance = Int
+    public typealias Element = Float
+    public typealias SubSequence = ArraySlice<Element>
+
+    // MARK: - Properties    /// Values stored in the table
+
+    private var content = [Element]()
+
+    public var phase: Float {
         didSet {
             phase = (0...1).clamp(phase)
         }
     }
 
-    public var startIndex: Int {
+    public var startIndex: Index {
         return content.startIndex
     }
 
-    public var endIndex: Int {
+    public var endIndex: Index {
         return content.endIndex
     }
 
-    public subscript(index: Int) -> Float {
+    public subscript(index: Index) -> Element {
         get {
             return content[index]
         }
         set {
-            return content[index] = newValue
-        }
-
-
-    }
-    
-    /// Returns the position immediately after the given index.
-    ///
-    /// - Parameter i: A valid index of the collection. `i` must be less than
-    ///   `endIndex`.
-    /// - Returns: The index value immediately after `i`.
-    public func index(after i: Int) -> Int {
-        return i + 1
-    }
-
+            content[index] = newValue
+        }
+    }
+
+    public subscript(bounds: Range<Index>) -> SubSequence {
+        get {
+            return content[bounds]
+        }
+        set {
+            content[bounds] = newValue
+        }
+    }
 
     /// Type of table
     var type: AKTableType

    ///   - size: Size of the table (multiple of 2)
    ///
    public init(_ type: AKTableType = .sine,
                  phase: Double = 0,
                  count: Int = 4096) {
        self.type = type
        self.phase = phase
        
        self.content = [Float](zeroes: count)
        
        switch type {
        case .sine:
            self.standardSineWave()

        }
    }
}

extension AKTable: RandomAccessCollection  {
    public typealias Indices = Array<Element>.Indices

    @inline(__always)
    public func index(before i: Index) -> Index {
        return i - 1
    }

    @inline(__always)
    public func index(after i: Index) -> Index {
        return i + 1
    }

    @inline(__always)
    public func index(_ i: Index, offsetBy n: Index) -> Index {
        return i + n
    }

    @inline(__always)
    public func formIndex(after i: inout Index) {
        i += 1
    }
    
    @inline(__always)
    public func distance(from start: Index, to end: Index) -> IndexDistance {
        return end - start
    }
}
