Changing the length of the Tone Generator

Hello. I need to generate a tone with a very precise term, I find that the rate is more precise term for “samples” but yet I do not even cover all the “decimal.”

For example, I generate a tone in 0.04545454545 Seconds exact duration or the equivalent in Samples: 2.00454545455

How I can modify this function tone generator for me to get more value?

I appreciate any ideas.

It is impossible to generate a tone to a greater accuracy than one sample.
Digital audio is just a series of numbers. Each individual sample is a number. You can have a sound that has 14 samples (a series of 14 numbers) or 15 samples (a series of 15 numbers) but you can’t have 14.5 numbers. Thus the duration accuracy is limited by the sample rate.

If your digital audio has a sample rate of 44100 Hz, that means there are 44100 samples for each 1 second of audio. (44100 points - the value of each point is defined by a number - the number is the sample “value”). That means that the greatest duration accuracy possible at 44100 Hz sample rate is 1/44100 second = 0.000022676 seconds

At a higher sample rate of 96 kHz (96000 Hz) there are 96000 samples per second, so the accuracy that is achievable is 1/96000 = 0.000010417 seconds = 0.010416667 milliseconds.
See here for more information about digital audio:

You can use Nyquist to produce tones that are accurate to the exact number of samples required.
For example, if you want to generate 441 samples of a 1kHz sine tone, you can use the following code in the “Nyquist Prompt” effect:

(setq num 441)
(abs-env (sustain (/ num *sound-srate*)(hzosc 1000)))

thank you very much, helped me a lot your information.

Just a note that if you try to listen to that tone in real life, you will not get a pure tone during start and stop. Any sound during a change is distorted and generates other tones – if only for a short time. It’s the principal of AM radio.

As long as you stay strictly in digital which has no real world restrictions, you should be OK. What is the job?


(( I learn to develop Isochronic tones, for brain entrainment.
Thanks to stevethefiddle I realized that changing sample rate I can do more accurate to calculate one cycle series per second.

My question now is: the higher sample rate improves the quality of tone? ))

Nyquist and Shannon give a much better explanation than I could ever give :–Shannon_sampling_theorem

Ok, then with only find be accurate I can configurate that sample rate. Thanks for you quote.