Noisy DefaultOutputUnit
Noisy DefaultOutputUnit
- Subject: Noisy DefaultOutputUnit
- From: Paul Scott <email@hidden>
- Date: Sat, 26 Jan 2008 12:57:01 -0800
Being completely dissatisfied with the quality and features of
freeware Morse code tutors, and even more indignant at the idea of
paying for educational materials, I've decided to embark on a Morse
tutor project of my own, which I will release as open source freeware.
Of course, there is only one platform for consideration. You guessed
it, Mac OSX. Which brings me here.
The main problem, how to generate sound. I mean generate. On the fly.
Playing audio files isn't an option. Initially, I will use modulated
sine waves, but later I'll be generating noise and other effects to
provide a realistic radio environment. Perusing the example projects
provided by Apple--I can't praise Apple enough for providing excellent
development tools, documentation, and examples at no cost--I've
decided that the sample in /Developer/Examples/CoreAudio/SimpleSDK/
DefaultOutput Unit fits the bill perfectly. Does anyone have any other
suggestions?
Now, while experimenting with DefaultOutputUnit, I discovered some
interesting problems. Running the program, unmodified, produces nasty
clicks in the speaker (on two iMacs and a MacBook Pro, and presumably
on all Macs) when switching sampling rates. The clicks seem to arise
when CFRunLoopRunInMode() times out. Why? I wondered. Moving or
removing AudioUnitStop(), AudioUnitStart(), AudioUnitUninitialize(),
etc. had no effect. However, changing the timeout in
CFRunLoopRunInMode() mitigated--although did not eliminate--the
annoyance. That lead me to believe that perhaps the sample (frame)
buffer was not completely filled in when the timeout occurred.
However, pre-initializing the buffer each time had no effect.
In trying to track down the cause, I modified the program to generate
a repeating pattern of a 440hz sine wave for one-half second followed
by one-half second of silence. I also changed the CFRunLoopRunInMode()
timeout to 10 seconds. This produced a clean on-off signal
continuously until the first sample rate change (timeout). Then the
dreaded clicks. However, something even stranger happened. At the
11025hz sample rate, pops began to appear before and after each signal-
on period that grew in volume, subsided, then reappeared. Strange,
since I'm generating (I think) a clean sine wave. Progressively higher
sample rates seemed to ameliorate the condition. I experimented with
trying to keep sample values smooth between frame groups to no effect.
Finally, I applied an attach/decay multiplication factor based on a
percentage of the sample rate. That produced a consistently clean
signal at all sample rates. However, I'm left wondering why, without
my attack/decay factor, there was a slowly modulating--rather than
consistent--popping signal superimposed on the sine wave.
At this point, I have three questions:
1) What is causing the clicks when CFRunLoopRunInMode() times out?
2) What is causing the slowly modulated popping signal sans attack/
decay factor?
3) If my application is Cocoa based, can I run this Core Audio code
with CFRunLoopRun() on its own thread?
Paul
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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