2012-07-21 2 views
0

기존 프로젝트에 this tone generation code을 추가하고 있는데 잘못된 것이 있습니다. 문제가 무엇인지 알 수 없습니다. 이 코드는 독립적 인 프로젝트에서 잘 작동합니다. 내가 No previous prototype for function 'RenderTone' (반복적으로) 말을 난 단지 경고가 코드함수에 대한 이전 프로토 타입이 없습니다.

나는 또한 몇 가지 오류를 받고 있어요하지만이는 내가 '원본 파일에없는을 추가 해요 컨트롤러에서

OSStatus RenderTone(
    void *inRefCon, 
    AudioUnitRenderActionFlags *ioActionFlags, 
    const AudioTimeStamp *inTimeStamp, 
    UInt32 inBusNumber, 
    UInt32 inNumberFrames, 
    AudioBufferList *ioData) 

{ 
    // Fixed amplitude is good enough for our purposes 
    const double amplitude = 0.25; 

    // Get the tone parameters out of the view controller 
    ToneGeneratorViewController *viewController = 
     (ToneGeneratorViewController *)inRefCon; 
    double theta = viewController->theta; 
    double theta_increment = 
     2.0 * M_PI * viewController->frequency/viewController->sampleRate; 

    // This is a mono tone generator so we only need the first buffer 
    const int channel = 0; 
    Float32 *buffer = (Float32 *)ioData->mBuffers[channel].mData; 

    // Generate the samples 
    for (UInt32 frame = 0; frame < inNumberFrames; frame++) 
    { 
     buffer[frame] = sin(theta) * amplitude; 

     theta += theta_increment; 
     if (theta > 2.0 * M_PI) 
     { 
      theta -= 2.0 * M_PI; 
     } 
    } 

    // Store the updated theta back in the view controller 
    viewController->theta = theta; 

    return noErr; 
} 

자신을 작성했습니다 : 그 원인이 될 수있는 것을

enter image description here

어떤 생각?

답변

1

AudioToolbox.framework를 프로젝트에 추가하십시오.

+0

이렇게하면 오류는 제거되지만 경고는 제거되지 않습니다. 그걸 고칠 수있는 어떤 생각? – networkprofile

+0

@Sled, 여기 ToneGenerator 샘플, 오류 없음, 경고 없음 ... 즐기십시오! http://is.gd/en50Zt – Guru

관련 문제