Sign in

username:

password:



Not a member?

Search speechcoding



Search tips

Subscribe to speechcoding



speechcoding by Keywords

ACELP | ADPCM | AMBE | AMR | AMR-NB | CELP | Codebook | DTMF | G.723 | G.726 | G.729 | GSM | Interpolation | LPC | LSF | LSP | MELP | PCM | Perceptual | Pitch | PSOL | QCELP | Quantization | SMV | VAD | Vocoder

Sponsor

Industry's highest performing at the lowest power DSPs now as low as $5.00*
Start development today!
*volume pricing for 10ku

Discussion Groups

See Also

Embedded SystemsFPGAElectronics

Discussion Groups | Speech Coding | A-law to linear coding & vice-versa

Technical discussions related to Speech Coding (all itu and other vocoders, ACELP, CELP, AMR, etc)

  

Post a new Thread

A-law to linear coding & vice-versa - Author Unknown - May 10 10:40:00 2000

Hello,
Can anyone provide me code for converting A-law to linear &
vice-versa. Kindly send the same at the foll. address:

Thanking in advance
Yours faithfully,

Sachin Athalye



______________________________
Start your Android Ice Cream Sandwich development on TI's AM35x Sitara ARM Cortex-A8 processor today.



(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

RE: A-law to linear coding & vice-versa - Cao, Binshi Binshi - May 10 14:00:00 2000

Please obtain ITU G.191 and you will have an official version of codes.

Binshi Cao.

> ----------
> From: [SMTP:]
> Reply To:
> Sent: Wednesday, May 10, 2000 6:40 AM
> To:
> Subject: [speechcoding] A-law to linear coding & vice-versa
>
> Hello,
> Can anyone provide me code for converting A-law to linear &
> vice-versa. Kindly send the same at the foll. address:
>
> Thanking in advance
> Yours faithfully,
>
> Sachin Athalye >
> ------------------------------------------------------------------------
> Remember four years of good friends, bad clothes, explosive chemistry
> experiments.
> http://click.egroups.com/1/4051/0/_/8885/_/957960092/
> ------------------------------------------------------------------------
>
> To Join:
>
> To Post:
>
> To Leave:
>
> Archives: http://www.egroups.com/group/speechcoding
>
> Other DSP-Related Groups: http://www.dsprelated.com






(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

RE: A-law to linear coding & vice-versa - satheesh - May 11 3:05:00 2000


Hi
Pls refer to Texas Instrument's Application Note SPRA163 for algorithm and
code for A & mu law companding.
The App note is downloadable from www.ti.com
Regards,
satheesh.s
-----Original Message-----
From: [mailto:]
Sent: Wednesday, May 10, 2000 4:10 PM
To:
Subject: [speechcoding] A-law to linear coding & vice-versa Hello,
Can anyone provide me code for converting A-law to linear &
vice-versa. Kindly send the same at the foll. address:

Thanking in advance
Yours faithfully,

Sachin Athalye
------------------------------------------------------------------------
Remember four years of good friends, bad clothes, explosive chemistry
experiments.
http://click.egroups.com/1/4051/0/_/8885/_/957960092/
------------------------------------------------------------------------

To Join:

To Post:

To Leave:

Archives: http://www.egroups.com/group/speechcoding

Other DSP-Related Groups: http://www.dsprelated.com


______________________________
New Code Sharing Section now Live on DSPRelated.com. Learn about the Reward Program for Contributors here.



(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: A-law to linear coding & vice-versa - Ganesan Ramachandran - May 11 3:06:00 2000

Hi,
   In which language u need the code? because most of the processors have this conversion program as a part of their library. it's just a lookup table conversion.
bye
 
-----Original Message-----
From: s...@philips.com <s...@philips.com>
To: s...@egroups.com <s...@egroups.com>
Date: Wednesday, May 10, 2000 6:44 PM
Subject: [speechcoding] A-law to linear coding & vice-versa

Hello,
      Can anyone provide me code for converting A-law to linear &
vice-versa. Kindly send the same at the foll. address:
s...@philips.com  
Thanking in advance
Yours faithfully,

Sachin Athalye
                 -------------------------------------------------------------- ----------
Remember four years of good friends, bad clothes, explosive chemistry
experiments.
http://click.egroups.com/1/4051/0/_/8885/_/957960092/
------------------------------------------------------------------------

To Join:  s...@egroups.com

To Post:  s...@egroups.com

To Leave: s...@egroups.com

Archives: http://www.egroups.com/group/speechcoding

Other DSP-Related Groups: http://www.dsprelated.com







(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

A-law to linear coding & vice-versa - Author Unknown - May 12 9:45:00 2000

Dear Friends,
Thank you for your prompt response. In the meantime, I
have come across a free source code from Sun Microsystems. But I have
trouble understanding it. I'm providing the same below :

#define SIGN_BIT (0x80) /* Sign bit for a A-law
byte.*/
#define QUANT_MASK (0xf) /* Quantization field mask. */
#define NSEGS (8) /* Number of A-law segments.
*/
#define SEG_SHIFT (4) /* Left shift for segment
number. */
#define SEG_MASK (0x70) /* Segment field mask. */

static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};

static int search( int val,short *table,int size)
{
int i;
for (i = 0; i < size; i++) {
if (val <= *table++)
return (i);
}
return (size);
}

/*
* linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
*
* linear2alaw() accepts an 16-bit integer and encodes it as A-law
data.
*
* Linear Input Code Compressed Code
* ------------------------ ---------------
* 0000000wxyza 000wxyz
* 0000001wxyza 001wxyz
* 000001wxyzab 010wxyz
* 00001wxyzabc 011wxyz
* 0001wxyzabcd 100wxyz
* 001wxyzabcde 101wxyz
* 01wxyzabcdef 110wxyz
* 1wxyzabcdefg 111wxyz
*
*/
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);
}
}

I have the foll. doubts:

1> In the func linear2alaw(), when pcm_val is found to be -ve, why is
the operation , pcm_val=-pcm_val-8, performed ?

2> In the func search(), an int is compared with a short. Will this
make it a machine [16-bit , 32-bit]dependent or compiler dependent
operation ?
Kindly solve my doubts.
Thanking you

Yours faithfully,
Sachin Athalye
email:



______________________________
New Code Sharing Section now Live on DSPRelated.com. Learn about the Reward Program for Contributors here.



(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )

Re: A-law to linear coding & vice-versa - Author Unknown - Jun 13 19:10:00 2000

Hi,

factor '8' is actually '1'. Actual i/p to linear-A law is
13 bit..but the code is for 16 bit linear ( obtained by
shifting left the 13 bit value by 3...similarly '1' becomes
8.

regards
Suresh shetty

--- In , sachin.athalye@p... wrote:
> Dear Friends,
> Thank you for your prompt response. In the meantime, I
> have come across a free source code from Sun Microsystems. But I
have
> trouble understanding it. I'm providing the same below :
>
> #define SIGN_BIT (0x80) /* Sign bit for a
A-law
> byte.*/
> #define QUANT_MASK (0xf) /* Quantization field
mask. */
> #define NSEGS (8) /* Number of A-law
segments.
> */
> #define SEG_SHIFT (4) /* Left shift for
segment
> number. */
> #define SEG_MASK (0x70) /* Segment field mask.
*/
>
> static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
> 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
>
> static int search( int val,short *table,int size)
> {
> int i;
> for (i = 0; i < size; i++) {
> if (val <= *table++)
> return (i);
> }
> return (size);
> }
>
> /*
> * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
> *
> * linear2alaw() accepts an 16-bit integer and encodes it as A-law
> data.
> *
> * Linear Input Code Compressed Code
> * ------------------------ ---------------
> * 0000000wxyza 000wxyz
> * 0000001wxyza 001wxyz
> * 000001wxyzab 010wxyz
> * 00001wxyzabc 011wxyz
> * 0001wxyzabcd 100wxyz
> * 001wxyzabcde 101wxyz
> * 01wxyzabcdef 110wxyz
> * 1wxyzabcdefg 111wxyz
> *
> */
> 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);
> }
> }
>
> I have the foll. doubts:
>
> 1> In the func linear2alaw(), when pcm_val is found to be -ve, why
is
> the operation , pcm_val=-pcm_val-8, performed ?
>
> 2> In the func search(), an int is compared with a short. Will this
> make it a machine [16-bit , 32-bit]dependent or compiler dependent
> operation ?
> Kindly solve my doubts.
> Thanking you
>
> Yours faithfully,
> Sachin Athalye
> email:sachin.athalye@p...


______________________________
New Code Sharing Section now Live on DSPRelated.com. Learn about the Reward Program for Contributors here.



(You need to be a member of speechcoding -- send a blank email to speechcoding-subscribe@yahoogroups.com )