summaryrefslogtreecommitdiffabout
path: root/gammu
authorzautrix <zautrix>2004-08-30 20:21:20 (UTC)
committer zautrix <zautrix>2004-08-30 20:21:20 (UTC)
commit109a23b70f67552a9ce27f682bb2b1bdbb2bb4f3 (patch) (unidiff)
tree30407f1548315b403f1ad7c55c81744413fcd14c /gammu
parent5f4867356dc4b34da20b66e9ede71e22899e4a4b (diff)
downloadkdepimpi-109a23b70f67552a9ce27f682bb2b1bdbb2bb4f3.zip
kdepimpi-109a23b70f67552a9ce27f682bb2b1bdbb2bb4f3.tar.gz
kdepimpi-109a23b70f67552a9ce27f682bb2b1bdbb2bb4f3.tar.bz2
sine fix
Diffstat (limited to 'gammu') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/common.pro1
-rw-r--r--gammu/emb/common/service/gsmring.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/gammu/emb/common/common.pro b/gammu/emb/common/common.pro
index 9342cb7..0e719ee 100644
--- a/gammu/emb/common/common.pro
+++ b/gammu/emb/common/common.pro
@@ -151,36 +151,37 @@ protocol/alcatel/alcabus.c \
151protocol/nokia/mbus2.c \ 151protocol/nokia/mbus2.c \
152protocol/nokia/fbus2.c \ 152protocol/nokia/fbus2.c \
153protocol/nokia/phonet.c \ 153protocol/nokia/phonet.c \
154protocol/obex/obex.c \ 154protocol/obex/obex.c \
155protocol/symbian/mrouter.c \ 155protocol/symbian/mrouter.c \
156phone/pfunc.c \ 156phone/pfunc.c \
157phone/at/atgen.c \ 157phone/at/atgen.c \
158phone/at/siemens.c \ 158phone/at/siemens.c \
159phone/at/sonyeric.c \ 159phone/at/sonyeric.c \
160phone/alcatel/alcatel.c \ 160phone/alcatel/alcatel.c \
161phone/nokia/dct3/n6110.c \ 161phone/nokia/dct3/n6110.c \
162phone/nokia/dct3/n7110.c \ 162phone/nokia/dct3/n7110.c \
163phone/nokia/dct3/n9210.c \ 163phone/nokia/dct3/n9210.c \
164phone/nokia/dct3/dct3func.c \ 164phone/nokia/dct3/dct3func.c \
165phone/nokia/dct4/n3320.c \ 165phone/nokia/dct4/n3320.c \
166phone/nokia/dct4/n3650.c \ 166phone/nokia/dct4/n3650.c \
167phone/nokia/dct4/n6510.c \ 167phone/nokia/dct4/n6510.c \
168phone/nokia/dct4/dct4func.c \ 168phone/nokia/dct4/dct4func.c \
169phone/nokia/nauto.c \ 169phone/nokia/nauto.c \
170phone/nokia/nfunc.c \ 170phone/nokia/nfunc.c \
171phone/nokia/nfuncold.c \ 171phone/nokia/nfuncold.c \
172phone/obex/obexgen.c \ 172phone/obex/obexgen.c \
173phone/symbian/mroutgen.c 173phone/symbian/mroutgen.c
174 174
175DEFINES += DESKTOP_VERSION
175TARGET = microgammu 176TARGET = microgammu
176CONFIG = warn_off release console 177CONFIG = warn_off release console
177DESTDIR = ../../../bin 178DESTDIR = ../../../bin
178OBJECTS_DIR = obj/unix 179OBJECTS_DIR = obj/unix
179MOC_DIR = moc/unix 180MOC_DIR = moc/unix
180 181
181unix: { 182unix: {
182SOURCES += device/serial/ser_unx.c 183SOURCES += device/serial/ser_unx.c
183} 184}
184win32:{ 185win32:{
185SOURCES += device/serial/ser_w32.c 186SOURCES += device/serial/ser_w32.c
186} 187}
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index f7f7082..7df46f1 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -83,50 +83,54 @@ GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone)
83 'R','I','F','F', 83 'R','I','F','F',
84 0x00,0x00,0x00,0x00,/* Length */ 84 0x00,0x00,0x00,0x00,/* Length */
85 'W','A','V','E'}; 85 'W','A','V','E'};
86 unsigned char FMT_Header[] = {'f','m','t',' ', 86 unsigned char FMT_Header[] = {'f','m','t',' ',
87 0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x44,0xac, 87 0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x44,0xac,
88 0x00,0x00,0x88,0x58,0x01,0x00,0x02,0x00,0x10,0x00}; 88 0x00,0x00,0x88,0x58,0x01,0x00,0x02,0x00,0x10,0x00};
89 unsigned char DATA_Header[] = { 89 unsigned char DATA_Header[] = {
90 'd','a','t','a', 90 'd','a','t','a',
91 0x00,0x00,0x00,0x00};/* Length */ 91 0x00,0x00,0x00,0x00};/* Length */
92 short DATA_Buffer[60000]; 92 short DATA_Buffer[60000];
93 long wavfilesize; 93 long wavfilesize;
94 GSM_RingNote *Note; 94 GSM_RingNote *Note;
95 long i,j,length=0; 95 long i,j,length=0;
96 double phase=0,phase_step; 96 double phase=0,phase_step;
97 97
98 fwrite(&WAV_Header, 1, sizeof(WAV_Header),file); 98 fwrite(&WAV_Header, 1, sizeof(WAV_Header),file);
99 fwrite(&FMT_Header, 1, sizeof(FMT_Header),file); 99 fwrite(&FMT_Header, 1, sizeof(FMT_Header),file);
100 fwrite(&DATA_Header, 1, sizeof(DATA_Header),file); 100 fwrite(&DATA_Header, 1, sizeof(DATA_Header),file);
101 101
102 for (i=0;i<ringtone->NoteTone.NrCommands;i++) { 102 for (i=0;i<ringtone->NoteTone.NrCommands;i++) {
103 if (ringtone->NoteTone.Commands[i].Type == RING_Note) { 103 if (ringtone->NoteTone.Commands[i].Type == RING_Note) {
104 Note = &ringtone->NoteTone.Commands[i].Note; 104 Note = &ringtone->NoteTone.Commands[i].Note;
105 phase_step = GSM_RingNoteGetFrequency(*Note)*WAV_SAMPLE_RATE*1.5; 105 phase_step = GSM_RingNoteGetFrequency(*Note)*WAV_SAMPLE_RATE*1.5;
106 for (j=0;j<((long)(GSM_RingNoteGetFullDuration(*Note)*WAV_SAMPLE_RATE/70));j++) { 106 for (j=0;j<((long)(GSM_RingNoteGetFullDuration(*Note)*WAV_SAMPLE_RATE/70));j++) {
107 /*DATA_Buffer[j] = ((int)(sin(phase*PI)*50000));*/ 107#ifdef DESKTOP_VERSION
108 DATA_Buffer[j] = ((int)(sin(phase*PI)*50000));
109#else
110 // we have no sin on Zaurus
108 DATA_Buffer[j] = ((int)(0.5*50000)); 111 DATA_Buffer[j] = ((int)(0.5*50000));
112#endif
109 phase = phase + phase_step; 113 phase = phase + phase_step;
110 length++; 114 length++;
111 } 115 }
112 fwrite(&DATA_Buffer,sizeof(short),j,file); 116 fwrite(&DATA_Buffer,sizeof(short),j,file);
113 } 117 }
114 } 118 }
115 119
116 wavfilesize = sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header) + length*2; 120 wavfilesize = sizeof(WAV_Header) + sizeof(FMT_Header) + sizeof(DATA_Header) + length*2;
117 WAV_Header[4] = ((unsigned char)wavfilesize % 256); 121 WAV_Header[4] = ((unsigned char)wavfilesize % 256);
118 WAV_Header[5] = ((unsigned char)wavfilesize / 256); 122 WAV_Header[5] = ((unsigned char)wavfilesize / 256);
119 WAV_Header[6] = ((unsigned char)wavfilesize / (256*256)); 123 WAV_Header[6] = ((unsigned char)wavfilesize / (256*256));
120 WAV_Header[7] = ((unsigned char)wavfilesize / (256*256*256)); 124 WAV_Header[7] = ((unsigned char)wavfilesize / (256*256*256));
121 wavfilesize = wavfilesize - 54; 125 wavfilesize = wavfilesize - 54;
122 DATA_Header[4] = ((unsigned char)wavfilesize % 256); 126 DATA_Header[4] = ((unsigned char)wavfilesize % 256);
123 DATA_Header[5] = ((unsigned char)wavfilesize / 256); 127 DATA_Header[5] = ((unsigned char)wavfilesize / 256);
124 DATA_Header[6] = ((unsigned char)wavfilesize / (256*256)); 128 DATA_Header[6] = ((unsigned char)wavfilesize / (256*256));
125 DATA_Header[7] = ((unsigned char)wavfilesize / (256*256*256)); 129 DATA_Header[7] = ((unsigned char)wavfilesize / (256*256*256));
126 130
127 fseek( file, 0, SEEK_SET); 131 fseek( file, 0, SEEK_SET);
128 fwrite(&WAV_Header, 1, sizeof(WAV_Header),file); 132 fwrite(&WAV_Header, 1, sizeof(WAV_Header),file);
129 fwrite(&FMT_Header, 1, sizeof(FMT_Header),file); 133 fwrite(&FMT_Header, 1, sizeof(FMT_Header),file);
130 fwrite(&DATA_Header, 1, sizeof(DATA_Header),file); 134 fwrite(&DATA_Header, 1, sizeof(DATA_Header),file);
131 135
132 return ERR_NONE; 136 return ERR_NONE;