0

私はiOSプログラミングが初めてで、現在FSK信号を復調するプロジェクトに取り組んでいます。Michael Tyson の循環バッファーの実装を採用しましたが、サンプルをログアウトして方形波に似ているかどうかを確認しようとすると、定数値 '67638612' が表示されます。オーディオジャックのマイクを介して FSK 変調信号を送信する回路が既にあります。サンプルをログアウトするために使用したコードは次のとおりです。

// Init circular buffer
BOOL TPCircularBufferInit(TPCircularBuffer *buffer, int32_t length);

// Listing 10.28 Initial Setup of Render Callback from RemoteIO
static OSStatus InputFSKDemodulationRenderCallback (

                                                void                        *inRefCon,            // A pointer to a struct containing the complete audio data
                                                //    to play, as well as state    information such as the
                                                //    first sample to play on this invocation of the callback.
                                                AudioUnitRenderActionFlags  *ioActionFlags, // Unused here. When generating audio, use ioActionFlags to indicate silence
                                                //    between sounds; for silence, also memset the ioData buffers to 0.
                                                const AudioTimeStamp        *inTimeStamp,   // Unused here.
                                                UInt32                      inBusNumber,    // The mixer unit input bus that is requesting some new
                                                //        frames of audio data to play.
                                                UInt32                      inNumberFrames, // The number of frames of audio to provide to the buffer(s)
                                                //        pointed to by the ioData parameter.
                                                AudioBufferList             *ioData         // On output, the audio data to play. The callback's primary
                                                //        responsibility is to fill the buffer(s) in the 
                                                //        AudioBufferList.
                                                ) {
AudioStruct* effectState = (AudioStruct*) inRefCon;
// Listing 10.29 Copying Captured Samples to Play-Out Buffer in RemoteIO Render Callback
// Just copy samples
UInt32 bus1 = 1;
CheckError(AudioUnitRender(effectState->rioUnit,
                           ioActionFlags,
                           inTimeStamp,
                           bus1,
                           inNumberFrames,
                           ioData),
           "Couldn't render from RemoteIO unit");

// Listing 10.30 Performing FSK demodulation Effect on a Buffer of Samples
// Walk the samples
AudioUnitSampleType* outSample = (AudioUnitSampleType* )ioData->mBuffers[0].mData;
AudioUnitSampleType sample = (AudioUnitSampleType) &outSample;
memset(outSample, 0, inNumberFrames * kUnitSize * 2);

// if (effectState->bufferIsReady && !effectState->playbackWasInterrupted){

    for (int bufCount = 0; bufCount<ioData->mNumberBuffers; bufCount++){
        int currentFrame = 0;
 while (currentFrame <= inNumberFrames) {
    // Pull audio from circular buffer
int32_t availableBytes;
AudioUnitSampleType *bufferTail     = TPCircularBufferTail( &effectState->circularBuffer,     &availableBytes);

memcpy(outSample, bufferTail, MIN(availableBytes, inNumberFrames * kUnitSize * 2) );
TPCircularBufferConsume(&effectState->circularBuffer, MIN(availableBytes, inNumberFrames *   kUnitSize * 2) );
effectState->currentSampleNum += MIN(availableBytes / (kUnitSize * 2), inNumberFrames);

     NSLog(@" currentsamplenumber  is: %ld", sample);

コンソールでは、これが私が見るすべてです:

2013-08-26 15:55:27.886 ElisaDongle[880:907] hardwareSampleRate = 44100.000000
RIO started!
2013-08-26 15:55:28.013 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.016 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.018 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.020 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.022 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.024 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.026 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.031 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.036 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.038 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612
2013-08-26 15:55:28.041 ElisaDongle[880:6403]  currentsamplenumber  is: 67638612

助けてください。私が間違っていることや欠けていることはありますか。ご不明な点がございましたら、お気軽にお問い合わせください。

4

0 に答える 0