Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AussieSusan

macrumors member
Original poster
May 29, 2006
54
0
Melbourne, Australia
I would like to generate a simple tone (sine wave) with a specified pitch and duration. For example: 440Hz for 0.5 seconds.

I've looked at the Core Audio and other audio-related documents and they all show how "easy" it is to do really fancy audio processing, except none show how to do something this simple. I can't believe that something that was possible on an old 8086-based PC with a single function call is so hard to do today!

Can someone please point me to the right reference or sample code?

Thanks

Susan
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
I think I answered this already in Apple's dev forum.

Read the Audio Queue documentation and look at the SpeakHere example code. Then instead of filling buffers from a wave file, generate sinewave samples and use those to fill the buffers. It should take maybe a dozen lines of code, total, in addition to Apple's audio queue example code. This will give you complete control over the exact pitch and duration. You could even do multivoice additive wavetable synthesis if you want more than one sinewave.

When Apple officially lifts their NDA (the new agreement hasn't been posted yet), there will probably be a lot more source code examples for these trivial things posted.


.
 

AussieSusan

macrumors member
Original poster
May 29, 2006
54
0
Melbourne, Australia
Thanks for the response Firewood - I posted here as well because I've had about 5 other questions that I posted there remain unanswered and I have the feeling that the audience here is a little different.

I took from your other response the information about how to generate the samples rather than the initial comment about the 'audio queue'. I have been reading (or trying to) about those (in the 'Audio Queue Services Programming Guide') but I must admit that I find I need to spend many days reading and rereading the Apple documentation before I start to understand it. I guess my mind must work in some other way to their documenters - everything is in there somewhere but I find it is often buried. (end of soap box speech!)

I guess I was looking for the equivalent of the Windows win32 "Beep(frequency, duration)" function......

Back to the reading

Susan
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.