         if readFile.points.count > countOfIntervals {
             interval = Int(readFile.points.count / countOfIntervals)
         }
-        for _ in (readFile.points) {
+        
+        _ = readFile.points.map { _ in
             if i % interval == 0 {
                 var x:CGFloat = 2.5
                 aPath.move(to: CGPoint(x:aPath.currentPoint.x + x , y:aPath.currentPoint.y))

        readFile.points = downSampledData.map{CGFloat($0)}
    }
    
    func readArray( array:[Float]){
        readFile.arrayFloatValues = array
    }
    
    func addDurationOfFileWith(url: URL?) {
        do {
            let file = try AVAudioFile(forReading: fileUrl!)
            let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: file.fileFormat.sampleRate, channels: file.fileFormat.channelCount, interleaved: false)
            
            let recAsset = AVAsset(url: fileUrl!)
            duration = recAsset.duration.seconds
            
            let buf = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: UInt32(file.length))
            try file.read(into: buf!)
            readFile.arrayFloatValues = Array(UnsafeBufferPointer(start: buf!.floatChannelData?[0], count:Int(buf!.frameLength)))
        }catch {
            print(error)
        }
    }
    
}

struct readFile {
    static var arrayFloatValues: [Float] = []
    static var points: [CGFloat] = []
}

class SonogramView: UIView {
    
    @IBInspectable var sonogramColor: UIColor = UIColor(red: 212.0/255.0, green: 216.0/255.0, blue: 217.0/255.0, alpha: 1.0)
    @IBInspectable var shapeColor: UIColor = UIColor(red: 232/255, green: 59/255, blue: 86/255, alpha: 1.0)
    @IBInspectable var animationFromColor: UIColor = UIColor(red: 212.0/255.0, green: 216.0/255.0, blue: 217.0/255.0, alpha: 1.0)
    @IBInspectable var animationToColor: UIColor = UIColor.red
    
    var shapeLayer: CAShapeLayer!
    var duration: Double = 0
    
    // override draw
    
    override func draw(_ rect: CGRect) {
        drawMyView(rect: rect)
    }
    
    // MARK: public API
    
    func addDurationOfFileWith(url: URL) {
        do {
            let file = try AVAudioFile(forReading: url)
            let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: file.fileFormat.sampleRate, channels: file.fileFormat.channelCount, interleaved: false)
            
            let recAsset = AVAsset(url: url)
            duration = recAsset.duration.seconds
            
            let buf = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: UInt32(file.length))!
            try file.read(into: buf)
            readFile.arrayFloatValues = Array(UnsafeBufferPointer(start: buf.floatChannelData?[0], count:Int(buf.frameLength)))
        } catch {
            print(error)
        }
    }
    
    // MARK: private API
    
    private func drawMyView(rect: CGRect) {
        convertToPoints()
        var f = 0
        let aPath = UIBezierPath()
        
        aPath.lineWidth = 2.0
