Tone Generator Inaccuracies?

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
sonusmagus
Posts: 12
Joined: Thu Jun 16, 2016 8:59 pm
Operating System: macOS 10.15 Catalina or later

Tone Generator Inaccuracies?

Post by sonusmagus » Thu Jun 16, 2016 9:06 pm

I need to create very accurate tones @ 96K

I tried to create a 830.61Hz sine wave @ 96K

To get a perfect loop I should be able to multiply 830.61 X 9600 = 7973856 (or 83.061 seconds)

Then simply set start of loop at zero and end of loop at 7973856 and it SHOULD be 100% accurate

When I generate the tone and look at what has been calculated, something is wrong

This has always worked for me with Sound Forge

Any ideas on this?

Thanks

TINLEY

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Tone Generator Inaccuracies?

Post by steve » Thu Jun 16, 2016 11:19 pm

A frequency of 830.61 Hz has a period of 1/830.61 seconds.
At 96000 Hz sample rate, to convert seconds to samples, multiply seconds by 96000.
So a single cycle at 830.61 Hz would be 96000/830.61 = 115.57770795 sample periods.

68991 cycles of 830.61 Hz at 96000 Hz sample rate would be:
1 cycle period = 96000/830.61 samples
68991 cycles = (68991 * 96000)/ 830.61 = 7973821.64914942
So 7973822 samples will be very nearly perfect.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

sonusmagus
Posts: 12
Joined: Thu Jun 16, 2016 8:59 pm
Operating System: macOS 10.15 Catalina or later

Re: Tone Generator Inaccuracies?

Post by sonusmagus » Thu Jun 16, 2016 11:31 pm

I had the first calculation, thanks

But where does 68991 come from?

What would make it perfect?

Can I do this:

83061 cycles of 830.61 Hz at 96000 Hz sample rate would be:
1 cycle period = 96000/830.61 samples
83061 cycles = (83061 * 96000)/ 830.61 = 9600000
So 96000.00 samples will be perfect

I was trying to account for the two decimal places and over complicating it

Now makes perfect sense to me

Thanks

TINLEY

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Tone Generator Inaccuracies?

Post by steve » Fri Jun 17, 2016 12:50 am

sonusmagus wrote:But where does 68991 come from?
I looked for the closest number of complete cycles to your figure of 7973856 samples.

To do that:
We know that 1 cycle is: "(sample rate)/frequency" samples.
How many cycles in 7973856 samples = (number of samples)/(samples per cycle)
Which gives us:
7973856/(96000/830.61)
= 68991.29721 cycles
Rounding to the closest number of cycles = 68991 cycles.
sonusmagus wrote:What would make it perfect?
Any whole number of samples that is an exact multiple of 96000/830.61
Try 100 seconds
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Tone Generator Inaccuracies?

Post by steve » Fri Jun 17, 2016 1:27 am

steve wrote:Any whole number of samples that is an exact multiple of 96000/830.61
Try 100 seconds
or 3,200,000 samples (33.333 seconds)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Tone Generator Inaccuracies?

Post by Robert J. H. » Fri Jun 17, 2016 10:03 am

steve wrote:
steve wrote:Any whole number of samples that is an exact multiple of 96000/830.61
Try 100 seconds
or 3,200,000 samples (33.333 seconds)
that's a pretty nasty frequency, isn't it?
The exact value (to 50 places) would be:
830.60939515989027704488357786743025088666010693809 Hz

The question is now how much accuracy one wants.
Steve's 33.3... seconds are perfect for 830.61 Hz
For 830.609 Hz it would be:
1,000 s / GCD(96,000,000 , 830,609) = 1,000 / 1 = 1,000 seconds
and for 830.6094 Hz:
10,000 s / GCD(960,000,000 , 8,306,094) = 10,000 / 6 = 1,666.667 seconds

That's the problem with such irrational, transcendental numbers... ;)

Robert

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Tone Generator Inaccuracies?

Post by steve » Fri Jun 17, 2016 10:41 am

Robert J. H. wrote:The exact value (to 50 places) would be:
830.60939515989027704488357786743025088666010693809 Hz
Is that for G#5/Ab5 at A440?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Tone Generator Inaccuracies?

Post by Robert J. H. » Fri Jun 17, 2016 11:02 am

steve wrote:
Robert J. H. wrote:The exact value (to 50 places) would be:
830.60939515989027704488357786743025088666010693809 Hz
Is that for G#5/Ab5 at A440?
Exactly, for equal temperament to be precise.

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Tone Generator Inaccuracies?

Post by Robert J. H. » Fri Jun 17, 2016 11:20 am

Here's the Octave formula for the frequency value:
>> vpa(sym(440)*2**(11/sym(12)))

It works only with the Symbolic package installed.

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Tone Generator Inaccuracies?

Post by Gale Andrews » Fri Jun 17, 2016 2:47 pm

I guess this is of most interest in the "Audio Processing" board so I moved it there.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Post Reply