Re: Simplest way to generate audio tones?
Re: Simplest way to generate audio tones?
- Subject: Re: Simplest way to generate audio tones?
- From: Michael David Crawford <email@hidden>
- Date: Fri, 03 Jun 2016 08:32:28 -0700
I wrote BirthCry.cpp when I was just getting started on Ogg Frog.
It's still not released but one of my beta testers released it for me
at Github after I specifically asked him not to.
Next time I'll request an NDA.
This sends 441 kHz PCM directly to the audio card. It doesn't use
QuickTime in any way.
You don't want to block on a mutex when you do that and run out of
samples; send it silence instead. I did it that way at first but it
scared both my dogs and very nearly set my MacBook Pro on fire!
https://github.com/rushgorden/oggfrog/blob/master/Source/OggFrog_10-Dec-2006/oggfrog/BirthCry.cpp
Michael David Crawford, Baritone
email@hidden
One Must Not Trifle With Wizards For It Makes Us Soggy And Hard To Light.
On Sun, May 29, 2016 at 10:10 AM, Jens Alfke <email@hidden> wrote:
>
>> 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
_______________________________________________
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