         }
 
         let decibelSamples = sharedBot.decibelSamples
+        let realSamplingInterval = min(samplingInterval, decibelSamples.count / minNumberOfDecibelSamples)
         var samples: [Float] = []
         var i = 0
         while i < decibelSamples.count {
             samples.append(decibelSamples[i])
-            i += samplingInterval
+            i += realSamplingInterval
         }
 
         let finalNumber = f(samples.count, max: maxNumberOfDecibelSamples)

        NSFileManager.audiobot_removeAudioAtFileURL(fileURL)
    }

    public class func compressDecibelSamples(decibelSamples: [Float], withSamplingInterval samplingInterval: Int, maxNumberOfDecibelSamples: Int) -> [Float] {

        func f(x: Int, max: Int) -> Int {
            let n = 1 - 1 / exp(Double(x) / 100)

        let compressedDecibelSamples = averageSamplingFrom(samples, withCount: finalNumber)
        
        return compressedDecibelSamples
    }}

// MARK: - Playback

