⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iekc64_audio.h

📁 一个小的测试程序
💻 H
📖 第 1 页 / 共 2 页
字号:
  */
  Uint32 dwAudioInEdmaPri;
	/*! This field defines to the AUDIO output EDMA priority 
	*/
	Uint32 dwAudioOutEdmaPri;	
}
IEKC64_AUDIO;

/*--------------------------------------------------------------------------*/
/*! This varaible contains the AUDIO default configuration
*/
extern const IEKC64_AUDIO IEKC64_AUDIO_CONFIG_DEFAULT;
  
/*--------------------------------------------------------------------------*/
/*! 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 failed
	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 ),
  //! Invalid audio configuration structure size	
	IEKC64_AUDIO_ERR_CFG_SIZE				= IEKC64_ERR_CODE( IEKC64_AUD,  18 ),
	//! Audio Handle allocation failed
	IEKC64_AUDIO_ERR_CANNOTALLOCATE_HANDLE = IEKC64_ERR_CODE( IEKC64_AUD,  19 ),
	//! Audio In start function failled. You may call the AUDIO_startRecord function from the main function.
	IEKC64_ERR_AUDIOIN_START_ERROR				= IEKC64_ERR_CODE( IEKC64_AUD,  20 )
};


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

	\param pAudioHandle 
				This must point to a Handle that will be filled
				by the call. This handle must be used in every next calls to
				the AUDIO module.

	\return	An IEKC64_STATUS. If the call succeeds, 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
	// Initialize with default parameters
	IEKC64_AUDIO AudioCfg = IEKC64_AUDIO_CONFIG_DEFAULT;
	Handle			hAUD;
	IEKC64_STATUS	status;

	//board intialisation
	...
	
	// configure needed fields 
	AudioCfg.dwSize = sizeof(IEKC64_AUDIO);
	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, &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_open(IEKC64_AUDIO *AudioConfig, Handle *pAudioHandle);

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

	\return	An IEKC64_STATUS. If the call succeeds, the value is 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 succeeds, the value is 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 ellapses,
				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 succeeds, the value is 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 calls block until a new frame is available

	\return	An IEKC64_STATUS. If the call succeeds, the value is 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_AUDIO_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 succeeds, 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 succeeds, the value is 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -