• 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: Simplest way to generate audio tones?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simplest way to generate audio tones?


  • Subject: Re: Simplest way to generate audio tones?
  • From: Jens Alfke <email@hidden>
  • Date: Sun, 29 May 2016 10:10:22 -0700

> On May 28, 2016, at 8:24 PM, Graham Cox <email@hidden> wrote:
>
> I’m looking for general pointers to the simplest/quickest way to generate an audio tone (sine wave) of a given frequency and duration. Most of the audio APIs seem concerned with playing samples rather than generating tones, so it’s not immediately obvious where to look.

It’s easy to generate a sample buffer of a sine wave. Allocate an array of uint16_t, and fill in each sample by scaling such that -1 ⟶ 0 and 1 ⟶ 255. Then tell whatever API you’re using that it’s a 1-channel 16-bit PCM buffer. Choose whatever sample rate you want to make it come out the right frequency; it’ll do the interpolation for you.

—Jens
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • QLPreviewPanel (how to supply default application url?)
      • From: sqwarqDev <email@hidden>
References: 
 >Simplest way to generate audio tones? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Simplest way to generate audio tones?
  • Next by Date: Re: When can String.enumerateSubstringsInRange ever pass in NIL?
  • Previous by thread: Re: Simplest way to generate audio tones?
  • Next by thread: QLPreviewPanel (how to supply default application url?)
  • Index(es):
    • Date
    • Thread