     }
 
     func handlePinchGesture(_ recognizer: UIPinchGestureRecognizer) {
-        if !self.doesAllowStretch {
+        if !doesAllowStretch {
             return
         }
         if recognizer.scale == 1 {
             return
         }
         let middleSamples = CGFloat((zoomStartSamples + zoomEndSamples) / 2)
-        let rangeSamples = CGFloat(self.zoomEndSamples - self.zoomStartSamples)
+        let rangeSamples = CGFloat(zoomEndSamples - zoomStartSamples)
         if middleSamples - 1.0 / recognizer.scale * CGFloat(rangeSamples) >= 0 {
-            self.zoomStartSamples = Int(CGFloat(middleSamples) - 1.0 / recognizer.scale * CGFloat(rangeSamples) / 2)
+            zoomStartSamples = Int(CGFloat(middleSamples) - 1.0 / recognizer.scale * CGFloat(rangeSamples) / 2)
         }
         else {
-            self.zoomStartSamples = 0
+            zoomStartSamples = 0
         }
         if middleSamples + 1 / recognizer.scale * CGFloat(rangeSamples) / 2 <= CGFloat(totalSamples) {
-            self.zoomEndSamples = Int(middleSamples + 1.0 / recognizer.scale * rangeSamples / 2)
+            zoomEndSamples = Int(middleSamples + 1.0 / recognizer.scale * rangeSamples / 2)
         }
         else {
-            self.zoomEndSamples = self.totalSamples
-        }
-        self.setNeedsDisplay()
-        self.setNeedsLayout()
+            zoomEndSamples = totalSamples
+        }
+        setNeedsDisplay()
+        setNeedsLayout()
         recognizer.scale = 1
     }
 
     func handlePanGesture(_ recognizer: UIPanGestureRecognizer) {
         let point = recognizer.translation(in: self)
-        if self.doesAllowScroll {
+        if doesAllowScroll {
             if recognizer.state == .began {
                 delegate?.waveformDidEndPanning?(self)
             }
-            var translationSamples = Int(CGFloat(self.zoomEndSamples - self.zoomStartSamples) * point.x / self.bounds.size.width)
+            var translationSamples = Int(CGFloat(zoomEndSamples - zoomStartSamples) * point.x / bounds.size.width)
             recognizer.setTranslation(CGPoint.zero, in: self)
-            if self.zoomStartSamples - translationSamples < 0 {
-                translationSamples = self.zoomStartSamples
-            }
-            if self.zoomEndSamples - translationSamples > self.totalSamples {
-                translationSamples = self.zoomEndSamples - self.totalSamples
-            }
-            self.zoomStartSamples -= translationSamples
-            self.zoomEndSamples -= translationSamples
+            if zoomStartSamples - translationSamples < 0 {
+                translationSamples = zoomStartSamples
+            }
+            if zoomEndSamples - translationSamples > totalSamples {
+                translationSamples = zoomEndSamples - totalSamples
+            }
+            zoomStartSamples -= translationSamples
+            zoomEndSamples -= translationSamples
             if recognizer.state == .ended {
                 delegate?.waveformDidEndPanning?(self)
-                self.setNeedsDisplay()
-                self.setNeedsLayout()
-            }
-            else if self.doesAllowScrubbing {
+                setNeedsDisplay()
+                setNeedsLayout()
+            }
+            else if doesAllowScrubbing {
                 let rangeSamples = CGFloat(zoomEndSamples - zoomStartSamples)
-                progressSamples = Int(CGFloat(zoomStartSamples) + rangeSamples * recognizer.location(in: self).x / self.bounds.size.width)
+                progressSamples = Int(CGFloat(zoomStartSamples) + rangeSamples * recognizer.location(in: self).x / bounds.size.width)
             }
         }
     }
 
     func handleTapGesture(_ recognizer: UITapGestureRecognizer) {
-        if self.doesAllowScrubbing {
+        if doesAllowScrubbing {
             let rangeSamples = CGFloat(zoomEndSamples - zoomStartSamples)
-            progressSamples = Int(CGFloat(zoomStartSamples) + rangeSamples * recognizer.location(in: self).x / self.bounds.size.width)
+            progressSamples = Int(CGFloat(zoomStartSamples) + rangeSamples * recognizer.location(in: self).x / bounds.size.width)
         }
     }
 }

    /// The first sample to render
    @IBInspectable open var zoomStartSamples: Int = 0 {
        didSet {
            self.setNeedsDisplay()
            self.setNeedsLayout()
        }
    }

    /// One plus the last sample to render
    @IBInspectable open var zoomEndSamples: Int = 0 {
        didSet {
            self.setNeedsDisplay()
            self.setNeedsLayout()
        }
    }


        let childFrame = CGRect(x: frame.size.width * scaledX, y: 0, width: frame.size.width * scaledWidth, height: frame.size.height)
        image.frame = childFrame
        highlightedImage.frame = childFrame
        clipping.frame = CGRect(x: 0, y: 0, width: frame.size.width * scaledProgressWidth, height: frame.size.height)
        clipping.isHidden = progressSamples <= zoomStartSamples
        print("\(frame) -- \(image.frame)")
    }

