1. clean *.pcm playing program
todo: 播放结束后,自动变成 play.
Q: AQPlayer::IsRunningProc(): where to use it ?
* 跟踪SpeakHere,发现以下调用:
#0 0x0000b7e1 in AQPlayer::isRunningProc at AQPlayer.mm:94
#1 0x00d46e62 in AQCallbackReceiver_PropertiesChanged
#2 0x00ce2ee3 in _XPropertiesChanged
#3 0x00cdb161 in mshMIGPerform
#4 0x00f68064 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
#5 0x00ec86f7 in __CFRunLoopDoSource1
#6 0x00ec5983 in __CFRunLoopRun
#7 0x00ec5240 in CFRunLoopRunSpecific
#8 0x00ec5161 in CFRunLoopRunInMode
#9 0x01a56268 in GSEventRunModal
#10 0x01a5632d in GSEventRun
#11 0x002d742e in UIApplicationMain
#12 0x00002734 in main at main.m:55
Note: 所以应该是在某个地方注册了property change之类event来驱动的。 Q: But where ?
* 重构代码,使用宏文件
杂音消失,但似乎在每一个buffer的内容放了两次,有重音。
* 修改sample rate,发现音调变化(大:高,小:低)
2. recording *.pcm file
* recording from SpeakHere
# SetupAudioFormat()
AudioStreamBasicDescription: ASBD
mSampleRate:441000
mFormatID: xxxxx( kLinearPCM )
mFormatFlags: 12 ( specific to format )
mFramesPerPacket: 0
mBytesPerFrame: 4
mChannelsPerFrame: 2
mBitesPerChannel: 16
mReserved: 0
Note1: FramesPerPacket not set
Note2: AudioFileType is not in dataformat.
Note3: 可从系统得到它支持的sample rate/channels等参数。
AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate,xxx,yyy)
# StartRecord()
bufferByteSize = ComputeRecordBufferSize(&mRecordFormat, kBufferDurationSeconds);
Note: bufferBytesSize = 88200.
Q:这个值可以随便设吗?原则是什么?
# MyInutBufferHandler()
注:此函数是由QAClient这个thread来调用的,而非main thread !
AT 9:31 PM, almost done !
Q: left issue: playback有重音。
3. reading Audio Unit Hosting Guide for iOS
* Audio Unit is the lowest layer in iOS audio stack.