     private func process(_ samples: UnsafeMutablePointer<Int16>,
                          ofLength sampleLength: Int,
                          from assetReader: AVAssetReader,
-                         downsampledTo targetSampleCount: Int) -> [Float] {
+                         downsampledTo targetSampleCount: Int,
+                         samplesPerPixel: Int) -> [Float] {
         var loudestClipValue: Float = 0.0
         var quietestClipValue = silenceDbThreshold
         var zeroDbEquivalent: Float = Float(Int16.max) // maximum amplitude storable in Int16 = 0 Db (loudest)

                    let processedSamples = process(blockSamples,
                                                   ofLength: sampleLength,
                                                   from: assetReader,
                                                   downsampledTo: targetSampleCount)
                    outputSamples += processedSamples
                }
            }

    fileprivate func extract(samplesFrom assetReader: AVAssetReader, downsampledTo targetSampleCount: Int) -> [Float] {
        var outputSamples = [Float]()

        // read upfront to avoid frequent re-calculation (and memory bloat)
        let samplesPerPixel = max(1, sampleCount(from: assetReader) / targetSampleCount)

        assetReader.startReading()
        while assetReader.status == .reading {
            let trackOutput = assetReader.outputs.first!
