summaryrefslogtreecommitdiff
path: root/core/applets/vmemo
Unidiff
Diffstat (limited to 'core/applets/vmemo') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp779
-rw-r--r--core/applets/vmemo/vmemo.pro2
-rw-r--r--core/applets/vmemo/vmemoimpl.cpp42
3 files changed, 434 insertions, 389 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 7021fae..e25a1ab 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -1,12 +1,12 @@
1/************************************************************************************ 1/************************************************************************************
2** 2 **
3** This file may be distributed and/or modified under the terms of the 3 ** This file may be distributed and/or modified under the terms of the
4** GNU General Public License version 2 as published by the Free Software 4 ** GNU General Public License version 2 as published by the Free Software
5** Foundation and appearing in the file LICENSE.GPL included in the 5 ** Foundation and appearing in the file LICENSE.GPL included in the
6** packaging of this file. 6 ** packaging of this file.
7** 7 **
8** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 8 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 9 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10** 10 **
11************************************************************************************/ 11 ************************************************************************************/
12// copyright 2002 Jeremy Cowgar <jc@cowgar.com> 12// copyright 2002 Jeremy Cowgar <jc@cowgar.com>
@@ -75,121 +75,121 @@ int seq = 0;
75static char * vmemo_xpm[] = { 75static char * vmemo_xpm[] = {
76"16 16 102 2", 76 "16 16 102 2",
77" c None", 77 " c None",
78". c #60636A", 78 ". c #60636A",
79"+ c #6E6E72", 79 "+ c #6E6E72",
80"@ c #68696E", 80 "@ c #68696E",
81"# c #4D525C", 81 "# c #4D525C",
82"$ c #6B6C70", 82 "$ c #6B6C70",
83"% c #E3E3E8", 83 "% c #E3E3E8",
84"& c #EEEEF2", 84 "& c #EEEEF2",
85"* c #EAEAEF", 85 "* c #EAEAEF",
86"= c #CACAD0", 86 "= c #CACAD0",
87"- c #474A51", 87 "- c #474A51",
88"; c #171819", 88 "; c #171819",
89"> c #9B9B9F", 89 "> c #9B9B9F",
90", c #EBEBF0", 90 ", c #EBEBF0",
91"' c #F4F4F7", 91 "' c #F4F4F7",
92") c #F1F1F5", 92 ") c #F1F1F5",
93"! c #DEDEE4", 93 "! c #DEDEE4",
94"~ c #57575C", 94 "~ c #57575C",
95"{ c #010101", 95 "{ c #010101",
96"] c #A2A2A6", 96 "] c #A2A2A6",
97"^ c #747477", 97 "^ c #747477",
98"/ c #B5B5B8", 98 "/ c #B5B5B8",
99"( c #AEAEB2", 99 "( c #AEAEB2",
100"_ c #69696D", 100 "_ c #69696D",
101": c #525256", 101 ": c #525256",
102"< c #181C24", 102 "< c #181C24",
103"[ c #97979B", 103 "[ c #97979B",
104"} c #A7A7AC", 104 "} c #A7A7AC",
105"| c #B0B0B4", 105 "| c #B0B0B4",
106"1 c #C8C8D1", 106 "1 c #C8C8D1",
107"2 c #75757B", 107 "2 c #75757B",
108"3 c #46464A", 108 "3 c #46464A",
109"4 c #494A4F", 109 "4 c #494A4F",
110"5 c #323234", 110 "5 c #323234",
111"6 c #909095", 111 "6 c #909095",
112"7 c #39393B", 112 "7 c #39393B",
113"8 c #757578", 113 "8 c #757578",
114"9 c #87878E", 114 "9 c #87878E",
115"0 c #222224", 115 "0 c #222224",
116"a c #414144", 116 "a c #414144",
117"b c #6A6A6E", 117 "b c #6A6A6E",
118"c c #020C16", 118 "c c #020C16",
119"d c #6B6B6F", 119 "d c #6B6B6F",
120"e c #68686D", 120 "e c #68686D",
121"f c #5B5B60", 121 "f c #5B5B60",
122"g c #8A8A8F", 122 "g c #8A8A8F",
123"h c #6B6B6E", 123 "h c #6B6B6E",
124"i c #ADADB2", 124 "i c #ADADB2",
125"j c #828289", 125 "j c #828289",
126"k c #3E3E41", 126 "k c #3E3E41",
127"l c #CFCFD7", 127 "l c #CFCFD7",
128"m c #4C4C50", 128 "m c #4C4C50",
129"n c #000000", 129 "n c #000000",
130"o c #66666A", 130 "o c #66666A",
131"p c #505054", 131 "p c #505054",
132"q c #838388", 132 "q c #838388",
133"r c #A1A1A7", 133 "r c #A1A1A7",
134"s c #A9A9AE", 134 "s c #A9A9AE",
135"t c #A8A8B0", 135 "t c #A8A8B0",
136"u c #5E5E63", 136 "u c #5E5E63",
137"v c #3A3A3E", 137 "v c #3A3A3E",
138"w c #BDBDC6", 138 "w c #BDBDC6",
139"x c #59595E", 139 "x c #59595E",
140"y c #76767C", 140 "y c #76767C",
141"z c #373738", 141 "z c #373738",
142"A c #717174", 142 "A c #717174",
143"B c #727278", 143 "B c #727278",
144"C c #1C1C1E", 144 "C c #1C1C1E",
145"D c #3C3C3F", 145 "D c #3C3C3F",
146"E c #ADADB6", 146 "E c #ADADB6",
147"F c #54555A", 147 "F c #54555A",
148"G c #8B8C94", 148 "G c #8B8C94",
149"H c #5A5A5F", 149 "H c #5A5A5F",
150"I c #BBBBC3", 150 "I c #BBBBC3",
151"J c #C4C4CB", 151 "J c #C4C4CB",
152"K c #909098", 152 "K c #909098",
153"L c #737379", 153 "L c #737379",
154"M c #343437", 154 "M c #343437",
155"N c #8F8F98", 155 "N c #8F8F98",
156"O c #000407", 156 "O c #000407",
157"P c #2D3137", 157 "P c #2D3137",
158"Q c #B0B1BC", 158 "Q c #B0B1BC",
159"R c #3B3C40", 159 "R c #3B3C40",
160"S c #6E6E74", 160 "S c #6E6E74",
161"T c #95959C", 161 "T c #95959C",
162"U c #74747A", 162 "U c #74747A",
163"V c #1D1D1E", 163 "V c #1D1D1E",
164"W c #91929A", 164 "W c #91929A",
165"X c #42444A", 165 "X c #42444A",
166"Y c #22282E", 166 "Y c #22282E",
167"Z c #B0B2BC", 167 "Z c #B0B2BC",
168"` c #898A90", 168 "` c #898A90",
169" . c #65656A", 169 " . c #65656A",
170".. c #999AA2", 170 ".. c #999AA2",
171"+. c #52535A", 171 "+. c #52535A",
172"@. c #151B21", 172 "@. c #151B21",
173"#. c #515257", 173 "#. c #515257",
174"$. c #B5B5BE", 174 "$. c #B5B5BE",
175"%. c #616167", 175 "%. c #616167",
176"&. c #1A1D22", 176 "&. c #1A1D22",
177"*. c #000713", 177 "*. c #000713",
178"=. c #1F1F21", 178 "=. c #1F1F21",
179" ", 179 " ",
180" . + @ # ", 180 " . + @ # ",
181" $ % & * = - ", 181 " $ % & * = - ",
182" ; > , ' ) ! ~ ", 182 " ; > , ' ) ! ~ ",
183" { ] ^ / ( _ : ", 183 " { ] ^ / ( _ : ",
184" < [ } | 1 2 3 ", 184 " < [ } | 1 2 3 ",
185" 4 5 6 7 8 9 0 a b c ", 185 " 4 5 6 7 8 9 0 a b c ",
186" d e f g h i j 3 k l m n ", 186 " d e f g h i j 3 k l m n ",
187" o p q r s t u v w n ", 187 " o p q r s t u v w n ",
188" o x y z A B C D E n ", 188 " o x y z A B C D E n ",
189" F G H I J K L M N O ", 189 " F G H I J K L M N O ",
190" P Q R S T U V W X ", 190 " P Q R S T U V W X ",
191" Y Z ` b ...+. ", 191 " Y Z ` b ...+. ",
192" @.#.$.%.&. ", 192 " @.#.$.%.&. ",
193" *.B =. ", 193 " *.B =. ",
194" n n n n n n n n n "}; 194 " n n n n n n n n n "};
195 195
@@ -197,38 +197,39 @@ static char * vmemo_xpm[] = {
197VMemo::VMemo( QWidget *parent, const char *_name ) 197VMemo::VMemo( QWidget *parent, const char *_name )
198 : QWidget( parent, _name ) 198 : QWidget( parent, _name )
199{ 199{
200 setFixedHeight( 18 ); 200 setFixedHeight( 18 );
201 setFixedWidth( 14 ); 201 setFixedWidth( 14 );
202 202
203 recording = FALSE; 203 recording = FALSE;
204 204
205 struct utsname name; /* check for embedix kernel running on the zaurus*/ 205 struct utsname name; /* check for embedix kernel running on the zaurus*/
206 if (uname(&name) != -1) { 206 if (uname(&name) != -1) {
207 QString release=name.release; 207 QString release=name.release;
208 Config vmCfg("Vmemo"); 208 Config vmCfg("Vmemo");
209 vmCfg.setGroup("Defaults"); 209 vmCfg.setGroup("Defaults");
210 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 210 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
211 211
212 qDebug("toggleKey %d", toggleKey); 212 qDebug("toggleKey %d", toggleKey);
213 213
214 if(release.find("embedix",0,TRUE) !=-1) 214 if(release.find("embedix",0,TRUE) !=-1)
215 systemZaurus=TRUE; 215 systemZaurus=TRUE;
216 else 216 else
217 systemZaurus=FALSE; 217 systemZaurus=FALSE;
218 218
219 myChannel = new QCopChannel( "QPE/VMemo", this ); 219 myChannel = new QCopChannel( "QPE/VMemo", this );
220 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 220 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
221 this, SLOT(receive(const QCString&, const QByteArray&)) ); 221 this, SLOT(receive(const QCString&, const QByteArray&)) );
222 222
223 if( toggleKey != -1 ) { 223 if( toggleKey != -1 ) {
224 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 224 // QPEApplication::grabKeyboard();
225// e << 4096; // Key_Escape 225 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
226// e << Key_F5; //4148 226 // e << 4096; // Key_Escape
227 e << toggleKey; 227 // e << Key_F5; //4148
228 e << QString("QPE/VMemo"); 228 e << toggleKey;
229 e << QString("toggleRecord()"); 229 e << QString("QPE/VMemo");
230 } 230 e << QString("toggleRecord()");
231 if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0)
232 hide();
233 } 231 }
232 // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0)
233 // hide();
234 }
234} 235}
@@ -241,12 +242,12 @@ void VMemo::receive( const QCString &msg, const QByteArray &data )
241{ 242{
242 QDataStream stream( data, IO_ReadOnly ); 243 QDataStream stream( data, IO_ReadOnly );
243 if (msg == "toggleRecord()") { 244 if (msg == "toggleRecord()") {
244 if (recording) { 245 if (recording) {
245 fromToggle = TRUE; 246 fromToggle = TRUE;
246 stopRecording(); 247 stopRecording();
247 } else { 248 } else {
248 fromToggle = TRUE; 249 fromToggle = TRUE;
249 startRecording(); 250 startRecording();
250 }
251 } 251 }
252 }
252} 253}
@@ -261,3 +262,3 @@ void VMemo::mousePressEvent( QMouseEvent * )
261{ 262{
262 startRecording(); 263 startRecording();
263} 264}
@@ -266,3 +267,3 @@ void VMemo::mouseReleaseEvent( QMouseEvent * )
266{ 267{
267 stopRecording(); 268 stopRecording();
268} 269}
@@ -271,30 +272,32 @@ bool VMemo::startRecording() {
271 272
272 if ( recording) 273 if ( recording)
273 return FALSE;; 274 return FALSE;;
274 275
275 Config config( "Vmemo" ); 276 Config config( "Vmemo" );
276 config.setGroup( "System" ); 277 config.setGroup( "System" );
277 278
278 useAlerts = config.readBoolEntry("Alert"); 279 useAlerts = config.readBoolEntry("Alert");
279 if(useAlerts) { 280 if(useAlerts) {
280 281
281 msgLabel = new QLabel( 0, "alertLabel" ); 282 msgLabel = new QLabel( 0, "alertLabel" );
282 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 283 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
283 msgLabel->show(); 284 msgLabel->show();
284 } 285 }
285 286
286// if(useAlerts) 287 // if(useAlerts)
287// QMessageBox::message("VMemo","Really Record?");//) ==1) 288 // QMessageBox::message("VMemo","Really Record?");//) ==1)
288// return; 289 // return;
289// } else { 290 // } else {
290 if (!systemZaurus ) 291 // if (!systemZaurus )
291 QSound::play(Resource::findSound("vmemob")); 292 // QSound::play(Resource::findSound("vmemob"));
292// } 293 // }
293 qDebug("Start recording"); 294 qDebug("Start recording engines");
294 recording = TRUE; 295 recording = TRUE;
295 if (openDSP() == -1) { 296
296 QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 297 if (openDSP() == -1) {
297 recording = FALSE; 298 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
298 return FALSE; 299 // delete msgLabel;
299 } 300 recording = FALSE;
301 return FALSE;
302 }
300 303
@@ -305,4 +308,4 @@ bool VMemo::startRecording() {
305 QString fName; 308 QString fName;
306 config.setGroup( "System" ); 309 config.setGroup( "System" );
307 fName = QPEApplication::documentDir() ; 310 fName = QPEApplication::documentDir() ;
308 fileName = config.readEntry("RecLocation", fName); 311 fileName = config.readEntry("RecLocation", fName);
@@ -312,8 +315,8 @@ bool VMemo::startRecording() {
312 if(s) 315 if(s)
313 fileName=fileName.right(fileName.length()-s-2); 316 fileName=fileName.right(fileName.length()-s-2);
314 qDebug("filename will be "+fileName); 317 qDebug("filename will be "+fileName);
315 if( fileName.left(1).find('/') == -1) 318 if( fileName.left(1).find('/') == -1)
316 fileName="/"+fileName; 319 fileName="/"+fileName;
317 if( fileName.right(1).find('/') == -1) 320 if( fileName.right(1).find('/') == -1)
318 fileName+="/"; 321 fileName+="/";
319 fName = "vm_"+ dt.toString()+ ".wav"; 322 fName = "vm_"+ dt.toString()+ ".wav";
@@ -321,3 +324,3 @@ bool VMemo::startRecording() {
321 fileName+=fName; 324 fileName+=fName;
322 qDebug("filename is "+fileName); 325 qDebug("filename is "+fileName);
323 // No spaces in the filename 326 // No spaces in the filename
@@ -329,5 +332,5 @@ bool VMemo::startRecording() {
329 if(openWAV(fileName.latin1()) == -1) { 332 if(openWAV(fileName.latin1()) == -1) {
330 QString err("Could not open the output file\n"); 333 // QString err("Could not open the output file\n");
331 err += fileName; 334 // err += fileName;
332 QMessageBox::critical(0, "vmemo", err, "Abort"); 335 // QMessageBox::critical(0, "vmemo", err, "Abort");
333 close(dsp); 336 close(dsp);
@@ -350,2 +353,3 @@ bool VMemo::startRecording() {
350 record(); 353 record();
354 // delete msgLabel;
351 return TRUE; 355 return TRUE;
@@ -356,3 +360,3 @@ void VMemo::stopRecording() {
356 if(useAlerts) 360 if(useAlerts)
357 if( msgLabel) delete msgLabel; 361 if( msgLabel) delete msgLabel;
358} 362}
@@ -361,48 +365,49 @@ int VMemo::openDSP()
361{ 365{
362 Config cfg("Vmemo"); 366 Config cfg("Vmemo");
363 cfg.setGroup("Record"); 367 cfg.setGroup("Record");
364 368
365 speed = cfg.readNumEntry("SampleRate", 22050); 369 speed = cfg.readNumEntry("SampleRate", 22050);
366 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 370 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
367 if (cfg.readNumEntry("SixteenBit", 1)==1) { 371 if (cfg.readNumEntry("SixteenBit", 1)==1) {
368 format = AFMT_S16_LE; 372 format = AFMT_S16_LE;
369 resolution = 16; 373 resolution = 16;
370 } else { 374 } else {
371 format = AFMT_U8; 375 format = AFMT_U8;
372 resolution = 8; 376 resolution = 8;
373 } 377 }
374 378
375 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 379 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
376 380
377 if(systemZaurus) { 381 if(systemZaurus) {
378 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 382 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1
379 channels=1; //zaurus has one input channel 383 channels=1; //zaurus has one input channel
380 } else { 384 } else {
381 dsp = open("/dev/dsp", O_RDWR); 385 dsp = open("/dev/dsp", O_RDWR);
382 } 386 }
383 387
384 if(dsp == -1) { 388 if(dsp == -1) {
385 perror("open(\"/dev/dsp\")"); 389 perror("open(\"/dev/dsp\")");
386 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 390 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
387 return -1; 391 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
388 } 392 return -1;
393 }
389 394
390 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 395 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
391 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 396 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
392 return -1; 397 return -1;
393 } 398 }
394 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 399 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
395 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 400 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
396 return -1; 401 return -1;
397 } 402 }
398 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 403 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
399 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 404 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
400 return -1; 405 return -1;
401 } 406 }
402 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 407 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
403 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 408 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
404 return -1; 409 return -1;
405 } 410 }
406 411
407 return 1; 412 return 1;
408} 413}
@@ -413,3 +418,3 @@ int VMemo::openWAV(const char *filename)
413 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { 418 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
414 errorMsg=filename; 419 errorMsg=filename;
415 return -1; 420 return -1;
@@ -443,95 +448,135 @@ void VMemo::record(void)
443{ 448{
444 int length=0, result, value; 449 int length=0, result, value;
445 QString msg; 450 QString msg;
446 msg.sprintf("Recording format %d", format); 451 msg.sprintf("Recording format %d", format);
447 qDebug(msg); 452 qDebug(msg);
448 453
449 if(systemZaurus) { 454 if(systemZaurus) {
450 signed short sound[512], monoBuffer[512]; 455
451 if(format==AFMT_S16_LE) { 456 msg.sprintf("Recording format zaurus");
452 457 qDebug(msg);
453 while(recording) { 458 signed short sound[512], monoBuffer[512];
454 459
455 result = read(dsp, sound, 512); // 8192 460 if(format==AFMT_S16_LE) {
456 int j=0; 461
457 462 while(recording) {
458 if(systemZaurus) { 463
459 for (int i = 0; i < result; i++) { //since Z is mono do normally 464 result = read(dsp, sound, 512); // 8192
460 monoBuffer[i] = sound[i]; 465 int j=0;
461 } 466
462 467 if(systemZaurus) {
463 length+=write(wav, monoBuffer, result); 468 for (int i = 0; i < result; i++) { //since Z is mono do normally
464 469 monoBuffer[i] = sound[i];
465 } else { //ipaq /stereo inputs 470 }
466 471
467 for (int i = 0; i < result; i+=2) { 472 length+=write(wav, monoBuffer, result);
468 monoBuffer[j] = (sound[i]+sound[i+1])/2; 473 if(length<0)
469 j++; 474 recording=false;
470 } 475
471 476 } else { //ipaq /stereo inputs
472 length+=write(wav, monoBuffer, result/2); 477
473 } 478
474 qApp->processEvents(); 479 for (int i = 0; i < result; i+=2) {
475// printf("%d\r",length); 480/ monoBuffer[j] = sound[i];
476// fflush(stdout); 481 // monoBuffer[j] = (sound[i]+sound[i+1])/2;
477 } 482
478 } else { //AFMT_U8 483 j++;
479// 8bit unsigned 484 }
480 unsigned short sound[512], monoBuffer[512]; 485
481 while(recording) { 486 length+=write(wav, monoBuffer, result);
482 result = read(dsp, sound, 512); // 8192 487 if(length<0)
483 int j=0; 488 recording=false;
484 if(systemZaurus) { 489 // length+=write(wav, monoBuffer, result/2);
485 for (int i = 0; i < result; i++) { //since Z is mono do normally
486 monoBuffer[i] = sound[i];
487 }
488 length+=write(wav, monoBuffer, result);
489 } else { //ipaq /stereo inputs
490 for (int i = 0; i < result; i+=2) {
491 monoBuffer[j] = (sound[i]+sound[i+1])/2;
492 j++;
493 }
494 length+=write(wav, monoBuffer, result/2);
495 }
496 length += result;
497// printf("%d\r",length);
498// fflush(stdout);
499 }
500
501 qApp->processEvents();
502 } 490 }
491 qApp->processEvents();
492// printf("%d\r",length);
493// fflush(stdout);
494 }
495
496} else { //AFMT_U8
497 // 8bit unsigned
498 unsigned short sound[512], monoBuffer[512];
499 while(recording) {
500 result = read(dsp, sound, 512); // 8192
501 int j=0;
502
503 if(systemZaurus) {
504
505 for (int i = 0; i < result; i++) { //since Z is mono do normally
506 monoBuffer[i] = sound[i];
507 }
508
509 length+=write(wav, monoBuffer, result);
503 510
504 } else { // this is specific for ipaqs that do not have 8 bit capabilities 511 } else { //ipaq /stereo inputs
505 512
506 signed short sound[512], monoBuffer[512]; 513 for (int i = 0; i < result; i+=2) {
514 monoBuffer[j] = (sound[i]+sound[i+1])/2;
515 j++;
516 }
507 517
508 while(recording) { 518 length+=write(wav, monoBuffer, result/2);
509 result = read(dsp, sound, 512); // 8192 519
510 write(wav, sound, result); 520 if(length<0)
511 length += result; 521 recording=false;
512 522
513 qApp->processEvents();
514 } 523 }
515// printf("%d\r",length); 524 length += result;
516// fflush(stdout); 525// printf("%d\r",length);
517 // qDebug("file has length of %d lasting %d seconds", 526// fflush(stdout);
518 // length, (( length / speed) / channels) / 2 ); 527 }
519 // medialplayer states wrong length in secs 528
529 qApp->processEvents();
520 } 530 }
521 531
522 value = length+36; 532 } else { // this is specific for ipaqs that do not have 8 bit capabilities
523 lseek(wav, 4, SEEK_SET); 533
524 write(wav, &value, 4); 534 msg.sprintf("Recording format other");
525 lseek(wav, 40, SEEK_SET); 535 qDebug(msg);
526 write(wav, &length, 4); 536
527 track.close(); 537 signed short sound[512], monoBuffer[512];
538
539 while(recording) {
540
541 result = read(dsp, sound, 512); // 8192
542
543 write(wav, sound, result);
544 length += result;
545 if(length<0) {
546
547 recording=false;
548 perror("dev/dsp's is a lookin' messy");
549 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
550 }
551// printf("%d\r",length);
552// fflush(stdout);
553 qApp->processEvents();
554 }
555 // qDebug("file has length of %d lasting %d seconds",
556 // length, (( length / speed) / channels) / 2 );
557 // medialplayer states wrong length in secs
558 }
559
560 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
561
562 value = length+36;
563
564 lseek(wav, 4, SEEK_SET);
565 write(wav, &value, 4);
566 lseek(wav, 40, SEEK_SET);
567
568 write(wav, &length, 4);
569
570 track.close();
571 qDebug("Tracvk closed");
528 572
529 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 573 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
530 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 574 perror("ioctl(\"SNDCTL_DSP_RESET\")");
531 ::close(dsp); 575
532 fileName = fileName.left(fileName.length()-4); 576 ::close(dsp);
533// if(useAlerts) 577 fileName = fileName.left(fileName.length()-4);
534// QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 578 // if(useAlerts)
535 qDebug("done recording "+fileName); 579 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
536 QSound::play(Resource::findSound("vmemoe")); 580 qDebug("done recording "+fileName);
581 QSound::play(Resource::findSound("vmemoe"));
537} 582}
@@ -540,33 +585,33 @@ int VMemo::setToggleButton(int tog) {
540 585
541 for( int i=0; i < 10;i++) { 586 for( int i=0; i < 10;i++) {
542 switch (tog) { 587 switch (tog) {
543 case 0: 588 case 0:
544 return -1; 589 return -1;
545 break; 590 break;
546 case 1: 591 case 1:
547 return 0; 592 return 0;
548 break; 593 break;
549 case 2: 594 case 2:
550 return Key_Escape; 595 return Key_Escape;
551 break; 596 break;
552 case 3: 597 case 3:
553 return Key_Space; 598 return Key_Space;
554 break; 599 break;
555 case 4: 600 case 4:
556 return Key_F12; 601 return Key_F12;
557 break; 602 break;
558 case 5: 603 case 5:
559 return Key_F9; 604 return Key_F9;
560 break; 605 break;
561 case 6: 606 case 6:
562 return Key_F10; 607 return Key_F10;
563 break; 608 break;
564 case 7: 609 case 7:
565 return Key_F11; 610 return Key_F11;
566 break; 611 break;
567 case 8: 612 case 8:
568 return Key_F13; 613 return Key_F13;
569 break; 614 break;
570 }; 615 };
571 } 616 }
572} 617}
diff --git a/core/applets/vmemo/vmemo.pro b/core/applets/vmemo/vmemo.pro
index 298d989..734cf5c 100644
--- a/core/applets/vmemo/vmemo.pro
+++ b/core/applets/vmemo/vmemo.pro
@@ -7,3 +7,3 @@ DESTDIR =$(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
diff --git a/core/applets/vmemo/vmemoimpl.cpp b/core/applets/vmemo/vmemoimpl.cpp
index 9e6c7cd..ef4a3a6 100644
--- a/core/applets/vmemo/vmemoimpl.cpp
+++ b/core/applets/vmemo/vmemoimpl.cpp
@@ -1,12 +1,12 @@
1/**************************************************************************************94x78** 1/**************************************************************************************94x78**
2** 2 **
3** This file may be distributed and/or modified under the terms of the 3 ** This file may be distributed and/or modified under the terms of the
4** GNU General Public License version 2 as published by the Free Software 4 ** GNU General Public License version 2 as published by the Free Software
5** Foundation and appearing in the file LICENSE.GPL included in the 5 ** Foundation and appearing in the file LICENSE.GPL included in the
6** packaging of this file. 6 ** packaging of this file.
7** 7 **
8** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 8 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 9 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10** 10 **
11*********************************************************************************************/ 11 *********************************************************************************************/
12 12
@@ -21,3 +21,3 @@
21VMemoAppletImpl::VMemoAppletImpl() 21VMemoAppletImpl::VMemoAppletImpl()
22 : vmemo(0), ref(0) 22 : vmemo(0), ref(0)
23{ 23{
@@ -33,3 +33,3 @@ QWidget *VMemoAppletImpl::applet( QWidget *parent )
33 if ( !vmemo ) 33 if ( !vmemo )
34 vmemo = new VMemo( parent ); 34 vmemo = new VMemo( parent );
35 return vmemo; 35 return vmemo;
@@ -44,11 +44,11 @@ QRESULT VMemoAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **
44{ 44{
45 *iface = 0; 45 *iface = 0;
46 if ( uuid == IID_QUnknown ) 46 if ( uuid == IID_QUnknown )
47 *iface = this; 47 *iface = this;
48 else if ( uuid == IID_TaskbarApplet ) 48 else if ( uuid == IID_TaskbarApplet )
49 *iface = this; 49 *iface = this;
50 50
51 if ( *iface ) 51 if ( *iface )
52 (*iface)->addRef(); 52 (*iface)->addRef();
53 return QS_OK; 53 return QS_OK;
54} 54}
@@ -58,2 +58,2 @@ Q_EXPORT_INTERFACE()
58 Q_CREATE_INSTANCE( VMemoAppletImpl ) 58 Q_CREATE_INSTANCE( VMemoAppletImpl )
59} 59 }