Re: Changing nominalSampleRate considered harmful?
Re: Changing nominalSampleRate considered harmful?
- Subject: Re: Changing nominalSampleRate considered harmful?
- From: Jeff Moore <email@hidden>
- Date: Mon, 21 Jul 2008 12:09:31 -0700
On Jul 21, 2008, at 11:46 AM, Mike Kluev wrote:
On Mon, 21 Jul 2008 19:19:13 Lubor Prikryl DS wrote:
On 21.7.2008, at 17:39, Mike Kluev wrote:
I've noticed that neither iTunes nor QuickTime Player changes
playing rate before playing music. That means they will happily
play music/movie on, whatever rate is currently set for the
device (say, 8kHz), even if the device supports higher rates
(say 48kHz). Even after logout/restart! Is that good user
experience? How user is supposed to change the rate (e.g. if
he suddenly wants to hear better quality music)? There are no
controls for it in Sound preference panel, nor in the apps'
preferences, and average user doesn't (and shouldn't) know
what HALLab is. Is my app supposed to do the same (do not
change sample rate) because it is bad (why)?
It is the proper behavior. Core Audio is multi-client, so if one
audio application is running, the other should not automatically
change sample rate of the same device.
I am not even talking about this case. Run an app that changes
rate, quit, reboot. Run iTunes - it still uses the saved rate
(supposedly in /Library/Preferences/
com.apple.audio.DeviceSettings.plist).
Correct. The sample rate setting belongs to the user. Applications
should not be changing it. That's why iTunes and QT don't.
For pro audio applications, a sample rate selector should be
provided in audio preferences.
For other apps, sample rate of the device should not be changed
without user's intention.
For both, you may ask Core Audio to open the device Control Panel
(e.g. Audio MIDI Setup for built in audio)
err = AudioDeviceGetProperty(mInputDevice.mID, 0, 1,
kAudioDevicePropertyConfigurationApplication, &propertySize,
&cp1location);
where user can set the desired sample rate.
That's interesting. But how does this help a user who downloaded
a third party app from the web, pressed OK in a "This app works
best at 8kHz. OK to change?" alert, played with it, then disliked
it, quitted and trashed it, then rebooted. Since then on his
movies and aiffes start to play at 8kHz and he doesn't see an
obvious way to change it back! Is this a proper behavior?!
That's where /Applications/Utility/Audio MIDI Setup.app comes in
handy. Or are you saying that's not good enough?
At any rate, a problem with this scenario is that if the user isn't
sophisticated enough to know what this whole "sample rate" thing is,
then asking them to change it to 8K makes no sense. The first app in
this scenario blew it right at the start by asking the user a question
they can't really answer. If they are familiar with how the term is
being used in context, generally they'll also understand how to change
it themselves after the fact.
This all just points out why it's always better for an app to leave
the hardware the way the user has set it. The app should be the one
adapting to the current settings. If your app works best at 8K, then
you should be prepared to resample the data as necessary to make use
of the hardware the way the user has set it up. Besides, 8K support in
the hardware is becoming rarer and the app may just be stuck with a
non-optimal sample rate because the hardware does not support the rate
the app desires at all.
Also, any app that does need to change the sample rate or other
hardware settings has to restore the hardware to the state the app
found it in when the app is done using the hardware. An example of an
app like this is our DVD Player. It needs to change the sample format
to play AC-3 data. The DVD Player is also careful to save the hardware
settings before changing them so that they can be restored when the
DVD Player stops playing.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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