Project

General

Profile

Actions

Feature #3672

open

Custom announcement and tones

Added by Armin over 5 years ago. Updated about 3 years ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
-
Start date:
10/25/2018
Due date:
% Done:

0%

Spec Reference:

Description

Hi,

how it's possible to change the announce in NMT?
I see there is file with hex data (announcement.c).
How can I convert usual raw audio or WAV to the same HEX format?


Files

hex2.py hex2.py 443 Bytes laforge, 02/01/2021 09:10 AM
Actions #1

Updated by laforge about 3 years ago

  • Assignee set to jolly
Actions #2

Updated by atmega about 3 years ago

Did you make any progress with announcement.c ?

Armin wrote:

Hi,

how it's possible to change the announce in NMT?
I see there is file with hex data (announcement.c).
How can I convert usual raw audio or WAV to the same HEX format?

Actions #3

Updated by Armin about 3 years ago

No. There is format where data is grouped by 2 bytes (0xFFFF). And all I found to convert RAW audio to the same format is nothing. There are some C/CPP projects where is possible to convert to 0xFF format like this:

const uint8_t hashmap[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // !"#$%&'
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ()*+,-./
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567
0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>?
0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // HIJKLMNO
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // PQRSTUVW
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // XYZ[\]^_
0x00, 0x0a, 0x0b, 0x0c ... ... ... ...

but we need 0xFFFF format for announcement.c
So I stuck here. Don't have so much prog. skills.

atmega wrote:

Did you make any progress with announcement.c ?

Actions #4

Updated by laforge about 3 years ago

On Sun, Jan 31, 2021 at 09:53:10PM +0000, Armin [REDMINE] wrote:

No. There is format where data is grouped by 2 bytes (0xFFFF).

without looking at the code: This is likely because it's 16bit samples.

but we need 0xFFFF format for announcement.c
So I stuck here. Don't have so much prog. skills.

Please try the attached python script for conversion. It might be that
you need to change the '<' to '>' to get the correct endianness.

Actions #5

Updated by Armin about 3 years ago

laforge wrote:

Please try the attached python script for conversion. It might be that
you need to change the '<' to '>' to get the correct endianness.

Yes it works.
I also found this code, but for 8 bit chunks. Could somebody change it to output 16 bit chunks.

//file pcm2c.c 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include  

FILE * ifil; 
FILE * ofil; 
char ofilnam[20]; 
char ifilnam[20]; 

//----------------------- 
void main (int argc, char * argv[]){ 
unsigned char b,n; 

  printf("pcm2c  read 8 bit pcm, write to c   June 1 07 Bob G\n"); 
  if(argc != 3){ 
    printf("usage: pcm2c foo.pcm foo.c\n"); 
    exit(1); 
  } 
  strcpy(ifilnam,argv[1]); 
  ifil=fopen(ifilnam,"rb"); 

  strcpy(ofilnam,argv[2]); 
  ofil=fopen(ofilnam,"w"); 

  fprintf(ofil,"const char dat[]={\n"); 
  while(1){ 
    for(n=0; n<16; n++){ 
      fread(&b,1,sizeof(b),ifil); 
      fprintf(ofil,"0x%02x,",b); 
      if(feof(ifil)) break; 
    } 
    fprintf(ofil,"\n"); 
    if(feof(ifil)) break; 
  } 
  fprintf(ofil,"\n};\n"); 
  fclose(ifil); 
  fclose(ofil); 
} 
//------eof------------
Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)