📄 g711si3000loopback_main.c
字号:
/*********************************************************************
* *
* Software License Agreement *
* *
* The software supplied herewith by Microchip Technology *
* Incorporated (the "Company") for its dsPIC controller *
* is intended and supplied to you, the Company's customer, *
* for use solely and exclusively on Microchip dsPIC *
* products. The software is owned by the Company and/or its *
* supplier, and is protected under applicable copyright laws. All *
* rights are reserved. Any use in violation of the foregoing *
* restrictions may subject the user to criminal sanctions under *
* applicable laws, as well as to civil liability for the breach of *
* the terms and conditions of this license. *
* *
* THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO *
* WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, *
* BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND *
* FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE *
* COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, *
* INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *
* *
*********************************************************************/
#include <p33Fxxxx.h>
#include "G711Lib_common.h"
#include "G711Lib_Si3000.h"
_FOSCSEL(FNOSC_PRIPLL);
_FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_EC);
_FWDT(FWDTEN_OFF);
/*-----------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------------*/
// User defined ping pong
short buffer1[NUMOFSAMPLESPERBLOCK]; //sampleIpBuffer.
short buffer2[NUMOFSAMPLESPERBLOCK]; //sampleOpBuffer.
short expandbuffer1[NUMOFSAMPLESPERBLOCK]; //sampleExpIpBuffer
short expandbuffer2[NUMOFSAMPLESPERBLOCK]; //sampleExpOpBuffer
short buffer11[NUMOFSAMPLESPERBLOCK]; //sampleComprsIpBuffer.
short buffer12[NUMOFSAMPLESPERBLOCK]; //sampleComprsOpBuffer.
long slen = NUMOFSAMPLESPERBLOCK;
short *temp, *temp1;
/*-----------------------------------------------------------------------------
Macro instantiation
------------------------------------------------------------------------------*/
G711SI3000INIT //Macro to instantiate SI3000 structure
CODECSETUP //Macro to instantiate CODECSETUP structure
/******************************************************************************
**
** FunctionName: G711SI3000LoopBack_Main ( )
**
** Description: Wrapper.
**
******************************************************************************/
int main ( void )
{
/* PLLFBD: Oscillator PLL Divisor Control Register set for 12.288 Mhz*/
CLKDIV = 0x00C0;
PLLFBD = 62; //Fcy = Fosc/2;
/* Initialize DCI and SI3000 Registers */
libSi3000Init ();
/* Start sampling speech data from SI3000 codec.Sampling of speech is stopped
when number of samples played equals recordsize value specified in
CODECSETUP structure. */
libSi3000StartSampling ( buffer1, buffer2,expandbuffer1,expandbuffer2,
buffer11, buffer12 );
libStartPlay (); //Enables the user to play speech.
if ( codecdata.law == 1 )
{
/*-------------------------------------------------------------------------
A LAW
-------------------------------------------------------------------------*/
while (1)
{
/*If one Block of RAW speech data has been loaded in one of the ping pong
buffers then start compressing that buffer*/
if ( 1 == codecdata.fBlockdone )
{
/* A Law Compress */
alaw_compress(slen ,codecdata.sampleOpBuffer ,\
codecdata.sampleComprsIpBuffer);
libBufManagerEncoder ();
codecdata.fCompressdone = 0x01;
}
if( codecdata.fCompressdone == 0x01 )
{
/* A Law Expand */
alaw_expand( slen,codecdata.sampleComprsOpBuffer,\
codecdata.sampleExpandIpBuffer );
/* Rewind the sample buffer poniter */
while ( codecdata.fBlockplayed != 0x00 );
libBufManagerDecoder ();
codecdata.fCompressdone = 0x00;
}
/* Check if the total number of blocks specified by #define RECORDSIZE
in G711Lib_common.h have been played */
if ( codecdata.recordSize == codecdata.loadblockCount )
codecdata.loadblockCount=0;
}
}
else
{
/*-------------------------------------------------------------------------
U LAW
--------------------------------------------------------------------------*/
while (1)
{
/*If one Block of RAW speech data has been loaded in one of the ping pong
buffers then start compressing that buffer*/
if ( 1 == codecdata.fBlockdone )
{
/* A Law Compress */
ulaw_compress( slen ,codecdata.sampleOpBuffer , \
codecdata.sampleComprsIpBuffer );
libBufManagerEncoder ();
codecdata.fCompressdone = 0x01;
}
if( codecdata.fCompressdone == 0x01 )
{
/* U Law Expand */
ulaw_expand( slen,codecdata.sampleComprsOpBuffer,
codecdata.sampleExpandIpBuffer );
/* Rewind the sample buffer poniter */
while ( codecdata.fBlockplayed != 0x00 );
libBufManagerDecoder ();
codecdata.fCompressdone = 0x00;
}
/* Check if the total number of blocks specified by #define RECORDSIZE
in G711Lib_common.h have been played */
if ( codecdata.recordSize == codecdata.loadblockCount )
codecdata.loadblockCount=0;
}
}
while( 1 );
}
/*-----------------------------------------------------------------------------
END OF FILE: RealTimeG711SI3000LoopBack_Main.c
-----------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -