Click here to Skip to main content
15,903,012 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CFileStatus Pin
Mark Salsbery5-Jul-08 8:50
Mark Salsbery5-Jul-08 8:50 
GeneralRe: CFileStatus Pin
baloneyman5-Jul-08 12:56
baloneyman5-Jul-08 12:56 
QuestionHow to put my toolbar visible by default? Pin
DillerXX5-Jul-08 7:20
DillerXX5-Jul-08 7:20 
QuestionError Code 87 Pin
Saksida Bojan5-Jul-08 6:35
Saksida Bojan5-Jul-08 6:35 
AnswerRe: Error Code 87 Pin
User 24844375-Jul-08 7:32
User 24844375-Jul-08 7:32 
AnswerRe: Error Code 87 Pin
Mark Salsbery5-Jul-08 9:04
Mark Salsbery5-Jul-08 9:04 
GeneralRe: Error Code 87 Pin
Saksida Bojan5-Jul-08 21:28
Saksida Bojan5-Jul-08 21:28 
Questioncompressing audio with g711 makes lots of noise Pin
doudou-shen5-Jul-08 6:09
doudou-shen5-Jul-08 6:09 
I want to compress and decompress audio with g711.Well ,Done it,but there are lots of noise in it.


8000khz 2 channels 16 bits
CG711 g_711[2];
unsigned char g_getfrommicbuff[80000];//
int g_getfromsocketbuff[80000];//
CWaveFile* g_pWaveFile;

HRESULT CALLBACK GetData(unsigned char * pBuffer, int nBufferLen) //
{
static unsigned long pos=0;
unsigned long realread=0;

static long count=0;
if(pos<m_pWavFile->GetSize())
{
m_pWavFile->Read((unsigned char *)pBuffer,nBufferLen,&realread);
pos+=realread;

HRESULT hr;
unsigned int dwDataWrote=0;

//compress
int *pint=(int *)pBuffer;
for(int i=0;i<realread/4;i++)//
{
g_getfrommicbuff[i]=g_711[0].linear2alaw(*pint++);//
}
//decompress
for(int x=0;x<realread/4;x++)
{
g_getfromsocketbuff[x]=g_711[0].alaw2linear(g_getfrommicbuff[x]);
}
if( FAILED( hr = g_pWaveFile->Write( realread, (BYTE*)g_getfromsocketbuff, &dwDataWrote ) ) )
{
TRACE("error writing\n");
}

count++;
}
else//
{
memset(pBuffer,0,nBufferLen);
}


return 0;
}






class CG711
{
public :

CG711()
{
memcpy(seg_end,G_seg_end,sizeof(short)*sizeof(seg_end));
memcpy(_u2a ,G_u2a ,sizeof(unsigned char)*sizeof(G_u2a));
memcpy(_a2u ,G_a2u ,sizeof(unsigned char)*sizeof(G_a2u));
}


short seg_end[8];
unsigned char _a2u[128];
unsigned char _u2a[128];
int search(int val,short *table,int size)
{
int i;
for (i = 0; i < size; i++) {
if (val <= *table++)
return (i);
}
return (size);
}

unsigned char linear2alaw(int pcm_val) /* 2's complement (16-bit range) */
{
int mask;
int seg;
unsigned char aval;

if (pcm_val >= 0) {
mask = 0xD5; /* sign (7th) bit = 1 */
} else {
mask = 0x55; /* sign bit = 0 */
pcm_val = -pcm_val - 8;
}

/* Convert the scaled magnitude to segment number. */
seg = search(pcm_val, seg_end, 8);

/* Combine the sign, segment, and quantization bits. */

if (seg >= 8) /* out of range, return maximum value. */
return (0x7F ^ mask);
else {
aval = seg << SEG_SHIFT;
if (seg < 2)
aval |= (pcm_val >> 4) & QUANT_MASK;
else
aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
return (aval ^ mask);
}
}


int alaw2linear(unsigned char a_val)
{
int t;
int seg;
a_val ^= 0x55;
t = (a_val & QUANT_MASK) << 4;
seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
switch (seg) {
case 0:
t += 8;
break;
case 1:
t += 0x108;
break;
default:
t += 0x108;
t <<= seg - 1;
}
return ((a_val & SIGN_BIT) ? t : -t);
}

}
AnswerRe: compressing audio with g711 makes lots of noise Pin
Varghese Paul M7-Jul-08 0:01
Varghese Paul M7-Jul-08 0:01 
Question"The ultimate grid" - adding new rows to a grid Pin
Sternocera5-Jul-08 5:58
Sternocera5-Jul-08 5:58 
AnswerRe: "The ultimate grid" - adding new rows to a grid Pin
followait5-Jul-08 14:49
followait5-Jul-08 14:49 
QuestionRe: "The ultimate grid" - adding new rows to a grid Pin
Sternocera6-Jul-08 0:05
Sternocera6-Jul-08 0:05 
AnswerRe: "The ultimate grid" - adding new rows to a grid Pin
followait6-Jul-08 2:04
followait6-Jul-08 2:04 
AnswerRe: "The ultimate grid" - adding new rows to a grid Pin
Graham Shanks6-Jul-08 10:44
Graham Shanks6-Jul-08 10:44 
QuestionHow could this be? Pin
followait5-Jul-08 4:16
followait5-Jul-08 4:16 
AnswerRe: How could this be? Pin
David Crow5-Jul-08 4:48
David Crow5-Jul-08 4:48 
Answerthe thread could be finished [modified] Pin
followait5-Jul-08 13:57
followait5-Jul-08 13:57 
QuestionLarge File problem Pin
Ubik K5-Jul-08 2:45
Ubik K5-Jul-08 2:45 
QuestionRe: Large File problem Pin
David Crow5-Jul-08 4:55
David Crow5-Jul-08 4:55 
AnswerRe: Large File problem Pin
Joe Woodbury5-Jul-08 11:24
professionalJoe Woodbury5-Jul-08 11:24 
GeneralRe: Large File problem Pin
Ubik K5-Jul-08 15:44
Ubik K5-Jul-08 15:44 
GeneralRe: Large File problem Pin
David Crow5-Jul-08 16:11
David Crow5-Jul-08 16:11 
GeneralRe: Large File problem Pin
Ubik K6-Jul-08 3:10
Ubik K6-Jul-08 3:10 
Questionmodeless child dialog would not close after its parent is destroy Pin
followait5-Jul-08 2:32
followait5-Jul-08 2:32 
AnswerRe: modeless child dialog would not close after its parent is destroy Pin
User 24844375-Jul-08 8:44
User 24844375-Jul-08 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.