So I need to program (using Java) some things that include generated sounds. I am struggling to understand how to make it work because I require a rather short signal while still using a sampling rate supported by the average sound card. For example a 100 uSec beep with a 200 uSec delay followed by another beep (initially supposed to be a click but a sine wave also works, would be grateful if you could explain why a sine wave makes it simpler).

My understanding is that I need a high sampling rate (number of samples per second), a frequency within hearing range (for example 1000) and a buffer to hold that data that will be fed to the audio stream provided by the Java libraries. The issue is that with my limit of sampling rate (hardware limitations) I end up with an almost completely empty buffer because of the tiny intervals of sound it must hold to meet the time requirements.

Am I missing something? Is there another way? Why does using a sine wave instead of a click make things easier? Any help would be appreciated.

  • 2
    $\begingroup$ you can't make a beep of 1 kHz that's only 100 μs long. is it supposed to be 100 ms? $\endgroup$
    – endolith
    Commented Apr 25, 2016 at 18:16
  • $\begingroup$ I don't think sine waves make it any easier. $\endgroup$ Commented Apr 25, 2016 at 19:07

1 Answer 1


If you want to generate a very short pulse, it is not usually a problem to have it at any time you wish to have it. That is because modern audio interfaces (sound cards) have an interpolating lowpass filter in the output path, usually with an impulse response that without latency looks like the sinc function:

sinc function
Figure 1. Sinc function, shown truncated at the ends and critically sampled with the sample number shown in the horizontal axis.

If you play back audio data that is sampled from a time-shifted sinc function with the peak somewhere between sample points, the interpolating lowpass filter will reconstruct the function from the samples so that the peak is in the correct position. Some audio interfaces use a low-latency variant of the lowpass filter that does not have a symmetrical sinc impulse response. Disregarding latency, it has just as good inter-sample timing capabilities if you give it samples of a time-shifted sinc function.

If you need a more rectangular pulse, you could add an analog comparator to the output of the audio interface. You can change the pulse length by varying the voltage level you compare to.

First test if you get that sinc shape from your hardware, like MBaz suggested.

  • $\begingroup$ Waw, they managed to implement non-causal filters ! $\endgroup$
    – user7657
    Commented Jul 24, 2016 at 21:55
  • $\begingroup$ @YvesDaoust the latency makes it causal. $\endgroup$ Commented Jul 25, 2016 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.