首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何防止iPhone 3GS过滤低频(<150 How )

如何防止iPhone 3GS过滤低频(<150 How )
EN

Stack Overflow用户
提问于 2011-07-19 17:52:44
回答 3查看 1.5K关注 0票数 18

我正在iPhone3GS上开发一个低音吉他音调检测应用程序。我发现我无法用RemoteIO获得低于150‘t的声音数据。然而,低音吉他可能会产生低于50 may的音调。根据报告"iPhone 4耳机输入频率响应“,http://blog.faberacoustical.com/2010/iphone/iphone-4-audio-and-frequency-response-limitations/在150 Hz以下有一个急剧下降。

这里展示了如何设置AudioUnit。

代码语言:javascript
复制
// set audio unit
{
    // create AudioUnit
    {
        AudioComponentDescription desc;
        desc.componentType = kAudioUnitType_Output;
        desc.componentSubType = kAudioUnitSubType_RemoteIO;
        desc.componentManufacturer = kAudioUnitManufacturer_Apple;
        desc.componentFlags = 0;
        desc.componentFlagsMask = 0;

        AudioComponent comp = AudioComponentFindNext(NULL, &desc);
        OSAssert(AudioComponentInstanceNew(comp, &m_AudioUnit));
    }

    //enable input on the remote I/O unit (output is default enabled, but input is not)
    {
        UInt32 one = 1;
        OSAssert(AudioUnitSetProperty(m_AudioUnit, kAudioOutputUnitProperty_EnableIO,
                                      kAudioUnitScope_Input, 1, &one, sizeof(one)));
    }

    //set render callback function
    {
        AURenderCallbackStruct callbackInfo;
        callbackInfo.inputProc=staticPerformThru;
        callbackInfo.inputProcRefCon=this;

        OSAssert(AudioUnitSetProperty(m_AudioUnit,
                                      kAudioUnitProperty_SetRenderCallback,
                                      kAudioUnitScope_Input, 
                                      0, &callbackInfo, sizeof(callbackInfo)));

    }

    //set in/output format
    {
        CAStreamBasicDescription outFormat;
        outFormat.SetAUCanonical(channels, false);
        outFormat.mSampleRate = sampleRate;
        OSAssert(AudioUnitSetProperty(m_AudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &outFormat, sizeof(outFormat)));
        OSAssert(AudioUnitSetProperty(m_AudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &outFormat, sizeof(outFormat)));
    }

    //Initialize remote I/O unit
    OSStatus r=AudioUnitInitialize(m_AudioUnit);
    OSAssert(r);
}
//start audio output
OSAssert(AudioOutputUnitStart(m_AudioUnit));

这是回调函数。

代码语言:javascript
复制
OSStatus AudioThruWorker::staticPerformThru(
                                           void                     *inRefCon, 
                                           AudioUnitRenderActionFlags   *ioActionFlags, 
                                           const AudioTimeStamp         *inTimeStamp, 
                                           UInt32                       inBusNumber, 
                                           UInt32                       inNumberFrames, 
                                           AudioBufferList          *ioData)
{

    AudioUnitRender(((AudioThruWorker*)inRefCon)->m_AudioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData);

    //Detect pitch here...

    return 0;
}

为了找出根本原因,

  1. 我修改了我的回调函数以绕过输入数据进行输出。
  2. 使用Mac生成白噪声
  3. 使用iRig将信号从Mac的耳机重定向到正在运行我的程序的iPhone3Gs。
  4. 使用iRig将iPhone的输出重定向到Mac。
  5. 在Mac上记录数据。

输出数据谱如下图所示。

你可以看到150赫兹的急剧下降。

为了确定问题是在输入端还是在输出端,我更改了回调函数以忽略输入数据并输出白噪声。结果如下所示。

很清楚,在150赫兹没有下降。因此,问题应该出现在输入端。

我认为这是一个硬件限制。然而,我在同一设备上尝试了应用程序"Amplitube“,关闭了所有效果,输入白噪声并分析输出。它在150 at时没有降压。结果如下所示。

这意味着丢弃问题不是硬件限制。软件必须有一些方法来避免这个问题。

有人知道这个秘密吗?

谢谢。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6745303

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档