     private func resetVolume() {
         let sampleCount = UInt32(self.length * UInt64(SampleRate) / 1000)
 
-        self.volumes = Array<Float>()
-        for (var i:UInt32 = 0; i < sampleCount; i++) {
-            self.volumes.append(Float(1))
+        self.volumeBuffer = getBuffer()
+
+        for (var i:Int = 0; i < Int(sampleCount); i++) {
+            self.volumeBuffer?.floatChannelData.memory[i] = Float(1)
         }
     }
 
     private func renderFadeIn(wantedStart:UInt32) {
         let sampleCount = UInt32(self.length * UInt64(SampleRate) / 1000)
 
-        if (UInt32(self.volumes.count) != sampleCount) {
+        if (self.volumeBuffer?.frameLength < sampleCount) {
             resetVolume()
         }
 

        }

        for (var i = 0; i < count; i++) {
            self.volumes[start +  i] *= Float(1) - (Float(i) / Float(count))
        }

    }

    private var volumeSequence = [Float(1), Float(1)]
    private var toneSequence = Array<Tone>()

    private var frequencyBuffer:AVAudioPCMBuffer?
    private var volumeBuffer:AVAudioPCMBuffer?

    init(length: UInt64) {
        self.length = length
    }

    // create a buffer with oscillations length of float samples
    private func getBuffer() -> AVAudioPCMBuffer {
        let sampleCount = UInt32(self.length * UInt64(SampleRate) / 1000)

        return AVAudioPCMBuffer(PCMFormat: AVAudioFormat(standardFormatWithSampleRate: Double(SampleRate), channels: 1),
                                frameCapacity:AVAudioFrameCount(sampleCount))

    }

    func setVolumeSequence(sequence:Array<Float>) {
