fix my BE mistake, merge master
commit
3a3940e118
|
@ -3,5 +3,3 @@ Receives voice packets via UDP and allows to play them back using aplay.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
./m17_udp | aplay -t raw -f S16_LE -r 8000 -c 1
|
./m17_udp | aplay -t raw -f S16_LE -r 8000 -c 1
|
||||||
or maybe
|
|
||||||
./m17_udp | aplay -t raw -f S16_BE -r 8000 -c 1
|
|
||||||
|
|
24
main.c
24
main.c
|
@ -34,7 +34,12 @@ int s, i, slen = sizeof(si_other) , rcv_len;
|
||||||
//stream info
|
//stream info
|
||||||
uint8_t src[10];
|
uint8_t src[10];
|
||||||
uint8_t dst[10];
|
uint8_t dst[10];
|
||||||
uint16_t type=0;
|
uint16_t type;
|
||||||
|
uint8_t nonce[14];
|
||||||
|
uint16_t crc_lich;
|
||||||
|
uint16_t fn;
|
||||||
|
uint8_t payload[16];
|
||||||
|
uint16_t crc_pld;
|
||||||
|
|
||||||
uint8_t* decode_callsign_base40(uint64_t encoded, uint8_t *callsign)
|
uint8_t* decode_callsign_base40(uint64_t encoded, uint8_t *callsign)
|
||||||
{
|
{
|
||||||
|
@ -116,12 +121,20 @@ int main(int argc, char *argv[])
|
||||||
decode_callsign_base40(tmp, dst);
|
decode_callsign_base40(tmp, dst);
|
||||||
type=(bits[12]<<8)|bits[13];
|
type=(bits[12]<<8)|bits[13];
|
||||||
|
|
||||||
|
memcpy(nonce, &bits[14], 14);
|
||||||
|
crc_lich=bits[28]<<8|bits[29];
|
||||||
|
fn=bits[30]<<8|bits[31];
|
||||||
|
memcpy(payload, &bits[32], 16);
|
||||||
|
crc_pld=bits[48]<<8|bits[49];
|
||||||
|
|
||||||
//info
|
//info
|
||||||
printf("%s\t\t%s\t\t%04X\n", src, dst, type);
|
/*printf("%s\t\t%s\t\t%04X\n", src, dst, type);*/
|
||||||
size_t frame1_offset = 32, frame2_offset =frame1_offset+8;
|
|
||||||
|
if(((type>>1)&0b11)==0b10) //voice only
|
||||||
|
{
|
||||||
//reconstruct speech
|
//reconstruct speech
|
||||||
codec2_decode(cod, &speech_buff[0], &bits[frame1_offset]);
|
codec2_decode(cod, &speech_buff[0], &payload[0]);
|
||||||
codec2_decode(cod, &speech_buff[160], &bits[frame2_offset]);
|
codec2_decode(cod, &speech_buff[160], &payload[8]);
|
||||||
|
|
||||||
//send to stdout for playback
|
//send to stdout for playback
|
||||||
for(uint16_t i=0; i<320*2; i++)
|
for(uint16_t i=0; i<320*2; i++)
|
||||||
|
@ -132,6 +145,7 @@ int main(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
printf("%c", (uint8_t)(speech_buff[i/2]>>8));
|
printf("%c", (uint8_t)(speech_buff[i/2]>>8));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*fp=fopen("out.raw", "a");
|
/*fp=fopen("out.raw", "a");
|
||||||
fwrite(speech_buff, 2, 160, fp);
|
fwrite(speech_buff, 2, 160, fp);
|
||||||
|
|
Loading…
Reference in New Issue