The API for this is being discussed (perhaps too much) on the Arduino developer mail list right now. Actually, for the last 5 days.
If you could very briefly mention why you need 31 kHz, it might really help. But please do so on that other thread. That's where I'll (probably soon) be posting code.