Re: Setting the Number of Channels
Re: Setting the Number of Channels
- Subject: Re: Setting the Number of Channels
- From: Michael Thornburgh <email@hidden>
- Date: Wed, 18 Jun 2003 18:39:40 -0700
here's my guess: changing the bit depth or the number of channels will
change the various byte sizes in a stream description record. you're
starting out with a record that's filled in for some existing number of
channels and bits. my guess is that the "match" operation isn't fully
changing those byte size fields for some reason.
try adding
[streamDescription setBytesPerPacket:0];
[streamDescription setBytesPerFrame:0];
before the "match", and see what happens.
alternatively, you could get the list of available stream formats and
choose the best match (setting the sample rate, if it's returned as
"0").
-mike
On Wednesday, June 18, 2003, at 06:13 PM, Jeff Zacharias wrote:
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.
_______________________________________________
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.