问题描述
- iOS 关于audio数据的提取 12C
- static void AQInputCallback (void *inUserData
AudioQueueRef inAudioQueue AudioQueueBufferRef inBuffer const AudioTimeStamp *inStartTimeUInt32 inNumPackets const AudioStreamPacketDescription * inPacketDesc)
{
getAudioDataText * engine = (__bridge getAudioDataText *) inUserData; //[engine processAudioBuffer:inBuffer withQueue:inAudioQueue];if (inNumPackets > 0){ NSDate *datenow = [NSDate date]; [engine processAudioBuffer:inBuffer withQueue:inAudioQueue]; NSString *timeSp = [NSString stringWithFormat:@""%f"" (CGFloat)[datenow timeIntervalSince1970]]; NSLog(@""---------------%@"" timeSp);}if (engine.aqc.run){ AudioQueueEnqueueBuffer(engine.aqc.queue inBuffer 0 NULL);}
}
- (id) initWithSampleRate:(NSInteger)sampleRate atChannels:(UInt32)channels
{
self = [super init];if (self){ aqc.mDataFormat.mSampleRate = sampleRate; aqc.mDataFormat.mFormatID = kAudioFormatLinearPCM; aqc.mDataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; aqc.mDataFormat.mFramesPerPacket = 1; aqc.mDataFormat.mChannelsPerFrame = channels; aqc.mDataFormat.mBitsPerChannel = kBitsPerChannels; aqc.mDataFormat.mBytesPerPacket = kBytesPerFrame; aqc.mDataFormat.mBytesPerFrame = kBytesPerFrame; aqc.frameSize = kFrameSize; //创建一个录音音频队列对象 AudioQueueNewInput(&aqc.mDataFormat AQInputCallback (__bridge void*)(self) NULL kCFRunLoopCommonModes 0 &aqc.queue); for (int i=0;i<kNumberBuffers;i++) { //请求音频队列对象来分配一个音频队列缓存。 AudioQueueAllocateBuffer(aqc.queue (UInt32)aqc.frameSize &aqc.mBuffers[i]); //给录音或者回放音频队列的缓存中添加一个缓存数据 AudioQueueEnqueueBuffer(aqc.queue aqc.mBuffers[i] 0 NULL); } aqc.recPtr = 0; aqc.run = 1; int status = AudioQueueStart(aqc.queue NULL); NSLog(@""AudioQueueStart = %d"" status);}return self;
}
为什设置的采样率 是44100 但是回调函数里的打印数据的频率只有500次/s?哪位大神给个解决方法 我qq 1353482080
时间: 2024-11-29 09:28:37