iPhone SpeakHere example produces different number of samples
Posted
by pion
on Stack Overflow
See other posts from Stack Overflow
or by pion
Published on 2010-06-13T00:06:07Z
Indexed on
2010/06/13
0:12 UTC
Read the original article
Hit count: 268
iphone
I am looking at the SpeakHere example and added the following:
// Overriding the output audio route
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);
assert(status == noErr);
// Changing the default output route. The new output route remains in effect unless you change the audio session category. This option is available starting in iPhone OS 3.1.
UInt32 doChangeDefaultRoute = 1;
status = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);
assert(status == noErr);
// Enable Bluetooth. See audioRouteOverride & doChangeDefaultRoute above
// http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW2
UInt32 allowBluetoothInput = 1;
status = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof(allowBluetoothInput), &allowBluetoothInput);
assert(status == noErr);
Also,
void AQRecorder::handleInputBufferCallback(void *aqData, ...
...
if (inNumPackets > 0) {
NSLog(@"Number of samples = %d", inBuffer->mAudioDataByteSize/2); // print out the number of sample
status = AudioFileWritePackets(aqr->mAudioFile,
FALSE,
inBuffer->mAudioDataByteSize,
inPacketDesc,
aqr->mCurrentPacket,
&inNumPackets,
inBuffer->mAudioData);
assert(status == noErr);
aqr->mCurrentPacket += inNumPackets;
}
...
Notice the "NSLog(@"Number of samples = %d", inBuffer->mAudioDataByteSize/2); // print out the number of sample" statement above.
I am using iPhone SDK 3.1.3.
I got the following results
- The number of samples is around 44,100 on Simulator
- The number of samples is around 22,000 on iPhone
- The number of samples is around 4,000 on iPhone using Jawbone Bluetooth
I am new on this. Why did itproduce different number of samples?
Thanks in advance for your help.
© Stack Overflow or respective owner