📄 g711playbacksi3000_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 Buffers
short expandbuffer1[NUMOFSAMPLESPERBLOCK]; //sampleExpIpBuffer
short expandbuffer2[NUMOFSAMPLESPERBLOCK]; //sampleExpOpBuffer
short buffer11[NUMOFSAMPLESPERBLOCK]; //sampleComprsIpBuffer.
short buffer12[NUMOFSAMPLESPERBLOCK]; //sampleComprsOpBuffer.
long slen = NUMOFSAMPLESPERBLOCK;
short *temp;
//-----------------------------------------------------------------------------
//Macro Instantiation
//-----------------------------------------------------------------------------
G711SI3000INIT //Macro to instantiate SI3000 structure
CODECSETUP //Macro to instantiate CODECSETUP structure
//-----------------------------------------------------------------------------
//External Variables
//-----------------------------------------------------------------------------
extern char libTblByteRead ( );
extern void libTblPtrSet ( char x );
/******************************************************************************
**
** Function Name: G711PlaybackSI3000_Main ( )
**
** Description: Wrapper.
**
******************************************************************************/
int main ( void )
{
/* PLLFBD: Oscillator PLL Divisor Control Register set for 12.288 Mhz*/
CLKDIV = 0x00C0;
PLLFBD = 62; //Fcy = Fosc/2;
libSi3000Init ( ); //Initialize Si3000 and DCI registers.
libSi3000StartSampling ( expandbuffer1, expandbuffer2, buffer11, buffer12 );
/* Set up the pointer to program memory encoded speech sample table. */
libTblPtrSet ( 1 );
libarrayFillDecoderInputPM ( );
/*****************************************************************************
A Law companding
*****************************************************************************/
if ( codecdata.law == 1 )
{
while ( 1 )
{
if( codecdata.fBlockdone != 0x01 && codecdata.fBlockplayed == 0x01
&& codecdata.sampleCount <= codecdata.arraysizeinbytes )
{
/*Load first Compressed speech datablock to encoded speech pingpong
buffer.*/
libarrayFillDecoderInputPM ( );
}
if ( codecdata.fBlockdone == 0x01 )
{
/* Start alaw expansion. */
alaw_expand( slen, codecdata.sampleComprsOpBuffer, \
codecdata.sampleExpandIpBuffer );
libStartPlay ( );
while( codecdata.fBlockplayed != 0x00 );
libBufManagerDecoder ( ); //Expander Buffer Management
}
/* Check if the total number of Blocks specified by #define
ARRAYSIZEINBYTES in G711Lib_common.h have been played. */
if ( ( codecdata.sampleCount >= codecdata.arraysizeinbytes )
&& ( codecdata.fBlockplayed == 0x00 ) )
{
/*Reset flags.*/
libSi3000StopSampling ( );
codecdata.fStartPlay = 0x00;
codecdata.fBlockdone = 0x00;
codecdata.blockCount = 0x0000;
codecdata.sampleCount = 0x00000000;
codecdata.fBlockplayed = 0x00;
break;
}
}
}
/************************End of A Law companding******************************/
/*****************************************************************************
u Law companding
*****************************************************************************/
else
{
while ( 1 )
{
if( codecdata.fBlockdone != 0x01 && codecdata.fBlockplayed == 0x01
&& codecdata.sampleCount <= codecdata.arraysizeinbytes )
{
/*Load first Compressed speech datablock to encoded speech pingpong
buffer.*/
libarrayFillDecoderInputPM ( );
}
if ( codecdata.fBlockdone == 0x01 )
{
/* Start ulaw expansion. */
ulaw_expand( slen, codecdata.sampleComprsOpBuffer, \
codecdata.sampleExpandIpBuffer );
libStartPlay ( );
while( codecdata.fBlockplayed != 0x00 );
libBufManagerDecoder ( ); //Expander Buffer Management
}
/* Check if the total number of Blocks specified by #define
ARRAYSIZEINBYTES in G711Lib_common.h have been played. */
if ( ( codecdata.sampleCount >= codecdata.arraysizeinbytes )
&& ( codecdata.fBlockplayed == 0x00 ) )
{
/*Reset flags.*/
libSi3000StopSampling ( );
codecdata.fStartPlay = 0x00;
codecdata.fBlockdone = 0x00;
codecdata.blockCount = 0x0000;
codecdata.sampleCount = 0x00000000;
codecdata.fBlockplayed = 0x00;
break;
}
}
}
while( 1 );
}
/************************End of u Law companding******************************/
/*-----------------------------------------------------------------------------
END OF FILE: G711PlaybackSI3000_Main.c
-----------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -