Setting the Number of Channels
Setting the Number of Channels
- Subject: Setting the Number of Channels
- From: Jeff Zacharias <email@hidden>
- Date: Wed, 18 Jun 2003 21:13:54 -0400
I'm writing Objective-C code to setup external hardware. All I need to
do is set the Sample Rate (44.1 kHz or 48.0 kHz) and set the number of
channels (2,4,6, or 8). I can use Audio MIDI Setup to change these
settings so I know the hardware is working fine. I am using
MTCoreAudio.framework. I can set the sample rate fine. However, I
can't set the channels to anything different than what it is currently
set to. My code sample is below:
stream = [recordStreamArray objectAtIndex:i];
streamDescription = [stream streamDescriptionForSide:
kMTCoreAudioStreamPhysicalSide];
[streamDescription setChannelsPerFrame:channels];
[streamDescription setSampleRate:sampleRate];
[streamDescription setBitsPerChannel:bits];
MTCoreAudioStreamDescription *physicalDescription = [stream
matchStreamDescription:streamDescription
forSide:kMTCoreAudioStreamPhysicalSide];
printf ( "matched to %s\n", [[physicalDescription description]
cString] );
printf ( "Setting to %s\n", [[streamDescription description] cString]
);
[stream setStreamDescription:streamDescription forSide:
kMTCoreAudioStreamPhysicalSide];
I seem to match just fine but but I get an error when it runs and it
doesn't get set. If my device is set to 2 channels 44.1 kHz and 24
bits and I just change the sample rate to 48 kHz it works fine. It I
try to change the channels to 4 and the sample rate to 48 kHz it does
not work and I get the following printout and error:
matched to 4ch-48000.00Hz-24bit-'lpcm' signed-integer big-endian
aligned-high
Setting to 4ch-48000.00Hz-24bit-'lpcm' signed-integer big-endian
aligned-high
MTCoreAudioStream setStreamDescription:forSide: failed, got !dat
I have tried for hours to get this to work. Is there some reason why I
can't set the number of channels or am I doing something wrong ?
Jeff Z
_______________________________________________
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.