0

i have this code, in order to read buffer samples , but i get a strange mach-o linker error , Framework of audio unit couldnt loaded so i put the audioTollBox and coreAudio as i read. my code is :

#define kOutputBus 0
#define kInputBus 1
AudioComponentInstance audioUnit;



@implementation remoteIO


//callback function : 

    static OSStatus recordingCallback(void *inRefCon, 
                                      AudioUnitRenderActionFlags *ioActionFlags, 
                                      const AudioTimeStamp *inTimeStamp, 
                                      UInt32 inBusNumber, 
                                      UInt32 inNumberFrames, 
                                      AudioBufferList *ioData)
    {
        AudioBuffer buffer;

        buffer.mNumberChannels = 1;
        buffer.mDataByteSize = inNumberFrames * 2;
        NSLog(@"%ld",inNumberFrames);
        buffer.mData = malloc( inNumberFrames * 2 );


        AudioBufferList bufferList;
        bufferList.mNumberBuffers = 1;
        bufferList.mBuffers[0] = buffer;



        OSStatus status;
        status = AudioUnitRender(audioUnit, 
                                 ioActionFlags, 
                                 inTimeStamp, 
                                 inBusNumber, 
                                 inNumberFrames, 
                                 &bufferList);  
        checkStatus(status);                       //here is the warnning+error
        double *q = (double *)(&bufferList)->mBuffers[0].mData;
        for(int i=0; i < strlen((const char *)(&bufferList)->mBuffers[0].mData); i++)
        {

            NSLog(@"%f",q[i]); 
        }
    }

and the reading method :

-(void)startListeningWithFrequency:(float)freq;
{
    OSStatus status;

    AudioComponentDescription desc;
    desc.componentType = kAudioUnitType_Output;
    desc.componentSubType = kAudioUnitSubType_RemoteIO;
    desc.componentFlags = 0;
    desc.componentFlagsMask = 0;
    desc.componentManufacturer = kAudioUnitManufacturer_Apple;

    AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);
    status = AudioComponentInstanceNew( inputComponent, &audioUnit);
    checkStatus(status);

    UInt32 flag = 1;
    status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input,kInputBus, &flag, sizeof(flag));
    checkStatus(status);

    AudioStreamBasicDescription audioFormat;
    audioFormat.mSampleRate         = 44100.00;//44100.00;
    audioFormat.mFormatID           = kAudioFormatLinearPCM;
    audioFormat.mFormatFlags        = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
    audioFormat.mFramesPerPacket    = 1;
    audioFormat.mChannelsPerFrame   = 1;
    audioFormat.mBitsPerChannel     = 16;
    audioFormat.mBytesPerPacket     = 2;
    audioFormat.mBytesPerFrame      = 2;

    status = AudioUnitSetProperty(audioUnit,
                                  kAudioUnitProperty_StreamFormat,
                                  kAudioUnitScope_Output,
                                  kInputBus,
                                  &audioFormat, 
                                  sizeof(audioFormat));
    checkStatus(status);

    checkStatus(status);
    AURenderCallbackStruct callbackStruct;
    callbackStruct.inputProc = recordingCallback;
    callbackStruct.inputProcRefCon = self;
    status = AudioUnitSetProperty(audioUnit, 
                                  kAudioOutputUnitProperty_SetInputCallback,
                                  kAudioUnitScope_Global,
                                  kInputBus, &callbackStruct, sizeof(callbackStruct));
    checkStatus(status);

    status = AudioOutputUnitStart(audioUnit);

}

and what i get is this error and warnning :

Undefined symbols for architecture i386:
  "_checkStatus", referenced from:
      _recordingCallback in remoteIO.o
      -[remoteIO startListeningWithFrequency:] in remoteIO.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

whats wrong here, ? thanks.

Curnelious
  • 1
  • 16
  • 76
  • 150
  • please??? anyone ? i am losing my mind from this audio thing !!! i can see now that when i take out ALL THE CheckStatus(status) lines, i can compile it. what am i missing?? i have put all frameworks, why cant he recognize this checkStatus thing ??? – Curnelious Jan 02 '12 at 12:29
  • i can see now that the word checkStatus is not mention in the whole apple doc, even once. not once. in any audio document, there is no function such as that . and in every audio guide, every post here ,everywhere, they all use this checkStatus(status) function, which wasnt declared by them .. what am i missing here ??? – Curnelious Jan 02 '12 at 12:58

1 Answers1

0

You have to write your own checkStatus() function, as what it does (e.g. how it reports an error: dialog box, console output, analytics logging, crash dump, etc.), or whether is does anything at all other than return from the audio code, is specific to each app.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • i took it out from my code- no checkStatus, and it worked. but my question is, what are the number that i have to get from the samples? i get between -32700- +32700.. is that ok ? – Curnelious Jan 03 '12 at 08:58