PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2025 → Compression alaw
Compression alaw
Iniciado por Co, 07,may. 2019 09:21 - No hay respuesta
Miembro registrado
32 mensajes
Publicado el 07,mayo 2019 - 09:21
Bonjour

Je dois écrire en windev une fonction de compression alaw pour des fichiers wav.

Je n'ai absolument aucune notion dans ce domaine. J'ai un exemple de code en c mais cela ne m'avance pas...
Merci de votre aide
Cordialement


Programmation dans la flash SPI

// Flash SPI Alaw
case FLASH_SPI_1_ALAW:
for (ii=0;ii<size/2;ii++)
{
val_compress = I2S_Compression_Alaw(Tab_PC[(ii*2)+9]*0x100 + Tab_PC[(ii*2)+8]) ;
SSP0_Write(adr,val_compress) ;
adr ++ ;
}
break;

/*****************************************************************************
** Function name: I2S_Compression_Alaw
** Mot d'entrée sur 15 bits + 1 de signe
** Octet de sortie sur 7 bits + 1 de signe, sans le XOR de 0x55 habituel
****************************************************************************/
signed char I2S_Compression_Alaw( signed short Lineaire )
{
signed char Sortie ;
unsigned char ii, Index ;

Sortie = 0 ;
if (Lineaire < 0)
Lineaire = 0 - Lineaire ;
else
Sortie = 1 ;
Lineaire = Lineaire >> 1 ;

Index = 0 ;
for(ii=0;ii<7;ii++) // Recherche par dichotomie de la valeur la plus proche dans la table de compression
{
if (Lineaire >= Tab_Alaw_Decomp[Index + (1 << (6 - ii))])
Index += (1 << (6 - ii)) ;
}

if (Sortie == 1)
return(Index) ;
else
return(0 - Index) ;
}


const unsigned short Tab_Alaw_Decomp[128] = {
0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248,
256, 267, 279, 292, 304, 318, 332, 347, 362, 378, 395, 412, 431, 450, 470, 490,
512, 535, 558, 583, 609, 636, 664, 693, 724, 756, 790, 825, 861, 899, 939, 981,
1024, 1070, 1117, 1166, 1218, 1272, 1328, 1387, 1448, 1513, 1579, 1649, 1722, 1799, 1878, 1961,
2048, 2139, 2233, 2333, 2435, 2544, 2656, 2774, 2896, 3025, 3158, 3299, 3444, 3597, 3756, 3923,
4096, 4278, 4467, 4665, 4871, 5087, 5312, 5548, 5793, 6050, 6317, 6598, 6889, 6889, 7512, 7846,
8192, 8556, 8933, 9330, 9742, 10175, 10624, 11096, 11585, 12100, 12634, 13195, 13777, 14389, 15024, 15692} ;