summaryrefslogtreecommitdiff
path: root/core/applets
authorllornkcor <llornkcor>2002-03-27 04:29:54 (UTC)
committer llornkcor <llornkcor>2002-03-27 04:29:54 (UTC)
commit524ad1da733675debd5c248b54efc5d58e855485 (patch) (unidiff)
tree6adf94b989e4675b4ccdaa10e8538766106eea50 /core/applets
parent78211642003f70797a5faa1767a5ab2f5f83606f (diff)
downloadopie-524ad1da733675debd5c248b54efc5d58e855485.zip
opie-524ad1da733675debd5c248b54efc5d58e855485.tar.gz
opie-524ad1da733675debd5c248b54efc5d58e855485.tar.bz2
changed icon
Diffstat (limited to 'core/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp452
-rw-r--r--core/applets/vmemo/vmemo.h3
2 files changed, 260 insertions, 195 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index ae5cf0c..e6c4ff9 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -70,68 +70,126 @@ int seq = 0;
70 70
71/* XPM */ 71/* XPM */
72static char * vmemo_xpm[] = { 72static char * vmemo_xpm[] = {
73"14 14 47 1", 73"16 16 102 2",
74" c None", 74" c None",
75". c #101010", 75". c #60636A",
76"+ c #0D0D0D", 76"+ c #6E6E72",
77"@ c #0B0B0B", 77"@ c #68696E",
78"# c #393939", 78"# c #4D525C",
79"$ c #6C6C6C", 79"$ c #6B6C70",
80"% c #5D5D5D", 80"% c #E3E3E8",
81"& c #4E4E4E", 81"& c #EEEEF2",
82"* c #1C1C1C", 82"* c #EAEAEF",
83"= c #131313", 83"= c #CACAD0",
84"- c #7B7B7B", 84"- c #474A51",
85"; c #303030", 85"; c #171819",
86"> c #383838", 86"> c #9B9B9F",
87", c #3F3F3F", 87", c #EBEBF0",
88"' c #343434", 88"' c #F4F4F7",
89") c #060606", 89") c #F1F1F5",
90"! c #444444", 90"! c #DEDEE4",
91"~ c #646464", 91"~ c #57575C",
92"{ c #505050", 92"{ c #010101",
93"] c #717171", 93"] c #A2A2A6",
94"^ c #1B1B1B", 94"^ c #747477",
95"/ c #585858", 95"/ c #B5B5B8",
96"( c #4C4C4C", 96"( c #AEAEB2",
97"_ c #353535", 97"_ c #69696D",
98": c #0E0E0E", 98": c #525256",
99"< c #080808", 99"< c #181C24",
100"[ c #262626", 100"[ c #97979B",
101"} c #121212", 101"} c #A7A7AC",
102"| c #7F7F7F", 102"| c #B0B0B4",
103"1 c #464646", 103"1 c #C8C8D1",
104"2 c #0C0C0C", 104"2 c #75757B",
105"3 c #727272", 105"3 c #46464A",
106"4 c #292929", 106"4 c #494A4F",
107"5 c #656565", 107"5 c #323234",
108"6 c #565656", 108"6 c #909095",
109"7 c #434343", 109"7 c #39393B",
110"8 c #272727", 110"8 c #757578",
111"9 c #0F0F0F", 111"9 c #87878E",
112"0 c #3A3A3A", 112"0 c #222224",
113"a c #090909", 113"a c #414144",
114"b c #535353", 114"b c #6A6A6E",
115"c c #545454", 115"c c #020C16",
116"d c #494949", 116"d c #6B6B6F",
117"e c #7A7A7A", 117"e c #68686D",
118"f c #202020", 118"f c #5B5B60",
119"g c #3D3D3D", 119"g c #8A8A8F",
120"h c #1F1F1F", 120"h c #6B6B6E",
121" .+@ ", 121"i c #ADADB2",
122" #$%&* ", 122"j c #828289",
123" =-;>,')", 123"k c #3E3E41",
124" .$;!~,)", 124"l c #CFCFD7",
125" ;#{]!)", 125"m c #4C4C50",
126" ^~/(_)", 126"n c #000000",
127" ./:@<[)", 127"o c #66666A",
128" }. .|]1;;2 ", 128"p c #505054",
129" #-$;^/3&;;4@ ", 129"q c #838388",
130".$;;#5:67;89 ", 130"r c #A1A1A7",
131":%;0%&ab;8. ", 131"s c #A9A9AE",
132"@cd%e!fg49 ", 132"t c #A8A8B0",
133" h0,!_;2@ ", 133"u c #5E5E63",
134" ))))) "}; 134"v c #3A3A3E",
135"w c #BDBDC6",
136"x c #59595E",
137"y c #76767C",
138"z c #373738",
139"A c #717174",
140"B c #727278",
141"C c #1C1C1E",
142"D c #3C3C3F",
143"E c #ADADB6",
144"F c #54555A",
145"G c #8B8C94",
146"H c #5A5A5F",
147"I c #BBBBC3",
148"J c #C4C4CB",
149"K c #909098",
150"L c #737379",
151"M c #343437",
152"N c #8F8F98",
153"O c #000407",
154"P c #2D3137",
155"Q c #B0B1BC",
156"R c #3B3C40",
157"S c #6E6E74",
158"T c #95959C",
159"U c #74747A",
160"V c #1D1D1E",
161"W c #91929A",
162"X c #42444A",
163"Y c #22282E",
164"Z c #B0B2BC",
165"` c #898A90",
166" . c #65656A",
167".. c #999AA2",
168"+. c #52535A",
169"@. c #151B21",
170"#. c #515257",
171"$. c #B5B5BE",
172"%. c #616167",
173"&. c #1A1D22",
174"*. c #000713",
175"=. c #1F1F21",
176" ",
177" . + @ # ",
178" $ % & * = - ",
179" ; > , ' ) ! ~ ",
180" { ] ^ / ( _ : ",
181" < [ } | 1 2 3 ",
182" 4 5 6 7 8 9 0 a b c ",
183" d e f g h i j 3 k l m n ",
184" o p q r s t u v w n ",
185" o x y z A B C D E n ",
186" F G H I J K L M N O ",
187" P Q R S T U V W X ",
188" Y Z ` b ...+. ",
189" @.#.$.%.&. ",
190" *.B =. ",
191" n n n n n n n n n "};
192
135 193
136VMemo::VMemo( QWidget *parent, const char *_name ) 194VMemo::VMemo( QWidget *parent, const char *_name )
137 : QWidget( parent, _name ) 195 : QWidget( parent, _name )
@@ -168,8 +226,7 @@ VMemo::~VMemo()
168void VMemo::receive( const QCString &msg, const QByteArray &data ) 226void VMemo::receive( const QCString &msg, const QByteArray &data )
169{ 227{
170 QDataStream stream( data, IO_ReadOnly ); 228 QDataStream stream( data, IO_ReadOnly );
171 if (msg == "toggleRecord()") 229 if (msg == "toggleRecord()") {
172 {
173 if (recording) 230 if (recording)
174 mouseReleaseEvent(NULL); 231 mouseReleaseEvent(NULL);
175 else 232 else
@@ -186,28 +243,35 @@ void VMemo::paintEvent( QPaintEvent* )
186void VMemo::mousePressEvent( QMouseEvent *me ) 243void VMemo::mousePressEvent( QMouseEvent *me )
187{ 244{
188 // just to be safe 245 // just to be safe
189 if (recording) 246 if (recording) {
190 { 247 recording = FALSE;
191 recording = FALSE; 248 return;
192 return; 249 }
193 }
194 250
195 /* 251 /*
196 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions 252 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
197 mousePressEvent and mouseReleaseEvent with a NULL parameter. 253 mousePressEvent and mouseReleaseEvent with a NULL parameter.
198 */ 254 */
199// if (!systemZaurus && me != NULL) 255// if (!systemZaurus && me != NULL)
200// return; 256// return;
201 257
202 QSound::play(Resource::findSound("vmemob")); 258// Config config( "Sound" );
203 qDebug("Start recording"); 259// config.setGroup( "System" );
204 recording = TRUE; 260// useAlerts = config.readBoolEntry("Alert");
205 if (openDSP() == -1) 261
206 { 262// if(useAlerts) {
207 QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort"); 263// if( QMessageBox::warning(this,"VMemo","Really Record?","Yes","No",0,0,1) ==1)
208 recording = FALSE; 264// return;
209 return; 265// } else {
210 } 266 QSound::play(Resource::findSound("vmemob"));
267// }
268 qDebug("Start recording");
269 recording = TRUE;
270 if (openDSP() == -1) {
271 QMessageBox::critical(0, "VMemo", "Could not open dsp device.", "Abort");
272 recording = FALSE;
273 return;
274 }
211 275
212 Config vmCfg("VMemo"); 276 Config vmCfg("VMemo");
213 vmCfg.setGroup("Defaults"); 277 vmCfg.setGroup("Defaults");
@@ -230,8 +294,7 @@ void VMemo::mousePressEvent( QMouseEvent *me )
230 fileName.replace(QRegExp(":"),"."); 294 fileName.replace(QRegExp(":"),".");
231 fileName.replace(QRegExp(","),""); 295 fileName.replace(QRegExp(","),"");
232 296
233 if(openWAV(fileName.latin1()) == -1) 297 if(openWAV(fileName.latin1()) == -1) {
234 {
235 QString err("Could not open the output file: "); 298 QString err("Could not open the output file: ");
236 err += fileName; 299 err += fileName;
237 300
@@ -262,50 +325,50 @@ void VMemo::mouseReleaseEvent( QMouseEvent * )
262 325
263int VMemo::openDSP() 326int VMemo::openDSP()
264{ 327{
265 Config cfg("Sound"); 328 Config cfg("Sound");
266 cfg.setGroup("Record"); 329 cfg.setGroup("Record");
267 330
268 speed = cfg.readNumEntry("SampleRate", 22050); 331 speed = cfg.readNumEntry("SampleRate", 22050);
269 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 332 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
270 if (cfg.readNumEntry("SixteenBit", 1)==1) { 333 if (cfg.readNumEntry("SixteenBit", 1)==1) {
271 format = AFMT_S16_LE; 334 format = AFMT_S16_LE;
272 resolution = 16; 335 resolution = 16;
273 } 336 } else {
274 else { 337 format = AFMT_S8;
275 format = AFMT_S8; 338 resolution = 8;
276 resolution = 8;
277 } 339 }
340
278 341
279 if(systemZaurus) { 342 if(systemZaurus) {
280 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 343 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1
281 channels=1; //zaurus has one input channel 344 channels=1; //zaurus has one input channel
282 } else { 345 } else {
283 dsp = open("/dev/dsp", O_RDWR); 346 dsp = open("/dev/dsp", O_RDWR);
284 } 347 }
285 348
286 if(dsp == -1) { 349 if(dsp == -1) {
287 perror("open(\"/dev/dsp\")"); 350 perror("open(\"/dev/dsp\")");
288 return -1; 351 return -1;
289 } 352 }
290 353
291 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 354 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
292 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 355 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
293 return -1; 356 return -1;
294 } 357 }
295 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 358 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
296 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 359 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
297 return -1; 360 return -1;
298 } 361 }
299 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 362 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
300 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 363 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
301 return -1; 364 return -1;
302 } 365 }
303 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 366 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
304 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 367 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
305 return -1; 368 return -1;
306 } 369 }
307 370
308 return 1; 371 return 1;
309} 372}
310 373
311int VMemo::openWAV(const char *filename) 374int VMemo::openWAV(const char *filename)
@@ -344,77 +407,78 @@ void VMemo::record(void)
344 qDebug("Recording"); 407 qDebug("Recording");
345 408
346 if(systemZaurus) { 409 if(systemZaurus) {
347 signed short sound[512], monoBuffer[512]; 410 signed short sound[512], monoBuffer[512];
348 411 if(format==AFMT_S16_LE) {
349 if(format==AFMT_S16_LE) { 412 while(recording) {
350 while(recording) { 413 result = read(dsp, sound, 512); // 8192
351 result = read(dsp, sound, 512); // 8192 414 qApp->processEvents();
352 qApp->processEvents(); 415 int j=0;
353 int j=0; 416 if(systemZaurus) {
354 if(systemZaurus) { 417 for (int i = 0; i < result; i++) { //since Z is mono do normally
355 for (int i = 0; i < result; i++) { //since Z is mono do normally 418 monoBuffer[i] = sound[i];
356 monoBuffer[i] = sound[i]; 419 }
357 } 420 qApp->processEvents();
358 qApp->processEvents(); 421 length+=write(wav, monoBuffer, result);
359 length+=write(wav, monoBuffer, result); 422 } else { //ipaq /stereo inputs
360 } else { //ipaq /stereo inputs 423 for (int i = 0; i < result; i+=2) {
361 for (int i = 0; i < result; i+=2) { 424 monoBuffer[j] = (sound[i]+sound[i+1])/2;
362 monoBuffer[j] = (sound[i]+sound[i+1])/2; 425 j++;
363 j++; 426 }
364 } 427 qApp->processEvents();
365 qApp->processEvents(); 428 length+=write(wav, monoBuffer, result/2);
366 length+=write(wav, monoBuffer, result/2); 429 }
367 } 430 printf("%d\r",length);
368 printf("%d\r",length); 431 fflush(stdout);
369 fflush(stdout); 432 }
370 } 433 } else { //AFMT_S8
371 } 434// 8bit unsigned
372 else { //AFMT_S8 // don't try this yet.. as player doesn't understand 8bit unsigned 435 unsigned short sound[512], monoBuffer[512];
373 while(recording) 436 while(recording) {
374 { 437 result = read(dsp, sound, 512); // 8192
375 result = read(dsp, sound, 512); // 8192 438 qApp->processEvents();
376 qApp->processEvents(); 439 int j=0;
377 int j=0; 440 if(systemZaurus) {
378 if(systemZaurus) 441 for (int i = 0; i < result; i++) { //since Z is mono do normally
379 { 442 monoBuffer[i] = sound[i];
380 for (int i = 0; i < result; i++) { //since Z is mono do normally 443 }
381 monoBuffer[i] = sound[i]; 444 qApp->processEvents();
382 } 445 length+=write(wav, monoBuffer, result);
383 qApp->processEvents(); 446 } else { //ipaq /stereo inputs
384 length+=write(wav, monoBuffer, result); 447 for (int i = 0; i < result; i+=2) {
385 } else { //ipaq /stereo inputs 448 monoBuffer[j] = (sound[i]+sound[i+1])/2;
386 for (int i = 0; i < result; i+=2) { 449 j++;
387 monoBuffer[j] = (sound[i]+sound[i+1])/2; 450 }
388 j++; 451 qApp->processEvents();
389 } 452 length+=write(wav, monoBuffer, result/2);
390 qApp->processEvents(); 453 }
391 length+=write(wav, monoBuffer, result/2); 454 length += result;
392 } 455 printf("%d\r",length);
393 length += result; 456 fflush(stdout);
394 printf("%d\r",length); 457
395 fflush(stdout); 458 qApp->processEvents();
396 459 }
397 qApp->processEvents(); 460
398 } 461 qApp->processEvents();
399 } 462 }
400 463
401 } else { 464 } else {
402 465
403 char sound[512]; //char is 8 bit 466 signed short sound[512], monoBuffer[512];
404 467
405 while(recording) 468 while(recording) {
406 { 469 result = read(dsp, sound, 512); // 8192
407 result = read(dsp, sound, 512); // 8192 470 qApp->processEvents();
408 qApp->processEvents();
409 471
410 write(wav, sound, result); 472 write(wav, sound, result);
411 length += result; 473 length += result;
412 474
413 qApp->processEvents(); 475 qApp->processEvents();
414 } 476 }
415 // qDebug("file has length of %d lasting %d seconds", 477 printf("%d\r",length);
416 // length, (( length / speed) / channels) / 2 ); 478 fflush(stdout);
417 // medialplayer states wrong length in secs 479 // qDebug("file has length of %d lasting %d seconds",
480 // length, (( length / speed) / channels) / 2 );
481 // medialplayer states wrong length in secs
418 } 482 }
419 483
420 value = length+36; 484 value = length+36;
@@ -425,10 +489,10 @@ void VMemo::record(void)
425 track.close(); 489 track.close();
426 490
427 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 491 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
428 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 492 perror("ioctl(\"SNDCTL_DSP_RESET\")");
429 ::close(dsp); 493 ::close(dsp);
430 if(systemZaurus) 494// if(useAlerts)
431 QMessageBox::message("Vmemo"," Done recording"); 495// QMessageBox::message("Vmemo"," Done recording");
432 496// else
433 QSound::play(Resource::findSound("vmemoe")); 497 QSound::play(Resource::findSound("vmemoe"));
434} 498}
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index d96cd94..f30476f 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -38,7 +38,8 @@ public slots:
38 void receive( const QCString &msg, const QByteArray &data ); 38 void receive( const QCString &msg, const QByteArray &data );
39 39
40private: 40private:
41 void paintEvent( QPaintEvent* ); 41 bool useAlerts;
42 void paintEvent( QPaintEvent* );
42 43
43 int openDSP(); 44 int openDSP();
44 int openWAV(const char *filename); 45 int openWAV(const char *filename);