     func render(buffer:AVAudioPCMBuffer) -> Bool {
         let sampleCount = Int(self.length * UInt64(SampleRate) / 1000)
 
-        if (self.frequencies.count == sampleCount) {
+        if (self.frequencyBuffer != nil) {
             for (var i = Int(0); i < sampleCount; i++) {
-                let value = volumes[i] * sin(Float(i) * 2 * π * self.frequencies[i] / SampleRate)
+                let value = (volumeBuffer?.floatChannelData.memory[i])! * sin(Float(i) * 2 * π * (self.frequencyBuffer?.floatChannelData.memory[i])! / SampleRate)
                 buffer.floatChannelData.memory[i] = value
                 // second channel
                 buffer.floatChannelData.memory[sampleCount + i] = value

        }

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

    }

        else {
            // fallback -> static frequency of 440hz

            if (self.volumeBuffer != nil) {
                for (var i = Int(0); i < sampleCount; i++) {
                    let value = (self.volumeBuffer?.floatChannelData.memory[i])! * sin(Float(i) * 2 * π * 440 / SampleRate)
                    buffer.floatChannelData.memory[i] = value
                    // second channel
                    buffer.floatChannelData.memory[sampleCount + i] = value
