• Forums
• Posts
Latest Posts
Active Posts
Recently Visited
Search Results
• Page Extras
• Forum Themes
• AVR Freaks

### Hot!a/u-law compression!

Author
TER
New Member
• Total Posts : 8
• Reward points : 0
• Joined: 2019/04/15 03:59:38
• Location: 0
• Status: offline
0

# I using pic24fj.Someone to Help-me ???Thanks a lot!

jtemples
عُضْوٌ جَدِيد
• Total Posts : 11241
• Reward points : 0
• Joined: 2004/02/13 12:31:19
• Location: Southern California
• Status: offline
Re: a/u-law compression! 2019/05/16 22:34:03 (permalink)
0
How are you going to use C++ with a PIC24?  And how would a C++ implementation of something so simple be different than the C implementation?
pcbbc
Super Member
• Total Posts : 1188
• Reward points : 0
• Joined: 2014/03/27 07:04:41
• Location: 0
• Status: offline
Re: a/u-law compression! 2019/05/17 04:35:27 (permalink)
0
From here:

μ-Law
`int8_t MuLaw_Encode(int16_t number){   const uint16_t MULAW_MAX = 0x1FFF;   const uint16_t MULAW_BIAS = 33;   uint16_t mask = 0x1000;   uint8_t sign = 0;   uint8_t position = 12;   uint8_t lsb = 0;   if (number < 0)   {      number = -number;      sign = 0x80;   }   number += MULAW_BIAS;   if (number > MULAW_MAX)   {      number = MULAW_MAX;   }   for (; ((number & mask) != mask && position >= 5); mask >>= 1, position--)        ;   lsb = (number >> (position - 4)) & 0x0f;   return (~(sign | ((position - 5) << 4) | lsb));}`

A-Law
`int8_t ALaw_Encode(int16_t number){   const uint16_t ALAW_MAX = 0xFFF;   uint16_t mask = 0x800;   uint8_t sign = 0;   uint8_t position = 11;   uint8_t lsb = 0;   if (number < 0)   {      number = -number;      sign = 0x80;   }   if (number > ALAW_MAX)   {      number = ALAW_MAX;   }   for (; ((number & mask) != mask && position >= 5); mask >>= 1, position--);   lsb = (number >> ((position == 4) ? (1) : (position - 4))) & 0x0f;   return (sign | ((position - 4) << 4) | lsb) ^ 0x55;}`

TER
New Member
• Total Posts : 8
• Reward points : 0
• Joined: 2019/04/15 03:59:38
• Location: 0
• Status: offline
Re: a/u-law compression! 2019/08/07 05:06:28 (permalink)
0
Thanks for help pcbbc!!!
pcbbc
Super Member
• Total Posts : 1188
• Reward points : 0
• Joined: 2014/03/27 07:04:41
• Location: 0
• Status: offline
Re: a/u-law compression! 2019/08/07 05:25:52 (permalink)
4.67 (3)
termin
Thanks for help pcbbc!!!

NP - Nothing like checking back on your posts regularly for updates, is there? pink: