Tag: audio

AudioQueue音量太低

使用AudioQueue播放PCM数据时遇到问题。 使用iPhone扬声器时音量较低; 我甚至把系统音量调到最大。 不过,当我使用耳机时,音量很好。 我将数据插入队列中,如下所示: memcpy(mBuffers[mIndex]->mAudioData, pcmData, mBufferByteSize); mBuffers[mIndex]->mAudioDataByteSize = mBufferByteSize; mBuffers[mIndex]->mPacketDescriptionCount = mBufferByteSize/2; OSStatus status = AudioQueueEnqueueBuffer(mQueue, mBuffers[mIndex], 0, NULL); NSLog(@"fill audio queue buffer[%d]",mIndex); if(mIndex == kNumberBuffers – 1) { isStartPlay = YES; mIndex = 0; AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0); status = AudioQueueStart(mQueue, NULL); }else { mIndex++; } 我已经设置了这样的音量: AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0);

Phonegap /cordova – 从临时目录读取文件作为文本

我正在使用cordova media插件录制.wavaudio样本。 其实我能够logging他们,但我找不到方法来获得已经创build的文件内容。 如果我做: // Record audio // function recordAudio() { var src = "myrecording.wav"; var mediaRec = new Media(src, onSuccess, onError); // Record audio mediaRec.startRecord(); // Stop recording after 10 sec var recTime = 0; var recInterval = setInterval(function() { recTime = recTime + 1; setAudioPosition(recTime + " sec"); if (recTime >= 3) { […]

不要播放声音

我把我的项目转换成ARC。 Xcode在例子的代码中改变了这一行 soundFileURLRef = (CFURLRef) [tapSound retain]; 至 soundFileURLRef = (__bridge CFURLRef) tapSound; 但没有声音播放。 怎么了? – (IBAction)buttonTapped:(UIButton *)sender { // Create the URL for the source audio file. The URLForResource:withExtension: method is new in iOS 4.0 NSURL *tapSound = [[NSBundle mainBundle] URLForResource: @"abide" withExtension: @"aif"]; CFURLRef soundFileURLRef; SystemSoundID soundFileObject; // Store the URL as a […]

如何在uiscrollview滚动时添加声音

-(void)layoutScrollImages { UIImageView *view = nil; NSArray *subviews = [scrollView1 subviews]; CGFloat curXLoc = 0; for (view in subviews) {if ([view isKindOfClass:[UIImageView class]] && view.tag > 0) { CGRect frame = view.frame; frame.origin = CGPointMake(curXLoc, 0); view.frame = frame; curXLoc += (kScrollObjWidth); } } [scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView1 bounds].size.height)]; } -(void)viewDidLoad { self.view.backgroundColor = […]

自动关联倒谱

我试图检测来自麦克风的声音中的一些回声。 回声将是周期性的,并有两种可能的偏移之一。 我听说我需要自动关联信号的倒频谱来检测这些回波的存在。 你能否使用Accelerate框架提供代码,显示如何检测audio数据中的回声?

循环播放CAF文件的样本

任何人都可以给我一个build议或如何循环通过CAF(核心audio格式)文件的样本的例子? 就像抽取前1000个样本并将其更改为0? 就像是: for(int i=0; i < numberOfSamples; i++) { cafFile.sample[i] = methodThatUsesSampleValue(cafFile.sample[i]); } 记住: 我不需要做这个活。 没有缓冲区等需要。 我想在C,C ++或Objective-C中做到这一点。 希望能够在iOS平台上使用代码。 任何帮助感激!

一般参数错误与AudioQueueGetProperty检索logging格式

我得到一个-50(一般参数错误)从一个调用AudioQueueGetProperty。 请帮助我,因为我已经触摸了XCode和任何iPhone工作了几个月。 这可能是一个简单的代表,但我无法解决它。 我的代码通往-50: //Setup format AudioStreamBasicDescription recordFormat; memset(&recordFormat, 0, sizeof(recordFormat)); recordFormat.mFormatID = kAudioFormatMPEG4AAC; recordFormat.mChannelsPerFrame = 2; CCGetDefaultInputDeviceSampleRate(&recordFormat.mSampleRate); UInt32 propSize = sizeof(recordFormat); AQ(AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &propSize, &recordFormat), "AudioFormatGetProperty throws unexpected errors."); //Setup Queue //listing 4.8-4.9 AudioQueueRef theQueue = {0}; self->queue = theQueue; AQ(AudioQueueNewInput(&recordFormat, CCAudioRecordingCallback, self, NULL, NULL, 0, &self->queue), "AudioQueueNewInput throws unexpected errors."); UInt32 size […]

根据logging的声音库识别声音

我正在尝试创build一个iOS应用程序,当它检测到拍手声音时将执行一个操作。 我试过的东西: 1)我的第一个方法是简单地使用AVAudioRecorder来测量整体功率。 这工作正常,但它可以通过说太大声,其他噪音等,所以我决定采取不同的做法。 2)然后,我实现了一些使用FFT的代码来获取来自麦克风的实时stream式audio的频率和大小。 我发现,拍手秒杀通常驻留在13kHZ-20kHZ的范围内,而大部分的谈话驻留在很低的频率。 然后,我在这个频率范围内实现了一个简单的阈值,这个工作正常,但其他的声音可以把它closures。 例如,在我手机旁边的桌子上放一支铅笔将通过这个阈值并算作拍手。 3)然后,我尝试将这个频率范围分成几百个分档,然后获取足够的数据,当声音通过时,我的应用程序将计算Z分数(统计的概率),如果Z分数是好的,那么可以作为一个拍手。 这根本不起作用,因为有些拍手不被识别,还有一些其他的声音被识别出来。 graphics: 为了帮助我理解如何检测拍子,我在Excel中创build了这个图表(每个图表有大约800个数据点),它涵盖了13kHZ-21kHZ的范围: 我现在在哪里: 即使在所有这些之后,我仍然没有看到如何识别拍手与其他声音。 任何帮助是极大的赞赏!

我的iOS应用程序使用8000赫兹采样率的audio单元返回一个扭曲的声音

我真的需要帮助解决这个问题。 我正在开发一个带有audio单元的iOS应用程序,录制的audio需要采用alaw格式的8bit / 8000赫兹采样率。 我怎么会听到说话者发出失真的声音。 我在网上看到这个样本: http://www.stefanpopp.de/2011/capture-iphone-microphone/comment-page-1/ 而试图debugging我的应用程序时,我在他的应用程序中使用我的audioFormat,我得到相同的扭曲的声音。 我猜我或者有不正确的设置,或者我需要做一些其他的事情来使这个工作。 鉴于链接中的应用程序和下面的audioFormat任何人都可以告诉我,如果我做错了什么或缺less的东西? 我对这个东西了解不多,谢谢。 audio格式: AudioStreamBasicDescription audioFormat; audioFormat.mSampleRate = 8000; audioFormat.mFormatID = kAudioFormatALaw; audioFormat.mFormatFlags = kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger; audioFormat.mFramesPerPacket = 1; audioFormat.mChannelsPerFrame = 1; audioFormat.mBitsPerChannel = 8; audioFormat.mBytesPerPacket = 1; audioFormat.mBytesPerFrame = 1;

在拨打iOS sdk的电话中播放音乐文件的问题

我有两个代码段: 代码1 – 这是通过入耳式扬声器播放音乐文件: NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"8Ocean.mp3"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:tileDirectory]; NSError *error=nil; self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&error]; if(!error) { [self.audioPlayer prepareToPlay]; UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); [self.audioPlayer play]; } else { NSLog(@"%@",error.localizedDescription); } 代码2-在通话过程中播放音乐文件(根据用户在通话过程中的设置发送到入耳式或免提式电话) NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"8Ocean.mp3"]; NSURL *fileURL = [[NSURL […]