Aircraft: A320
Phase of flight: Cruise
Anomaly: Aircraft Equipment Problem Critical

Flight suffered a Number 2 Engine compressor stall and a subsequent engine failure. The seat belt sign was on. The flight was descending to FL340 due to chop at FL350. We had initially started a climb to FL370 but had reversed and started a descent after ATC informed us that the next sector had mod chop at that altitude. In the descent; in smooth air; open descent; Mach .78; managed speed. We heard a thump. Not the loud banging we had in training; just enough to wonder 'what was that'. Our attention went to the engine instruments and everything was normal; then the Purser called to say he had heard a loud bang from the right side of the aircraft. I told him we were aware of the odd noise and I would get back to him. We scanned the engine instruments and saw a momentary flash of amber stall on the upper screen; but it lasted only a second or so. Then the Engine 2 oil filter clog amber annunciation came on. I immediately grabbed the Flight Manual to start looking for the correct procedure. The Purser called us again to say he heard another loud bang. I told the First Officer (pilot not flying) to fly and handle the communications and I would work the problem. We requested a lower altitude from ATC; and ATC asked us if we could stay at FL340; for another minute. We said yes. I continued to try and find the Oil Clog procedure when the pilot flying said the Number 2 Engine had failed; I declared an emergency and requested lower FL250; from the engine out data on the FMC. That was issued by ATC and I began to complete the engine failure ECAM that had just popped up on the screen. I sent Dispatch a message to CALL ME and continued the running and completing the ECAM. Dispatch responded with a frequency; which I put into the VHF #2 and passed along our current condition; and divert information to [nearest suitable airport]. We had continued our descent to 12;000 FT and subsequently got a descent to 6;000 FT navigating with ATC vectors to the airfield. I called the Purser to inform him of the time remaining; destination; weather and landing conditions.Fortunately all the back up systems were working perfectly and the weather was better than CAT 1 minimums; with the runway clear and dry. I decided not to prep as the aircraft was flying well with all systems backed up. It was about 15 minutes before touchdown. We completed all the checklists and continued down to 4;000 FT at 15 NM south of the airfield. Immediately after checklist completion we notified ATC and they gave us a vector to the localizer for the ILS to the field. Approach and landing were normal; we rolled out straight ahead and stopped on the runway to allow the emergency vehicles and crew to checkout our engine. Everything was reported to look normal from the chief of the firefighters so we taxied clear of the runway and to the gate. The flight taxied to the gate and shut down normally. Once at the gate my phone was ringing constantly; even before we were out of the seats. I forgot to place a write-up into the ACARS; partly due to the phone calls from Operations and others who I relayed our flight problems to. I subsequently called [Maintenance] later that night to check if I had indeed forgot to enter it. The technician I talked to said yes but that all the information was inputted from transmitted data and some others I had talked to. [Narrative 2 had no additional information.] A320 flight crew reported compressor stall and subsequent failure of #2 engine at FL340. Flight declared an emergency and diverted to nearest suitable airport.