• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sin() optimization on PowerPC and Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sin() optimization on PowerPC and Intel


  • Subject: Re: sin() optimization on PowerPC and Intel
  • From: "Dave Hoskins" <email@hidden>
  • Date: Tue, 27 Jun 2006 18:47:20 +0100

Yeah, that's a useful site, I've used the one called "Fast sine wave calculation" before.
You initialise it with the freq and phase, and your loop ends up being simply:


y0 = b1*y1 - y2
y2 = y1
y1 = y0

Many find that simple DSP maths wins over table access on speed with todays processors.
Cheers,
Dave Hoskins




----- Original Message ----- From: "William Stewart" <email@hidden>
To: "Andy O'Meara" <email@hidden>
Cc: <email@hidden>
Sent: Tuesday, June 27, 2006 6:30 PM
Subject: Re: sin() optimization on PowerPC and Intel



As James said yesterday:

If you include <TargetConditionals.h> you can use TARGET_CPU_X86 or TARGET_CPU_PPC.

This is more about coding DSP than about CoreAudio, so you might look for the answer on the music-dsp mailing list where this kind of thing has been discussed at length. You could also look at the music-dsp source code archive where there are a number of sine functions and oscillators.
http://www.musicdsp.org/



Bill

On 27/06/2006, at 10:16 AM, Andy O'Meara wrote:


Some comments on the table method...

You can make your table much smaller if you do a linear interp method,
because it buys you a good chunk of precision. The resulting smaller size of
the table means memory bandwidth, at the cost of doing another load, two
mults, and an add. Clearly the performance gain (or loss) depends on the
hardware and compiler.


In any case, be sure yo use lrint() to convert your floats to indexes
(instead of a cast)--that's a biggie.


On 6/27/06 10:38 AM, "Bob Lang" <email@hidden> wrote:

Hi

If you're looking for fast execution speed then I'd be tempted to set
up a large array and use it to store pre-computed sine values.  This
converts each calculation into a simple and fast look up operation.
Of course, you only need to store one quarter of the cycle as the
remaining three quarters can be easily obtained from the stored first
quarter.

If you hold (say) 900 separate points, then you can store each sample
to a precision of 0.1 degree, which may already be sufficiently
accurate for your application.  Obviously, you can get better
accuracy by using a bigger array and/or using a simple linear
interpolation technique on two adjacent samples.

Bob
--
On 26 Jun 2006, at 16:37, Artemiy Pavlov wrote:

Hello all!

I have the following problem. XCode 2.2, Mac OS 10.4.6 on Intel.

I created a sin() function replacement using four first members of
the Taylor series - works perfectly like the standard sin() (the
thing is that I need a very pure sine for FM purposes, so other
models do not work ear-wise).

But the thing is that it doesn't work any faster than the standard
sin() function... It's not optimized with assembly language, but
anyway has no division operations and all coefficients are pre-
computed. I heard that on Intels the sin() function is actually
implemented in CPU instructions, and that is why it works so fast.
Is this true?

So the question is - should I determine the CPU type for my
universal app and use sin() on Intel and custom sin() on PPC? If
so, are there any #define's available to be able to branch the code?

Thanks!


All the best,

Artemiy Pavlov
Sineshine http://sineshine.com



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blueyonder.co.uk

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:
40soundspectrum.com


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

--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________ __
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________ __


_______________________________________________
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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.0.394 / Virus Database: 268.9.2/372 - Release Date: 21/06/2006



_______________________________________________
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


  • Follow-Ups:
    • Re: sin() optimization on PowerPC and Intel
      • From: Artemiy Pavlov <email@hidden>
References: 
 >Re: sin() optimization on PowerPC and Intel (From: "Andy O'Meara" <email@hidden>)
 >Re: sin() optimization on PowerPC and Intel (From: William Stewart <email@hidden>)

  • Prev by Date: Re: sin() optimization on PowerPC and Intel
  • Next by Date: Re: sin() optimization on PowerPC and Intel
  • Previous by thread: Re: sin() optimization on PowerPC and Intel
  • Next by thread: Re: sin() optimization on PowerPC and Intel
  • Index(es):
    • Date
    • Thread