Generating and playing ultrasound

I’m trying to get my computer to produce some high frequency tones in order to calibrate a bat detector, but I can’t get it to go higher than about 20kHz.

I’ve managed to create the tones in Audacity. I created a track, set it to 192kHz, and generated a 2000-20000Hz chirp, then used the Change Speed effect to make it 5 times faster. According to the spectrogram, the chirp is now 10kHz to nearly 100kHz.

When I play it, it dies out around 20kHz. I don’t know for sure whether this is a limitation of Audacity, Windows, the soundcard, or the speakers. I know the speakers will struggle with high frequencies, but I would have thought they’d be able to do at least a bit over 20kHz, so I’m suspicious that they aren’t the problem.

In Windows 7’s Audio Manager, I have changed what it calls the Default Format from 44100Hz to 192000Hz, although I don’t understand what that setting is really for. Is there something else I need to configure, or is this just not posssible?

The system is a Dell laptop, so the speakers are fairly small, which should help.

Most soundcards have anti-aliasing filters to keep them from going beyond audibility (20KHz).

You might be able to find and buy a USB connected soundcard that is listed for higher frequencies. It would have to say so.

The other possibility is drop by a pet store and try out a dog whistle. You would have to match the frequencies.


I suspect your speakers will not reach 100 kHz. There are very few tweeters that go up that high with any meaningful output.

Try and find a cheap piezo tweeter. These can attain 100 kHz with a lot of output even from a very puny amp as their impedance is around 5 to 15 kOhms and not 4 or 8 Ohms as a “normal” dynamic speaker. It also means you can put a lot of those in parallel to go up to even higher levels.

Thank, but at this stage I’d be grateful to even get to 30kHz.


If your soundcard really supports 192 kHz, the upper range is half, theoretically. 96 kHz. In practice, filtering would give you a little less, let’s say 95 kHz…

The amp will follow effortlessly, unless filtered, as Koz said. And a lot of them are filtered.

But no average speaker goes up to 30 kHz even. A crummy, piëzo speaker like you can find in musical greeting cards might. It might even be vert loud (relatively speaking) at 30 kHz, or at 66 kHz. And some crummy small dynamic speakers might resonate at 38 kHz or so, but then you 'r really need to be lucky.

There are other ways to get very high frequencies, like the parallel or serial ports, if your computer has one. Not with Audacity, of course, as it would be a square wave, digitally generated to use as an analog test signal.

Or a simple hardware thingy, with one 10 cents 555 timer IC and a couple resistors/C’s, if your handy with a soldering iron…

A friend has sent me a sample wav file containing 10 to 40kHz tones, and suggested I play it on my Sony PCM-M10 recorder. (which can play up to 96kHz files) It works and I can hear the tones using the bat detector.

I tried to use a wav file I generated in Audacity, but the detector doesn’t respond. So now I’m wondering if at least part of my problem is that I’m not generating the sound properly. This is how I did it:

  • Create a new stereo track (M10 won’t play mono wav files)
  • Set rate to 96kHz
  • Generate a 10kHz tone of 0.8 amplitude (because it won’t accept higher than 20kHz)
  • Use Change Speed effect to triple the speed to make it 30kHz
  • Export to wav file

I noticed that if I change the project rate at the bottom of the screen (which I’ve never noticed before) to 96kHz, the exported file is twice the size, so I guess it was downsampling on export before? That would explain the problem, but it still doesn’t work now that I’ve changed it. Is there something else I need to do. What do I have to do to create a 30kHz tone in a 96kHz wav file?

Generating a 30 kHz sine wave in a 96 kHz sample rate WAv file is easy.

  1. Open Audacity
  2. Set the project rate (lower left corner of the main Audacity window) to 96000.
  3. “Generate menu > Tone” set the frequency to 30000 Hz
  4. Export as a 16-bit WAV file.

Playing the 30 kHz sine wave has several problems:

  1. Can your sound card produce a 30 kHz frequency? Possibly but many sound cards are limited to a little over 20 kHz.
  2. Does your amp work up to 30 kHz? Some hi-fi amps will get close to 30 kHz, but others are limited to a little over 20 kHz.
  3. Do your speakers work up to 30 kHz? Most hi-fi speakers can manage 16 kHz pretty well. Some will manage 20 kHz. A few can get to about 25 kHz or even higher, for example Kef R700 speakers (about $1500) claim a frequency range up to 45 kHz.
    The overall chance of it working with standard domestic equipment is pretty low.

There’s a list of tweeters here with their frequency ranges shown. Most have a frequency range up to a little over 20 kHz, a few go up to 30 kHz or more.
You could also look up “ultrasonic transmitter”.

Aha, that’s why the Generate Tone command was limited to around 20kHz. I’ve never had to change the project rate, so it didn’t occur to me that the track rate was being overridden. But the way I did it (setting the project rate later) should still have exported the file ok, shouldn’t it? If I open it with Audacity, the spectrogram shows a 30kHz tone, so I guess it must have. Yet I’m getting nothing on the detector, so this file is somehow different to the one my friend generated (not with Audacity).

Playing the 30 kHz sine wave has several problems:

I’m getting around the hardware problem for now by playing the file on my M10 recorder. It can produce ultrasounds up to 40kHz ok playing my friend’s wav file. Maybe the tiny speaker helps a bit. It’s probably not very loud, but I’ve got the detector’s microphone right up against it.

There’s a list of tweeters here with their frequency ranges shown. Most have a frequency range up to a little over 20 kHz, a few go up to 30 kHz or more.
You could also look up “ultrasonic transmitter”.

If I can work out how to generate a file properly, and it turns out that my computer can play them, I’ll buy a piezo speaker. I’m told they can go pretty high.

It depends on the piezo speaker. Some of the ones in the link are piezo, and mostly they don’t go much over 20 kHz. On the other hand, there are piezo transmitters that are specifically designed for ultrasound. Look at the specs before you buy.

I’ll do that, but my immediate problem is generating the file. I’ll experiment more now that I know about project rates, and come back if I’ve still got problems.

I suspect a lot of speakers can go way higher than their ratings if you don’t mind a very poor response.

Speakers fall apart in ways that are a little magic. They don’t just grind to a halt. You can get the voice coil in the middle going at a different speed than the rest of the cone or diaphragm. What sound does that give you? Beats me. It’s unpredictable.

Then there’s: “Whats that burning smell?” Speakers aren’t designed to have one continuous tone applied. They warn you about that when you’re testing speakers with calibrated tones.

The piezo things do pretty well up there.


OK, so you “suspect” that to be the case, but if it does not work, how do you know whether it’s because your “suspicion” was incorrect or whether is is some other problem?

And put Adele through it every so often to make sure it’s still alive.


I was hoping I could tell by starting around 20kHz and gradually increasing it till it stops giving the expected results. Thanks for the warning though. I might make sure I use a cheap pair of earphones to avoid damaging the speakers.

Another thing to consider with piezo tweeters is that their impedance goes down as the frequency increases. At DC they act as “open circuit”, but at very high frequency they act as “short circuit”, which can burn out your amp unless you include a resistor in series with the piezo.


Thanks for the warning. I’m not sure how to safeguard against that.


Real sound. All these experiments are with sound only bats can hear. The speaker could be cooked and you would never know. Stop every so often and put music in to make sure the speaker is not smoking ruin.

And no we’re not making that up. One of the speaker failures is to have a mis-behaving amplifier that’s generating ultra sonic tones by accident. Some of the earlier non-tube amplifiers would do that. Your first indication of problems is muffled music and a burning smell. You can also get that if, as I said, you’re testing your speakers and you leave 20,000Hz applied too long.

I’m not sure how to safeguard against that (piezo shorting).

You put a fixed resistor between the amplifier and the piezo speaker. The speaker may exhibit some evil characteristics, but the resistor will not allow damage.

If you’re in the US and near one of the remaining Radio Shacks, I can give you part numbers. They scaled way back on the build-it-yourself tools and parts they carry, so it’s something of an adventure now.


That 8 ohm resistor and a package of colored clip wires are both standard Radio Shack parts.

You put the amplifier at one end and the peizo speaker on the other. It doesn’t matter which is at which end. No matter what the piezo does or at what frequency, the amplifier will not care. It’s protected by that white block (power resistor) in the middle. The system is good up to an amplifier power of about 20 Watts.

I get about $12 USD.