You can use the Renfe website to check prices. When you enter your trip info, check the "tarjeta dorada" box. The site will give you the lowest price available. I just looked at Madrid-Sevilla for May 30, the price for the AVE train (fastest) is €45.80.
You can't get the discount on the Renfe site until you have the TD card number. Once you are in Spain you can buy tickets in advance on the Renfe site (use Paypal - most US credit cards don't work) or in person (cash or credit card) at any train station. You need to show proof of age when you buy the TD card - I used my driver's license last time. It was €6. If you're landing at El Prat and taking the train into the city, buy the TD card at the Renfe station at the airport, though if you're staying near Placa Catalunya, the bus is better.
I've bought train tickets at Barcelona Sants - long lines, but you get a number and sit and wait BUT there are lines for different types of tickets so be careful. Avoid buying tickets at Madrid Atocha station! Lines are very long.