• 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: Generating a rising sine tone with sinf()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generating a rising sine tone with sinf()


  • Subject: Re: Generating a rising sine tone with sinf()
  • From: Adam Bellard <email@hidden>
  • Date: Thu, 19 Jun 2014 13:08:20 -0400

Like I said, wild guess... Andy looks like he knows what he's talking about!

AB


On Thu, Jun 19, 2014 at 1:03 PM, Jim McGowan <email@hidden> wrote:
Hi Andy

Thanks, but no I'm definitely writing mono.

Jim

On 20 Jun, 2014, at 0:55, Adam Bellard <email@hidden> wrote:

Just a wild guess, maybe you are writing interleaved stereo audio out instead of mono?

Adam Bellard


On Thu, Jun 19, 2014 at 12:42 PM, Jim McGowan <email@hidden> wrote:
I’m writing some code to generate a sine tone that begins at a given frequency and the frequency rises linearly to a maximum over a specified time.  Seemingly straightforward, my approach was to fill a sample buffer in a loop (I’m using the AudioSampleType on OS X, i.e. Float32):

frequency = minFreq + (frequencyRangeLength * (sampleIndex / lengthInSamples));
sineSweepSamples[sampleIndex] = sinf((2.0 * M_PI * sampleIndex * frequency) / sampleRate)

However, this generates a tone where the frequency increases at a faster rate than it should.  When I remove the “2.0 *”, i.e. use pi instead of 2pi, I get the results I want, but I don’t understand why.  Checking the formula (with the 2pi)  in the Grapher app shows it is correct, and by dumping all the values in each iteration of the loop I see that the frequency is being calculated properly.

Can anyone explain this for me?

Thanks,
Jim
 _______________________________________________
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

References: 
 >Generating a rising sine tone with sinf() (From: Jim McGowan <email@hidden>)
 >Re: Generating a rising sine tone with sinf() (From: Adam Bellard <email@hidden>)
 >Re: Generating a rising sine tone with sinf() (From: Jim McGowan <email@hidden>)

  • Prev by Date: Re: Generating a rising sine tone with sinf()
  • Next by Date: Re: Generating a rising sine tone with sinf()
  • Previous by thread: Re: Generating a rising sine tone with sinf()
  • Next by thread: Generating a rising sine tone with sinf() (Adam Bellard)
  • Index(es):
    • Date
    • Thread