-/* Very fast hack. It should be written correctly ! */
-void GSM_PlayOneNote (GSM_RingtoneNote note) {
- int Hz;
-
- Hz=GSM_GetFrequency(note.note);
-
- GSM->PlayTone(Hz,5);
-
- /* Is it correct ? Experimental values here */
- switch (note.style) {
- case StaccatoStyle:
- usleep (7500);
- GSM->PlayTone(0,0);
- usleep ((1500000/note.tempo*note.duration)-(7500));
- break;
- case ContinuousStyle:
- usleep (1500000/note.tempo*note.duration);
- break;
- case NaturalStyle:
- usleep (1500000/note.tempo*note.duration-50);
- GSM->PlayTone(0,0);
- usleep (50);
- break;
- }
-}
-
-void GSM_PlayRingtone (GSM_Ringtone *ringtone) {
-
- int i;
-
- for (i=0;i<ringtone->NrNotes;i++) {
- GSM_PlayOneNote(ringtone->notes[i]);
- }
-
- /* Disables buzzer */
- GSM->PlayTone(255*255,0);
-}
-
-/* Initializes one ringtone: first is number of ringtone in
- RingingTones in gnokii.h, second its' code, last position in phone menu */
-void RT(int number, int code, int menu) {
- RingingTones[number].code=code;
- RingingTones[number].menu=menu;
-}
-
-/* This function initializes structures with ringtones names adequate for
- your phone model and firmware; if your phone is not now supported:
- 1.set first ringtone in 1'st profile in your phone
- 2.make ./gnokii --getprofile 1
- 3.read ringtone code
- 4.see in gnokii.h, if ringtone name is gnokii.h in RingingTones (if not, add)
- 5.put here RT(a,b,c), where a is number of name in RingingTones in gnokii.h,
- b is its' code and c is number of ringtone in phone menu
- 6.repeat steps 1-5 for all ringtones
- 7.send me (Marcin-Wiacek@Topnet.PL) all RT and phone model */
-void PrepareRingingTones(char model[64], char rev[64]) {
-
- char rev2[64];
- int i;
- bool doit;
-
- if (!RingingTones[0].code) {
- if (!strcmp(model,"NSE-1")) //5110
- {
- RT( 2,18, 1);RT( 3,19, 2);RT( 7,23, 3);RT( 5,21, 4);RT( 9,25, 5);
- RT(20,48, 7);RT(11,27, 8);RT(33,59, 9);RT(35,62,10);
- RT(46,60,11);RT(16,36,12);RT(17,37,13);RT(13,32,14);RT(14,34,15);
- RT(19,43,16);RT(18,39,17);RT(24,50,18);RT(31,57,19);RT(28,54,20);
- RT(30,56,21);RT(40,73,22);RT(39,72,23);RT(37,69,24);
- RT(23,49,26);RT(38,71,27); RT(41,74,29);
-
- strcpy(rev2,"05.23"); //5.24 and higher
- doit=false;
- for(i=0;i<5;i++)
- {
- if (rev[i]<rev2[i]) break;
- if (rev[i]>rev2[i]) doit=true;
- }
-
- if (doit) {
- RT(22,47, 6);RT(47,58,25);RT(45,80,28);RT(43,75,30);
- } else
- {
- RT(21,47, 6);RT(32,58,25);RT(44,80,28);RT(42,75,30);
- }
- RingingTones[0].menu=30; /* How many ringtones in phone */
- }
- if (!strcmp(model,"NSM-1")) //6150
- {
- RT( 2,18, 1);RT( 3,19, 2);RT( 7,23, 3);RT( 6,22, 4);
- RT( 4,20, 5);RT( 5,21, 6);RT(15,35, 7);RT(12,30, 8);
- RT( 9,25, 9);RT(20,47,10);RT( 8,24,11);RT(11,27,12);
- RT(10,26,13);RT(34,60,14);RT(33,58,15);RT(35,61,16);
- RT(16,36,17);RT(13,32,18);RT(19,43,19);RT(18,39,20);
- RT(24,49,21);RT(31,56,22);RT(25,50,23);RT(27,52,24);
- RT(26,51,25);RT(28,53,26);RT(29,54,27);RT(30,55,28);
- RT(39,71,29);RT(37,68,30);RT(47,57,31);RT(23,48,32);
- RT(38,70,33);RT(36,67,34);RT(41,73,35);
- /*uploadable ringtone*/
- RT( 1,17,36);
- RingingTones[0].menu=36; /* How many ringtones in phone */
- }
- if (!strcmp(model,"NPE-3")) //6210
- {
- RT(19,64, 1);RT( 2,65, 2);RT( 3,66, 3);RT(15,67, 4);RT( 6,68, 5);
- RT(49,69, 6);RT(50,70, 7);RT( 7,71, 8);RT(35,72, 9);RT(33,73,10);
- RT(18,74,11);RT( 5,75,12);RT(51,76,13);RT(52,77,14);RT(53,78,15);
- RT(37,79,16);RT(54,80,17);RT(55,81,18);RT(56,82,19);RT(57,83,20);
- RT(58,84,21);RT(59,85,22);RT(25,86,23);RT(27,87,24);RT(30,88,25);
- RT(39,89,26);RT(24,90,27);RT( 8,91,28);RT(60,92,29);RT(61,93,30);
- RT(31,94,31);RT(62,95,32);RT(63,96,33);RT(64,97,34);RT(48,98,35);
- /* Uploadable ringtones */
- RT( 1,137,36);RT(65,138,37);RT(66,139,38);RT(67,140,39);RT(68,141,40);
-
- RingingTones[0].menu=40; /* How many ringtones in phone */
- }
- RingingTones[0].code=true;
- }
-}
-
-/* returns names from code or number in menu */
-char *RingingToneName(int code, int menu)
-{
- int index=1,i;
- GSM_Error error;
-
- if (code==0)
- {
- while (strcmp(RingingTones[index].name,"")) {
- if (RingingTones[index].menu==menu) break;
- index++;
- }
- } else
- {
- while (strcmp(RingingTones[index].name,"")) {
- if (RingingTones[index].code==code) break;
- index++;
- }
- }
-
- if (!strncmp(RingingTones[index].name,"Uploaded ",9)) {
- ringtone.location=atoi(&RingingTones[index].name[10]);
-
- error=GSM->GetBinRingtone(&ringtone);
-
- if (error==GE_NONE) return ringtone.name;
- if (error==GE_UNKNOWNMODEL) {