Help!
Help!
- Subject: Help!
- From: Matthew Johnson <email@hidden>
- Date: Wed, 24 Apr 2002 16:56:55 +1000
The following section of code works with the built-in audio controller
count = sizeof(brc->inDeviceFormat);
err = AudioDeviceGetProperty(brc->inputAudioDevice, 0, false, kAudioDevicePropertyStreamFormat, &count,
&brc->inDeviceFormat);
if (err != kAudioHardwareNoError)
{
fprintf(stderr, "get kAudioDevicePropertyStreamFormat error %ld\n", err);
}
else
{
if (brc->inDeviceFormat.mFormatID != kAudioFormatLinearPCM)
{
fprintf(stderr, "mFormatID != kAudioFormatLinearPCM\n");
}
else
{
if (!(brc->inDeviceFormat.mFormatFlags & kLinearPCMFormatFlagIsFloat))
{
fprintf(stderr, "Sorry, currently only works with float format....\n");
}
else
{
fprintf(stderr, "input SampleRate = %g\n", brc->inDeviceFormat.mSampleRate);
fprintf(stderr, "input FormatFlags = lX\n", brc->inDeviceFormat.mFormatFlags);
fprintf(stderr, "input BytesPerPacket = %ld\n", brc->inDeviceFormat.mBytesPerPacket);
fprintf(stderr, "input FramesPerPacket = %ld\n", brc->inDeviceFormat.mFramesPerPacket);
fprintf(stderr, "input ChannelsPerFrame = %ld\n",
brc->inDeviceFormat.mChannelsPerFrame);
fprintf(stderr, "input BytesPerFrame = %ld\n", brc->inDeviceFormat.mBytesPerFrame);
fprintf(stderr, "input BitsPerChannel = %ld\n", brc->inDeviceFormat.mBitsPerChannel);
}
}
}
This produces the following output:
input SampleRate = 44100
input FormatFlags = 0000000B
input BytesPerPacket = 8
input FramesPerPacket = 1
input ChannelsPerFrame = 2
input BytesPerFrame = 8
input BitsPerChannel = 32
This is great but when I plug in a plantronic DSP-400 USB microphone then I get
get kAudioDevicePropertyStreamFormat error 1852797029
How on earth can I work out what sample rate the mic is recording at (yes the mic works in my app. I just can't get any
data on the format)
Also
// Get controlllers
err=AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,&theSize,NULL);
numberOfDevices= theSize / sizeof(AudioDeviceID);
dList=(AudioDeviceID *)calloc(numberOfDevices,sizeof(AudioDeviceID));
err=AudioHardwareGetProperty(kAudioHardwarePropertyDevices,&theSize,dList);
fprintf(stderr,"# of controllers=%d err=[%s] %d \n",numberOfDevices,err==noErr?"noErr":"bad",err);
// Get controller name
for(i=0;i<numberOfDevices;i++)
{
err = AudioDeviceGetPropertyInfo(dList[i], 0, false, kAudioDevicePropertyDeviceName, &len,
&outWritable);
err = AudioDeviceGetProperty(dList[i], 0, false, kAudioDevicePropertyDeviceName, &len, buf);
fprintf(stderr,"name of Controller[%d]=[%s]\n",i,buf);
}
This bit of code to get the controller names makes the following output:
# of controllers=3
name of Controller[0]=[Plantronics headset]
name of Controller[1]=[Plantronics headset]
name of Controller[2]=[Built-in audio controller]
why is it doing that when I only have one plantronics headset plugged in?
Matt
_______________________________________________
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.