Re: Learning Core Audio Example 2.1
Re: Learning Core Audio Example 2.1
- Subject: Re: Learning Core Audio Example 2.1
- From: John Geelen <email@hidden>
- Date: Mon, 21 May 2012 20:47:13 +0200
Please take a look at my example code on my web site:
http://www.jgelectronics.nl/JG_Electronics/Cocoa_Audio_Source_Code/Entries/2011/9/21_Audio_Tool_with_Graphic_Display.html
regards,
John Geelen
Op 20 mei 2012, om 20:57 heeft Graham Wheel het volgende geschreven:
> There seems to be a lot of interest in Adamson & Avila's recently published book Learning Core Audio on this list, and although the topic of this post is not specifically about Core Audio, it does pertain to an example from the book and is likely to be of interest to many list members, so for lack of a better place I have posted here.
>
> The algorithm for generating a sound file of a particular frequency in the CAToneFileGenerator of example 2.1 in Learning Core Audio contains a fundamental flaw. The purpose of the code example is to generate a sound file containing square, sawtooth, or sine wave of an arbitrary frequency. The flaw in the algorithm results in a signal that is distorted and off-frequency unless the frequency being generated is an exact divisor of the sampling frequency.
>
> A discrete-time signal generated by sampling a continuous periodic signal is not necessarily periodic, or it may be periodic with a different period than the underlying continuous signal. The example attempts to generate samples of a square wave, triangle wave, or sinusoid of an arbitrary frequency by creating samples for one period, and then repeating the pattern for the length of the signal. This only works correctly if the sampling frequency is an integer multiple of the frequency of the signal being generated.
>
> As an example, try generating a 441Hz sinusoid and a 440Hz sinusoid using the sample code (pages 32-33, with the modification on page 39). The 441Hz signal is an integer divisor of the sampling frequency of 44100Hz, and produces an exact sampled sinusoid and audibly pure tone. However, at 440Hz the signal contains distortion that is quite audible, and is not exactly 440Hz.
>
> A more accurate way to generate the sampled signal would be to sample the entire signal, rather than try to stitch together repeated periods.
>
> Graham
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden