sine wave generator

Honestly, I just thought I would use 25 kHz because I need ultrasound to penetrate wood

So why pick a 40kHz transducer?

These things are not like loudspeakers with a roughly flat response across part of the audio spectrum - they peak massively at their resonant frequency; that's what they're designed for.

Generating 40kHz is relatively simple (a simple for loop with some padding will need a little tuning and experimentation), it just depends what else you need to be doing at the same time, but you seem to be avoiding the question.