 
 let pi = M_PI
 
-@IBDesignable class SiriWaveformView: UIView
-{
+@IBDesignable
+class SiriWaveformView: UIView {
     private var _phase: CGFloat = 0.0
     private var _amplitude: CGFloat = 0.0
 

            let maxAmplitude = halfHeight - 4.0 // 4 corresponds to twice the stroke width

            // Progress is a value between 1.0 and -0.5, determined by the current wave idx, which is used to alter the wave's amplitude.
            let progress = CGFloat(1.0 - Float(i) / Float(numberOfWaves))
            let normedAmplitude = (1.5 * progress - 0.5) * amplitude

            // var multiplier = CGFloat(min(1.0, (progress / 3.0 * 2.0) + (1.0 / 3.0)))
            let multiplier = CGFloat(1.0)
            waveColor.colorWithAlphaComponent(multiplier * CGColorGetAlpha(waveColor.CGColor)).set()

            for var x: CGFloat = 0.0; x < width + density; x += density {
                // We use a parable to scale the sinus wave, that has its peak in the middle of the view.
                let scaling = -pow(1 / mid * (x - mid), 2) + 1

                // Original Code:
                // CGFloat y = scaling * maxAmplitude * normedAmplitude * sinf(2 * M_PI *(x / width) * self.frequency + self.phase) + halfHeight;
                let tempCasting = CGFloat(2.0 * Float(pi) * Float(x / width)) * frequency + _phase
                let y = scaling * maxAmplitude * normedAmplitude * CGFloat(sinf(Float(tempCasting))) + halfHeight

                if x == 0 {

                } else {
                    CGContextAddLineToPoint(context, x, y)
                }

                x += density
            }
            
            CGContextStrokePath(context)
