Question about setting sampling rate of sound input
Question about setting sampling rate of sound input
- Subject: Question about setting sampling rate of sound input
- From: Michael Bonnice <email@hidden>
- Date: Thu, 23 Oct 2003 22:07:14 -0700
My application listens to the default input device (either line in or
internal microphone) and does an FFT on it to know the frequency
content. It works but lacks resolution at low frequencies. I've
just been learning CoreAudio so there are some things that are not
clear to me yet.
I want to change the sampling rate from within my code. Somehow there
must be some sort of function call that does this. However, the
AudioDeviceSetProperty routine doesn't have a selector to set the
sample rate of the input device. The AudioUnits section of the
documentation says I can set the sample rate, but I can't find a
Component Manager selector for the default input device so I don't have
a way to use AudioUnitSetProperty.
I've tried asking the device to match to a format that has a lower
sampling rate (10000), but it picks 44100. It only has one format
(44100) when I use this:
count = sizeof(indevice);
err =
AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&count, (void *) &indevice);
err = AudioDeviceGetPropertyInfo ( indevice, 0, true,
kAudioDevicePropertyStreamFormats, &count, NULL );
numDescriptions = count / sizeof(AudioStreamBasicDescription);
fprintf (stderr, "found %ld formats\n", numDescriptions );
I know I have seen other programs do this because they have an
interface where you pick 44100 or 22000 or whatever. How do I do this
in software?
Mike
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.