iekc64_audio.h

来自「TI公司的算法标准 Framework5的源代码」· C头文件 代码 · 共 636 行 · 第 1/2 页

H
636
字号
            store captured frames 
        */
  Uint32*                               pBuffer;                
}
IEKC64_AUDIO;
  
/*--------------------------------------------------------------------------*/
/*! Module error codes.<br>
         If status returned from a module call is negative (or 
         IEKC64_SUCCESS(return code) is false), the value represents en error
         from the list below
*/
enum IEKC64_AUDIO_STATUS
{
        //! \ Codec initialization error
        IEKC64_AUDIO_INIT_ERR                                           = IEKC64_ERR_CODE( IEKC64_AUD,  1 ),
        //! \ Codec writing error
        IEKC64_AUDIO_WRITE_ERR                                          = IEKC64_ERR_CODE( IEKC64_AUD,  2 ),
        //! \ Codec line intialization error
        IEKC64_AUDIO_SOURCE_LINE_ERR                            = IEKC64_ERR_CODE( IEKC64_AUD,  3 ),
        //! \ Codec mic intialization error
        IEKC64_AUDIO_SOURCE_MIC_ERR                             = IEKC64_ERR_CODE( IEKC64_AUD,  4 ),
        //! \ Codec mic -20 db intialization error
        IEKC64_AUDIO_SOURCE_MIC20DB_ERR                     = IEKC64_ERR_CODE( IEKC64_AUD,  5 ),
        //! \ Unknown error
        IEKC64_AUDIO_UNKNOWN_ERR                                        = IEKC64_ERR_CODE( IEKC64_AUD,  6 ),
        //! \ Interrupt not waited
        IEKC64_AUDIO_SPURIOUSINTR                                       = IEKC64_ERR_CODE( IEKC64_AUD,  7 ),
        //! \ Audio receive time out 
        IEKC64_AUDIO_RCV_TIMEOUT                                        = IEKC64_ERR_CODE( IEKC64_AUD,  8 ),
        //! \ Audio transmit time out 
        IEKC64_AUDIO_XMT_TIMEOUT                                        = IEKC64_ERR_CODE( IEKC64_AUD,  9 ),
        //! \ Audio open fail
        IEKC64_AUDIO_OPENFAIL                                           = IEKC64_ERR_CODE( IEKC64_AUD,  10 ),
        //! \ Audio time out occurs
        IEKC64_AUDIO_TIMEOUT                                            = IEKC64_ERR_CODE( IEKC64_AUD,  11 ),
        //! \ No frame available for reading
        IEKC64_AUDIO_ERR_NO_FRAME_AVAILABLE                 = IEKC64_ERR_CODE( IEKC64_AUD,  12 ),
        //! \ Frame size unsupported
        IEKC64_AUDIO_FRAME_SIZE_ERR                                 = IEKC64_ERR_CODE( IEKC64_AUD,  13 ),
        //! \ Mcbsp channel open failed
        IEKC64_AUDIO_MCBSP_OPEN_FAIL                            = IEKC64_ERR_CODE( IEKC64_AUD,  14 ),
        //! \ Tcc channel already used
        IEKC64_AUDIO_EDMA_BADTCC                                        = IEKC64_ERR_CODE( IEKC64_AUD,  15 ),
        //! \ Audio sample rate initialization failed
        IEKC64_SAMPLERATE_FAIL                                          = IEKC64_ERR_CODE( IEKC64_AUD,  16 ),
        //! \ Audio semaphore creation failed
        IEKC64_ERR_SEMAUDIO                                                     = IEKC64_ERR_CODE( IEKC64_AUD,  17 )
};


/*--------------------------------------------------------------------------*/
/*! Initialize the AUDIO module
 
        \param pAudioConfig 
                                A pointer to an audio configuration structure

        \param pAudioHandle 
                                A audio handle passed by reference. The call will return
                                the handle for the allocated audio object

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        IEKC64_AUDIO AudioCfg;
        Handle                  hAUD;
        IEKC64_STATUS   status;

        //board intialisation
        ...
        
        // Configuration
        AudioCfg.Source=SOURCE_LINE;
        AudioCfg.DigitalAudio.isDACSoftMuteEnabled=FALSE;
        AudioCfg.DigitalAudio.isADCHighPassFilterEnabled=TRUE;
        AudioCfg.DigitalAudio.DeEmphasisCtrl=AUDIO_DEEMP48K;
        AudioCfg.SampleRate=0;  //12.288MHz
        AudioCfg.FramesLength=65000;
        AudioCfg.GainInLeft=4.5;
        AudioCfg.GainInRigth=4.5;
        AudioCfg.GainOutLeft=6;
        AudioCfg.GainOutRigth=6;
        AudioCfg.LoopBack=FALSE;
        AudioCfg.nFramesInBuffer=5;
        AudioCfg.nFramesToKeep=2;
        AudioCfg.pBuffer=&TabIn[0];
        
        AUDIO_open(&AudioCfg,NULL);
        \endverbatim
        
  You can find usage of this function in <a href="../../example/loopback_audio">example/loopback_audio</a>
  /<a href="../../example/loopback_audio/loopback_audio.c">loopback_audio.c</a>.

*/
IEKC64_STATUS AUDIO_open(IEKC64_AUDIO *AudioConfig, Handle AudioHandle);

/*--------------------------------------------------------------------------*/
/*! Start the audio recording
 
        \param audioHandle
                                A audio handle returned by a previous call to AUDIO_init().

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        IEKC64_AUDIO AudioCfg;
        Handle                  hAUD;
        IEKC64_STATUS   status;

        ...initialize all field
        AUDIO_open(&AudioCfg,NULL);
        ...
        AUDIO_startRecord(&hAUD);
        \endverbatim

  You can find usage of this function in <a href="../../example/loopback_audio">example/loopback_audio</a>
  /<a href="../../example/loopback_audio/loopback_audio.c">loopback_audio.c</a>.

*/

IEKC64_STATUS AUDIO_startRecord( Handle audioHandle );

/*--------------------------------------------------------------------------*/
/*! Start the audio playing
 
        \param audioHandle
                                A audio handle returned by a previous call to AUDIO_init().

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        IEKC64_AUDIO AudioCfg;
        Handle                  hAUD;
        IEKC64_STATUS   status;

        ...initialize all field
        AUDIO_open(&AudioCfg,NULL);
        ...
        AUDIO_startPlay(&hAUD);
        \endverbatim

  You can find usage of this function in <a href="../../example/loopback_audio">example/loopback_audio</a>
  /<a href="../../example/loopback_audio/loopback_audio.c">loopback_audio.c</a>.

*/
IEKC64_STATUS AUDIO_startPlay( Handle audioHandle );


/*--------------------------------------------------------------------------*/
/*! Get next frame from the recording audio buffer
 
        \param audioHandle 
                                An audio handle returned by a previous call to AUDIO_init().

        \param pPtrFrame 
                                A pointer, passed by reference, to the next audio frame from
                                the recording audio buffer. The call will set the value.

        \param nTimeout 
                                A maximum time in milliseconds to wait for a new audio frame.
                                If no audio frame is available before the specified time ellapse,
                                IEKC64_AUDIO_ERR_NO_FRAME_AVAILABLE is returned.
                                If the timeout value is 0 or IEKC64_AUDIO_NO_WAIT, the function 
                                doesn't block.
                                If the timeout value is IEKC64_AUDIO_WAIT_INFINITE, then the 
                                function call block until a new frame is available

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        IEKC64_AUDIO AudioCfg;
        Handle                  hAUD;
        IEKC64_STATUS   status;

        ...initialize all field
        AUDIO_open(&AudioCfg,NULL);
        ...
        AUDIO_getFrame(hAUD, (void**)&Address,IEKC64_AUDIO_WAIT_INFINITE);
        ...     
        AUDIO_startRecord(&hAUD);
        \endverbatim

  You can find usage of this function in <a href="../../example/loopback_audio">example/loopback_audio</a>
  /<a href="../../example/loopback_audio/loopback_audio.c">loopback_audio.c</a>.

*/
IEKC64_STATUS AUDIO_getFrame( Handle audioHandle, void **pPtrFrame, Int32 nTimeout );

/*--------------------------------------------------------------------------*/
/*! Set next audio frame to played
 
        \param audioHandle 
                                An audio handle returned by a previous call to AUDIO_init().

        \param pFrame 
                                A pointer to the next audio frame to be played
                                
        \param nTimeout 
                                A maximum time in milliseconds to wait for the audio frame
                                to become active.
                                If the timeout value is 0 or IEKC64_AUDIO_NO_WAIT, the function 
                                doesn't block.
                                If the timeout value is IEKC64_AUDIO_WAIT_INFINITE, then the 
                                function call block until a new frame is available

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        IEKC64_AUDIO AudioCfg;
        Handle                  hAUD;
        IEKC64_STATUS   status;

        ...initialize all field
        AUDIO_open(&AudioCfg,NULL);
        ...
        AUDIO_startRecord(&hAUD);
        ...
        status = AUDIO_getFrame(hAUD, (void**)&Address,IEKC64_VIDEO_NO_WAIT);
                
        if (IEKC64_SUCCESS(status))
                {
                ...
                }
        \endverbatim

  You can find usage of this function in <a href="../../example/loopback_audio">example/loopback_audio</a>
  /<a href="../../example/loopback_audio/loopback_audio.c">loopback_audio.c</a>.

*/
IEKC64_STATUS AUDIO_putFrame( Handle audioHandle, void *pFrame, Int32 nTimeout );

/*--------------------------------------------------------------------------*/
/*! Wait for the last put frame to be active
 
        \param audioHandle
                                An audio handle returned by a previous call to AUDIO_init().

        \param nTimeout 
                                A maximum time in milliseconds to wait for the audio frame
                                to become active.
                                If the timeout value is 0 or IEKC64_AUDIO_NO_WAIT, the function 
                                doesn't wait at all.
                                If the timeout value is IEKC64_AUDIO_WAIT_INFINITE, then the 
                                function call block until a new frame is available

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        status = AUDIO_waitPlayed( audioHandle, IEKC64_AUDIO_NO_WAIT );
        if ( !IEKC64_SUCCESS(status) )
        {
                printf( "AUDIO_waitPlayed() returned error %08X\n", status );
                exit( 1 );
        }
        \endverbatim

*/
IEKC64_STATUS AUDIO_waitPlayed( Handle audioHandle, Int32 nTimeout );


/*--------------------------------------------------------------------------*/
/*! Stop audio for record AND play.
 
        \param audioHandle
                                An audio handle returned by a previous call to AUDIO_init().

        \return An IEKC64_STATUS. If the call succeed, the value will be IEKC64_OK.
                                Otherwise it holds an error code. The status code can be tested by
                                the IEKC64_SUCCESS(return code) macro that is true is the value
                                represents a successful call.

        \b Example: 
        \verbatim
        status = AUDIO_stop( audioHandle );
        if ( !IEKC64_SUCCESS(status) )
        {
                printf( "AUDIO_stop() returned error %08X\n", status );
                exit( 1 );
        }
        \endverbatim

*/
IEKC64_STATUS AUDIO_close(Handle AudioHandle);


/*@}*//* end of group AUDIO */

#ifdef __cplusplus
}
#endif

#endif /* ifndef _IEK_AUDIO_H_ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?