23 # define WIN32_LEAN_AND_MEAN 30 #include "../misc/coding/coding.h" 37 #define chk_fwrite(data, size, count, file) \ 38 if (fwrite(data, size, count, file) != count) goto fail; 49 case Note_C : freq = 52330;
break;
51 case Note_D : freq = 58730;
break;
53 case Note_E : freq = 65930;
break;
54 case Note_F : freq = 69850;
break;
56 case Note_G : freq = 78400;
break;
58 case Note_A : freq = 88000;
break;
60 case Note_H : freq = 98780;
break;
91 case DottedNote : duration = duration * 3/2;
break;
93 case Length_2_3 : duration = duration * 2/3;
break;
100 # define PI 3.141592654 103 #define WAV_SAMPLE_RATE 44100 108 unsigned char WAV_Header[] = {
112 unsigned char FMT_Header[] = {
'f',
'm',
't',
' ',
113 0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x44,0xac,
114 0x00,0x00,0x88,0x58,0x01,0x00,0x02,0x00,0x10,0x00};
115 unsigned char DATA_Header[] = {
117 0x00,0x00,0x00,0x00};
122 size_t j,length=0, duration;
123 double phase=0,phase_step;
125 chk_fwrite(&WAV_Header, 1,
sizeof(WAV_Header), file);
126 chk_fwrite(&FMT_Header, 1,
sizeof(FMT_Header), file);
127 chk_fwrite(&DATA_Header, 1,
sizeof(DATA_Header), file);
139 for (j = 0; j < duration; j++) {
140 DATA = ((int)(sin(phase*
PI) * 50000));
142 phase = phase + phase_step;
148 wavfilesize =
sizeof(WAV_Header) +
sizeof(FMT_Header) +
sizeof(DATA_Header) + length*2;
149 WAV_Header[4] = ((
unsigned char)wavfilesize % 256);
150 WAV_Header[5] = ((
unsigned char)wavfilesize / 256);
151 WAV_Header[6] = ((
unsigned char)wavfilesize / (256*256));
152 WAV_Header[7] = ((
unsigned char)wavfilesize / (256*256*256));
153 wavfilesize = wavfilesize - 54;
154 DATA_Header[4] = ((
unsigned char)wavfilesize % 256);
155 DATA_Header[5] = ((
unsigned char)wavfilesize / 256);
156 DATA_Header[6] = ((
unsigned char)wavfilesize / (256*256));
157 DATA_Header[7] = ((
unsigned char)wavfilesize / (256*256*256));
159 fseek( file, 0, SEEK_SET);
160 chk_fwrite(&WAV_Header, 1,
sizeof(WAV_Header), file);
161 chk_fwrite(&FMT_Header, 1,
sizeof(FMT_Header), file);
162 chk_fwrite(&DATA_Header, 1,
sizeof(DATA_Header), file);
175 fprintf(file,
"\x0C\x01\x2C");
212 unsigned char buffer[15];
219 for (i=0;i<6;i++) buffer[i]=0;
242 DefNoteDuration = k * 32;
243 dbgprintf(NULL,
"DefNoteDuration=%d\n", DefNoteDuration);
244 switch (DefNoteDuration) {
255 for (i=0;i<9;i++) buffer[i]=0;
261 buffer[Note->
Scale - 1]++;
272 DefNoteScale = k + 1;
274 fprintf(file,
",o=%i,",DefNoteScale);
275 dbgprintf(NULL,
"DefNoteScale=%d\n", DefNoteScale);
297 DefNoteTempo=Note->
Tempo;
298 DefNoteStyle=Note->
Style;
299 switch (Note->
Style) {
306 fprintf(file,
"b=%i:",DefNoteTempo);
307 dbgprintf(NULL,
"DefNoteTempo=%d\n", DefNoteTempo);
312 if (Note->
Style!=DefNoteStyle) {
314 if (!firstcomma) fprintf(file,
",");
316 DefNoteStyle=Note->
Style;
317 switch (Note->
Style) {
324 if (Note->
Tempo!=DefNoteTempo) {
326 if (!firstcomma) fprintf(file,
",");
328 DefNoteTempo=Note->
Tempo;
329 fprintf(file,
"b=%i",DefNoteTempo);
332 if (Note->
Duration!=DefNoteDuration) {
334 if (!firstcomma) fprintf(file,
",");
347 if (!firstcomma) fprintf(file,
",");
351 switch (Note->
Note) {
352 case Note_C :fprintf(file,
"c");
break;
353 case Note_Cis:fprintf(file,
"c#");
break;
354 case Note_D :fprintf(file,
"d");
break;
355 case Note_Dis:fprintf(file,
"d#");
break;
356 case Note_E :fprintf(file,
"e");
break;
357 case Note_F :fprintf(file,
"f");
break;
358 case Note_Fis:fprintf(file,
"f#");
break;
359 case Note_G :fprintf(file,
"g");
break;
360 case Note_Gis:fprintf(file,
"g#");
break;
361 case Note_A :fprintf(file,
"a");
break;
362 case Note_Ais:fprintf(file,
"a#");
break;
363 case Note_H :fprintf(file,
"h");
break;
364 default :fprintf(file,
"p");
break;
371 fprintf(file,
"%i",Note->
Scale);
390 static void WriteVarLen(
unsigned char* midifile,
size_t* current,
long value)
394 buffer = value & 0x7f;
396 while (value >>= 7) {
399 buffer += (value & 0x7f);
403 midifile[(*current)++] = (
unsigned char)buffer;
415 int pause_time = 0, duration, i, note=0, length = 20;
419 unsigned char midifile[3000] = {
420 0x4D, 0x54, 0x68, 0x64,
421 0x00, 0x00, 0x00, 0x06,
425 0x4D, 0x54, 0x72, 0x6B,
426 0x00, 0x00, 0x00, 0x00,
427 0x00, 0xFF, 0x51, 0x03,
437 duration = 60000000/Note->
Tempo;
439 midifile[current++] = (
unsigned char)(duration >> 16);
440 midifile[current++] = (
unsigned char)(duration >> 8);
441 midifile[current++] = (
unsigned char)duration;
446 if (!started)
continue;
449 pause_time += duration;
452 note = Note->
Note/16 + 12 * Note->
Scale - 1;
457 midifile[current++]=0x90;
458 midifile[current++]=note;
459 midifile[current++]=0x64;
462 midifile[current++]=0x80;
463 midifile[current++]=note;
464 midifile[current++]=0x64;
468 midifile[current++] = 0x00;
469 midifile[current++] = 0xFF;
470 midifile[current++] = 0x2F;
471 midifile[current++] = 0x00;
472 midifile[length++] = (current-22) >> 8;
473 midifile[length] = current-22;
500 file = fopen(FileName,
"wb");
503 switch (ringtone->
Format) {
505 if (strstr(FileName,
".ott")) {
507 }
else if (strstr(FileName,
".rng")) {
509 }
else if (strstr(FileName,
".mid")) {
511 }
else if (strstr(FileName,
".imy")) {
513 }
else if (strstr(FileName,
".ime")) {
515 }
else if (strstr(FileName,
".wav")) {
522 error =
savebin(file, ringtone);
528 error =
savemmf(file, ringtone);
542 int DefNoteTempo = 63;
546 char buffer[2000],Name[100];
549 readbytes = fread(buffer, 1,
sizeof(buffer), file);
554 while (buffer[i] !=
':' && i < readbytes) {
555 if (buffer[i] == 0x00)
return ERR_NONE;
561 }
else if (i >= readbytes) {
564 memcpy(Name,buffer,i);
572 if (i >= readbytes) {
581 switch (atoi(buffer+i+2)) {
591 switch (atoi(buffer+i+2)) {
592 case 4: DefNoteScale =
Scale_440 ;
break;
593 case 5: DefNoteScale =
Scale_880 ;
break;
599 DefNoteTempo=atoi(buffer+i+2);
600 dbgprintf(NULL,
"Tempo = %i\n",DefNoteTempo);
603 switch (buffer[i+1]) {
608 switch (buffer[i+2]) {
615 while (buffer[i] !=
':' && buffer[i] !=
',') {
616 if (buffer[i] == 0x00)
return ERR_NONE;
619 if (buffer[i] ==
',') i++;
620 if (buffer[i] ==
':')
break;
622 dbgprintf(NULL,
"DefNoteDuration=%d\n", DefNoteDuration);
623 dbgprintf(NULL,
"DefNoteScale=%d\n", DefNoteScale);
630 switch (buffer[i+1]) {
657 switch (buffer[i+2]) {
658 case 4: DefNoteScale =
Scale_440 ;
break;
659 case 5: DefNoteScale =
Scale_880 ;
break;
665 switch (buffer[i+1]) {
670 switch (buffer[i+2]) {
679 Note->
Style = DefNoteStyle;
680 Note->
Tempo = DefNoteTempo;
681 Note->
Scale = DefNoteScale;
687 switch (atoi(buffer+i)) {
696 while(isdigit((
int)buffer[i])) i++;
699 if (buffer[i]==
'.') {
708 case 'A':
case 'a': Note->
Note =
Note_A;
break;
709 case 'B':
case 'b': Note->
Note =
Note_H;
break;
710 case 'C':
case 'c': Note->
Note =
Note_C;
break;
711 case 'D':
case 'd': Note->
Note =
Note_D;
break;
712 case 'E':
case 'e': Note->
Note =
Note_E;
break;
713 case 'F':
case 'f': Note->
Note =
Note_F;
break;
714 case 'G':
case 'g': Note->
Note =
Note_G;
break;
715 case 'H':
case 'h': Note->
Note =
Note_H;
break;
718 if (i >= readbytes)
break;
720 if (buffer[i]==
'#') {
721 switch (Note->
Note) {
730 if (i >= readbytes)
break;
734 if (buffer[i]==
'.') {
737 if (i >= readbytes)
break;
742 switch (atoi(buffer+i)) {
749 if (i >= readbytes)
break;
755 if (i >= readbytes)
break;
756 while (buffer[i] !=
',') {
757 if (buffer[i] == 0x00)
return ERR_NONE;
759 if (i >= readbytes)
break;
761 if (i >= readbytes)
break;
762 if (buffer[i] ==
',') i++;
763 if (i >= readbytes) {
776 i = fread(Buffer, 1, 2000, file);
786 bytes_read = fread(Buffer, 1, 4000, file);
790 if (Buffer[j] ==0x00 && Buffer[j+1]==0x02 &&
791 Buffer[j+2]==0x4a && Buffer[j+3]==0x3a)
break;
803 unsigned char buffer[2000];
808 while (buffer[i]!=0x00) i++;
810 while (buffer[i]!=0x02 && buffer[i+1]!=0xFC && buffer[i+2]!=0x09) {
833 size_t length=0,readbytes=0;
836 fstat(fileno(file), &st);
841 readbytes = fread(buffer, 1, length, file);
842 if (readbytes != length) {
843 dbgprintf(NULL,
"Could not read whole file!\n");
847 dbgprintf(NULL,
"Length %ld name \"%s\"\n", (
long)length,
855 unsigned char buffer[2000];
859 if (buffer[18]==0x00 && buffer[21]!=0x02) {
877 unsigned char buffer[300];
880 char *file_only_name;
883 dbgprintf(NULL,
"Loading ringtone %s\n",FileName);
884 file = fopen(FileName,
"rb");
887 file_only_name = strrchr(FileName,
'/');
888 if (file_only_name == NULL) {
889 file_only_name = strrchr(FileName,
'\\');
893 if (file_only_name == NULL) {
894 file_only_name = FileName;
898 len = strlen(file_only_name);
907 readbytes = fread(buffer, 1, 4, file);
908 if (ringtone->
Format == 0x00 && readbytes == 4) {
910 if (buffer[0]==0x00 && buffer[1]==0x00 &&
911 buffer[2]==0x0C && buffer[3]==0x01) {
914 if (buffer[0]==0x00 && buffer[1]==0x00 &&
918 if (buffer[0]==0x4D && buffer[1]==0x54 &&
919 buffer[2]==0x68 && buffer[3]==0x64) {
922 if (buffer[0]==0x4D && buffer[1]==0x4D &&
923 buffer[2]==0x4D && buffer[3]==0x44) {
926 if (buffer[0]==
'R' && buffer[1]==
'I' &&
927 buffer[2]==
'F' && buffer[3]==
'F') {
928 dbgprintf(NULL,
"RIFF is not supported for loading!\n");
934 switch (ringtone->
Format) {
936 if (buffer[0]==0x02 && buffer[1]==0x4A) {
938 }
else if (buffer[0]==0xC7 && buffer[1]==0x45) {
946 if (buffer[0]==0x00 && buffer[1]==0x00 &&
947 buffer[2]==0x0C && buffer[3]==0x01) {
950 if (buffer[0]==0x00 && buffer[1]==0x00 &&
952 error=
loadre(file,ringtone);
959 error =
loadmmf(file,ringtone);
973 25, 28, 31, 35, 40, 45, 50, 56, 63, 70,
974 80, 90, 100, 112, 125, 140, 160, 180, 200, 225,
975 250, 285, 320, 355, 400, 450, 500, 565, 635, 715,
994 unsigned char CommandLength = 0x02;
995 unsigned char Loop = 0x15;
997 unsigned char Buffer[200];
998 size_t StartBit=0, OldStartBit;
999 int StartBitHowManyCommands;
1000 int HowManyCommands = 0;
1001 int HowManyNotes = 0;
1029 AddBufferByte(package, &StartBit, ((
unsigned char)(Loop<<4)), 4);
1032 StartBitHowManyCommands=StartBit;
1033 StartBit = StartBit + 8;
1052 OldStartBit = StartBit;
1058 if ((j/8)>(*maxlength)) {
1059 StartBit = OldStartBit;
1062 DefScale = Note->
Scale;
1064 AddBufferByte(package, &StartBit, ((
unsigned char)((DefScale-4)<<6)), 2);
1067 if (DefStyle != Note->
Style) {
1070 if ((j/8)>(*maxlength)) {
1071 StartBit = OldStartBit;
1074 DefStyle = Note->
Style;
1076 AddBufferByte(package, &StartBit, ((
unsigned char)DefStyle), 2);
1084 if ((j/8)>(*maxlength)) {
1085 StartBit = OldStartBit;
1091 AddBufferByte(package, &StartBit, ((
unsigned char)DefTempo), 5);
1096 if ((j/8)>(*maxlength)) {
1097 StartBit = OldStartBit;
1107 if (*maxlength<1000) {
1109 if (HowManyNotes==130-1)
break;
1117 OldStartBit = StartBit;
1118 StartBit = StartBitHowManyCommands;
1120 AddBufferByte(package, &StartBit, ((
unsigned char)HowManyCommands), 8);
1121 StartBit = OldStartBit;
1123 *maxlength=StartBit/8;
1131 int l, q, i, spec, HowMany;
1151 dbgprintf(NULL,
"Not RingingToneProgramming\n");
1175 GetBuffer(package, &StartBit, Buffer, 8*l);
1182 dbgprintf(NULL,
"Number of song patterns: %i\n",l);
1188 dbgprintf(NULL,
"Not PatternHeaderId\n");
1202 for (i=0;i<HowMany;i++) {
1236 Note->
Scale = DefScale;
1237 Note->
Style = DefStyle;
1238 Note->
Tempo = DefTempo;
1243 dbgprintf(NULL,
"Unsupported block %i %i\n",q,i);
1252 int current = 0, i, note, lastnote = 0, duration;
1254 unsigned char end[] = {0x40, 0x7D, 0x40, 0x5C, 0x0A, 0xFE, 0x40,
1255 0x20, 0x40, 0x7D, 0x40, 0x37, 0x0A, 0xFE,
1256 0x0A, 0x0A, 0x40, 0x32, 0x07, 0x0B};
1277 note = 113 + Note->
Note/16;
1279 switch (Note->
Scale) {
1281 case Scale_880 : note = note + 12;
break;
1291 switch (Note->
Style) {
1301 if (note != 0x40 && duration) {
1308 if (note != 0x40 && note == lastnote && duration) {
1314 while (duration > 125) {
1324 for (i = 0; i < (int)
sizeof(end); i++) dest->
NokiaBinary.
Frame[current++] = end[i];
1330 size_t NrNotes = 0, i = 3, j, StartRepeat = 0, EndRepeat;
1331 int z, repeat = 0, accuracy;
1333 unsigned char command,length=0;
1343 while (i<src->NokiaBinary.Length) {
1346 if (command != 0x06 && command != 0x00 && command != 0x09) {
1349 dbgprintf(NULL,
"Block %02x %02x - ",length,command);
1350 }
else dbgprintf(NULL,
"Block %02x - ",command);
1351 if (command >= 114 && command <= 161) {
1353 if (command >= 114 && command <= 124) {
1354 NotesScale[NrNotes] =
Scale_440; command -= 114;
1355 }
else if (command >= 125 && command <= 137) {
1356 NotesScale[NrNotes] =
Scale_880; command -= 126;
1357 }
else if (command >= 138 && command <= 149) {
1358 NotesScale[NrNotes] =
Scale_1760; command -= 138;
1359 }
else if (command >= 150 && command <= 161) {
1360 NotesScale[NrNotes] =
Scale_3520; command -= 150;
1365 case 0 : Notes[NrNotes] =
Note_C;
break;
1366 case 1 : Notes[NrNotes] =
Note_Cis;
break;
1367 case 2 : Notes[NrNotes] =
Note_D;
break;
1368 case 3 : Notes[NrNotes] =
Note_Dis;
break;
1369 case 4 : Notes[NrNotes] =
Note_E;
break;
1370 case 5 : Notes[NrNotes] =
Note_F;
break;
1371 case 6 : Notes[NrNotes] =
Note_Fis;
break;
1372 case 7 : Notes[NrNotes] =
Note_G;
break;
1373 case 8 : Notes[NrNotes] =
Note_Gis;
break;
1374 case 9 : Notes[NrNotes] =
Note_A;
break;
1375 case 10 : Notes[NrNotes] =
Note_Ais;
break;
1376 case 11 : Notes[NrNotes] =
Note_H;
break;
1377 default : Notes[NrNotes] =
Note_Pause;
break;
1380 Notes[NrNotes - 1] == Notes[NrNotes] &&
1381 NotesScale[NrNotes - 1] == NotesScale[NrNotes]) {
1382 NotesLen[NrNotes - 1] += length;
1384 NotesLen[NrNotes] = length;
1387 }
else switch (command) {
1392 dbgprintf(NULL,
"repeat %i times\n",length);
1394 StartRepeat = NrNotes;
1398 EndRepeat = NrNotes;
1399 for (z=0;z<repeat-1;z++) {
1400 for (j=StartRepeat;j<EndRepeat;j++) {
1401 Notes[NrNotes] = Notes[j];
1402 NotesScale[NrNotes] = NotesScale[j];
1403 NotesLen[NrNotes] = NotesLen[j];
1405 dbgprintf(NULL,
"Adding repeat note %i %i\n",Notes[j],NotesLen[j]);
1410 if (length == 0x0B) {
1419 if (length == 0x01) {
1420 dbgprintf(NULL,
"Let's start our song\n");
1423 if (length == 0x0A) {
1424 dbgprintf(NULL,
"Ending joining note\n");
1427 if (length == 0xFE) {
1428 dbgprintf(NULL,
"Starting joining note\n");
1436 Notes[NrNotes - 1] == Notes[NrNotes]) {
1437 NotesLen[NrNotes - 1] += length;
1439 NotesLen[NrNotes] = length;
1440 NotesScale[NrNotes] = 0;
1449 while (NrNotes > 0 && Notes[NrNotes-1] ==
Note_Pause) {
1453 for (accuracy=1; accuracy<5; accuracy++) {
1456 Lengths[0] = 30000/i;
1457 for (j=0;j<5;j++) Lengths[j+1] = Lengths[j] / 2;
1458 for (j=0;j<6;j++) Lengths[6+j] = Lengths[j] * 3/2;
1459 for (j=0;j<6;j++) Lengths[12+j] = Lengths[j] * 9/4;
1460 for (j=0;j<6;j++) Lengths[18+j] = Lengths[j] * 2/3;
1463 dbgprintf(NULL,
"Length matrix (%ld) : ", (
long)i);
1464 for (j=0;j<6*4;j++)
dbgprintf(NULL,
"%i ",Lengths[j]);
1469 for (j=0;j<NrNotes;j++) {
1470 dbgprintf(NULL,
"Comparing to %i\n",NotesLen[j]);
1472 for (z=0;z<6*4;z++) {
1473 if (NotesLen[j] - Lengths[z] > -accuracy &&
1474 NotesLen[j] - Lengths[z] < accuracy) {
1479 if (!foundlen)
break;
1481 if (foundlen)
break;
1490 for (i=0;i<6;i++) Duration[i] = Duration[i];
1491 for (i=0;i<6;i++) Duration[i+6] = Duration[i];
1492 for (i=0;i<6;i++) Duration[i+12] = Duration[i];
1493 for (i=0;i<6;i++) Duration[i+18] = Duration[i];
1495 for (i=0;i<6;i++) DurationSpec[i+6] =
DottedNote;
1497 for (i=0;i<6;i++) DurationSpec[i+18] =
Length_2_3;
1499 for (i=0;i<NrNotes;i++) {
1502 Note->
Note = Notes[i];
1503 Note->
Tempo = Speed;
1506 for (z=0;z<6*4;z++) {
1507 if (NotesLen[i] - Lengths[z] > -accuracy &&
1508 NotesLen[i] - Lengths[z] < accuracy) {
1556 if (src->
Format==Format) {
1567 int i, NrNotes = 0, Len, Max = *maxlength;
1581 *maxlength+=sprintf(package,
"BEGIN:IMELODY%c%c",13,10);
1583 *maxlength+=sprintf(package+(*maxlength),
"VERSION:1.0%c%c",13,10);
1585 *maxlength+=sprintf(package+(*maxlength),
"VERSION:1.2%c%c",13,10);
1587 *maxlength+=sprintf(package+(*maxlength),
"FORMAT:CLASS1.0%c%c",13,10);
1603 DefNoteTempo = Note->
Tempo;
1604 Len+=sprintf(package+Len,
"BEAT:%i%c%c",DefNoteTempo,13,10);
1605 dbgprintf(NULL,
"DefNoteTempo=%d\n",DefNoteTempo);
1608 DefNoteStyle = Note->
Style;
1609 switch (DefNoteStyle) {
1611 case NaturalStyle :Len+=sprintf(package+Len,
"STYLE:S0%c%c",13,10);
break;
1612 case ContinuousStyle:Len+=sprintf(package+Len,
"STYLE:S1%c%c",13,10);
break;
1613 case StaccatoStyle :Len+=sprintf(package+Len,
"STYLE:S2%c%c",13,10);
break;
1616 Len+=sprintf(package+Len,
"MELODY:");
1619 if ((Len+15) > Max) {
break; }
1621 if (Len > Max) {
break; }
1634 if (!started)
break;
1636 Len+=sprintf(package+Len,
"*%i",Note->
Scale-1);
1638 switch (Note->
Note) {
1639 case Note_C :Len+=sprintf(package+Len,
"c");
break;
1640 case Note_Cis :Len+=sprintf(package+Len,
"#c");
break;
1641 case Note_D :Len+=sprintf(package+Len,
"d");
break;
1642 case Note_Dis :Len+=sprintf(package+Len,
"#d");
break;
1643 case Note_E :Len+=sprintf(package+Len,
"e");
break;
1644 case Note_F :Len+=sprintf(package+Len,
"f");
break;
1645 case Note_Fis :Len+=sprintf(package+Len,
"#f");
break;
1646 case Note_G :Len+=sprintf(package+Len,
"g");
break;
1647 case Note_Gis :Len+=sprintf(package+Len,
"#g");
break;
1648 case Note_A :Len+=sprintf(package+Len,
"a");
break;
1649 case Note_Ais :Len+=sprintf(package+Len,
"#a");
break;
1650 case Note_H :Len+=sprintf(package+Len,
"b");
break;
1651 case Note_Pause :Len+=sprintf(package+Len,
"r");
break;
1664 case DottedNote : package[Len++] =
'.';
break;
1666 case Length_2_3 : package[Len++] =
';';
break;
1671 if ((Len+15) > Max) { end =
TRUE;
break; }
1673 if (Len > Max) { end =
TRUE;
break; }
1678 if ((Len + 6) > Max) { end =
TRUE;
break; }
1679 (*maxlength)+=sprintf(package+Len,
"ledoff");
1682 if ((Len + 5) > Max) { end =
TRUE;
break; }
1683 (*maxlength)+=sprintf(package+Len,
"ledon");
1686 if ((Len + 7) > Max) { end =
TRUE;
break; }
1687 (*maxlength)+=sprintf(package+Len,
"vibeoff");
1690 if ((Len + 6) > Max) { end =
TRUE;
break; }
1691 (*maxlength)+=sprintf(package+Len,
"vibeon");
1694 if ((Len + 7) > Max) { end =
TRUE;
break; }
1695 (*maxlength)+=sprintf(package+Len,
"backoff");
1698 if ((Len + 6) > Max) { end =
TRUE;
break; }
1699 (*maxlength)+=sprintf(package+Len,
"backon");
1708 if (version != 0) *maxlength+=sprintf(package+(*maxlength),
"%c%cEND:IMELODY%c%c",13,10,13,10);
1717 for (i = 0; i < Info->
Number; i++) {
GSM_RingCommand Commands[GSM_MAX_RINGTONE_NOTES]
GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
int GSM_RingNoteGetFrequency(GSM_RingNote Note)
unsigned char Name[(GSM_MAX_RINGTONE_NAME_LENGTH+1) *2]
GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
static GSM_Error loadott(FILE *file, GSM_Ringtone *ringtone)
GSM_Error GSM_SaveRingtoneMidi(FILE *file, GSM_Ringtone *ringtone)
#define SM_InstructionID_StyleInstructionId
char * DecodeUnicodeString(const unsigned char *src)
GSM_RingtoneFormat Format
#define SM_InstructionID_TempoInstructionId
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
static GSM_Error loadcommunicator(FILE *file, GSM_Ringtone *ringtone)
static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
GSM_RingNoteDuration Duration
void AddBufferByte(unsigned char *Destination, size_t *CurrentBit, unsigned char Source, size_t BitsToProcess)
void BufferAlign(unsigned char *Destination, size_t *CurrentBit)
static GSM_Error loadbin(FILE *file, GSM_Ringtone *ringtone)
void GetBufferInt(unsigned char *Source, size_t *CurrentBit, int *integer, size_t BitsToProcess)
static void RTTL2Binary(GSM_Ringtone *dest, GSM_Ringtone *src)
#define GSM_MAX_RINGTONE_NAME_LENGTH
#define SM_InstructionID_NoteInstructionId
size_t UnicodeLength(const unsigned char *str)
#define SM_InstructionID_ScaleInstructionId
unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, size_t *maxlength)
GSM_NoteRingtone NoteTone
void BufferAlignNumber(size_t *CurrentBit)
int GSM_RTTLGetTempo(int Beats)
static GSM_Error loadrttl(FILE *file, GSM_Ringtone *ringtone)
static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
#define SM_CommandEnd_CommandEnd
static int SM_BeatsPerMinute[]
#define SM_Command_RingingToneProgramming
#define GSM_MAX_RINGTONE_NOTES
GSM_Error GSM_SaveRingtoneRttl(FILE *file, GSM_Ringtone *ringtone)
void GetBuffer(unsigned char *Source, size_t *CurrentBit, unsigned char *Destination, size_t BitsToProcess)
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
const unsigned char * GSM_GetRingtoneName(const GSM_AllRingtonesInfo *Info, const int ID)
GSM_NokiaBinaryRingtone NokiaBinary
unsigned char Frame[50000]
GSM_RingtoneInfo * Ringtone
GSM_RingNoteDurationSpec DurationSpec
int GSM_RingNoteGetFullDuration(GSM_RingNote Note)
static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
static void Binary2RTTL(GSM_Ringtone *dest, GSM_Ringtone *src)
static GSM_Error savebin(FILE *file, GSM_Ringtone *ringtone)
GSM_Error GSM_DecodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, size_t maxlength UNUSED)
GSM_BinaryTone BinaryTone
void AddBuffer(unsigned char *Destination, size_t *CurrentBit, unsigned char *Source, size_t BitsToProcess)
void DecodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, size_t len)
void EncodeUnicodeSpecialNOKIAChars(unsigned char *dest, const unsigned char *src, size_t len)
static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
unsigned char Name[30 *2]
GSM_Error GSM_SaveRingtoneWav(FILE *file, GSM_Ringtone *ringtone)
static void WriteVarLen(unsigned char *midifile, size_t *current, long value)
GSM_Error GSM_RingtoneConvert(GSM_Ringtone *dest, GSM_Ringtone *src, GSM_RingtoneFormat Format)
GSM_Error GSM_SaveRingtoneIMelody(FILE *file, GSM_Ringtone *ringtone)
#define SM_InstructionID_VolumeInstructionId
unsigned char GSM_EncodeEMSSound(GSM_Ringtone *ringtone, unsigned char *package, size_t *maxlength, GSM_RingtoneVersion version, gboolean start)
#define SM_InstructionID_PatternHeaderId
#define SM_PatternID_A_part
GSM_Error GSM_SaveRingtoneOtt(FILE *file, GSM_Ringtone *ringtone)
#define chk_fwrite(data, size, count, file)
#define SM_Song_BasicSongType