summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 4c55dc7..22cb276 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -129,392 +129,396 @@ static char * vmemo_xpm[] = {
129"o c #66666A", 129"o c #66666A",
130"p c #505054", 130"p c #505054",
131"q c #838388", 131"q c #838388",
132"r c #A1A1A7", 132"r c #A1A1A7",
133"s c #A9A9AE", 133"s c #A9A9AE",
134"t c #A8A8B0", 134"t c #A8A8B0",
135"u c #5E5E63", 135"u c #5E5E63",
136"v c #3A3A3E", 136"v c #3A3A3E",
137"w c #BDBDC6", 137"w c #BDBDC6",
138"x c #59595E", 138"x c #59595E",
139"y c #76767C", 139"y c #76767C",
140"z c #373738", 140"z c #373738",
141"A c #717174", 141"A c #717174",
142"B c #727278", 142"B c #727278",
143"C c #1C1C1E", 143"C c #1C1C1E",
144"D c #3C3C3F", 144"D c #3C3C3F",
145"E c #ADADB6", 145"E c #ADADB6",
146"F c #54555A", 146"F c #54555A",
147"G c #8B8C94", 147"G c #8B8C94",
148"H c #5A5A5F", 148"H c #5A5A5F",
149"I c #BBBBC3", 149"I c #BBBBC3",
150"J c #C4C4CB", 150"J c #C4C4CB",
151"K c #909098", 151"K c #909098",
152"L c #737379", 152"L c #737379",
153"M c #343437", 153"M c #343437",
154"N c #8F8F98", 154"N c #8F8F98",
155"O c #000407", 155"O c #000407",
156"P c #2D3137", 156"P c #2D3137",
157"Q c #B0B1BC", 157"Q c #B0B1BC",
158"R c #3B3C40", 158"R c #3B3C40",
159"S c #6E6E74", 159"S c #6E6E74",
160"T c #95959C", 160"T c #95959C",
161"U c #74747A", 161"U c #74747A",
162"V c #1D1D1E", 162"V c #1D1D1E",
163"W c #91929A", 163"W c #91929A",
164"X c #42444A", 164"X c #42444A",
165"Y c #22282E", 165"Y c #22282E",
166"Z c #B0B2BC", 166"Z c #B0B2BC",
167"` c #898A90", 167"` c #898A90",
168" . c #65656A", 168" . c #65656A",
169".. c #999AA2", 169".. c #999AA2",
170"+. c #52535A", 170"+. c #52535A",
171"@. c #151B21", 171"@. c #151B21",
172"#. c #515257", 172"#. c #515257",
173"$. c #B5B5BE", 173"$. c #B5B5BE",
174"%. c #616167", 174"%. c #616167",
175"&. c #1A1D22", 175"&. c #1A1D22",
176"*. c #000713", 176"*. c #000713",
177"=. c #1F1F21", 177"=. c #1F1F21",
178" ", 178" ",
179" . + @ # ", 179" . + @ # ",
180" $ % & * = - ", 180" $ % & * = - ",
181" ; > , ' ) ! ~ ", 181" ; > , ' ) ! ~ ",
182" { ] ^ / ( _ : ", 182" { ] ^ / ( _ : ",
183" < [ } | 1 2 3 ", 183" < [ } | 1 2 3 ",
184" 4 5 6 7 8 9 0 a b c ", 184" 4 5 6 7 8 9 0 a b c ",
185" d e f g h i j 3 k l m n ", 185" d e f g h i j 3 k l m n ",
186" o p q r s t u v w n ", 186" o p q r s t u v w n ",
187" o x y z A B C D E n ", 187" o x y z A B C D E n ",
188" F G H I J K L M N O ", 188" F G H I J K L M N O ",
189" P Q R S T U V W X ", 189" P Q R S T U V W X ",
190" Y Z ` b ...+. ", 190" Y Z ` b ...+. ",
191" @.#.$.%.&. ", 191" @.#.$.%.&. ",
192" *.B =. ", 192" *.B =. ",
193" n n n n n n n n n "}; 193" n n n n n n n n n "};
194 194
195 195
196VMemo::VMemo( QWidget *parent, const char *_name ) 196VMemo::VMemo( QWidget *parent, const char *_name )
197 : QWidget( parent, _name ) 197 : QWidget( parent, _name )
198{ 198{
199 setFixedHeight( 18 ); 199 setFixedHeight( 18 );
200 setFixedWidth( 14 ); 200 setFixedWidth( 14 );
201 201
202 recording = FALSE; 202 recording = FALSE;
203 203
204 struct utsname name; /* check for embedix kernel running on the zaurus*/ 204 struct utsname name; /* check for embedix kernel running on the zaurus*/
205 if (uname(&name) != -1) { 205 if (uname(&name) != -1) {
206 QString release=name.release; 206 QString release=name.release;
207 if(release.find("embedix",0,TRUE) !=-1) 207 if(release.find("embedix",0,TRUE) !=-1)
208 systemZaurus=TRUE; 208 systemZaurus=TRUE;
209 else { 209 else {
210 systemZaurus=FALSE; 210 systemZaurus=FALSE;
211 myChannel = new QCopChannel( "QPE/VMemo", this ); 211 myChannel = new QCopChannel( "QPE/VMemo", this );
212 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 212 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
213 this, SLOT(receive(const QCString&, const QByteArray&)) ); 213 this, SLOT(receive(const QCString&, const QByteArray&)) );
214 214
215// // Register the REC key press, for ipaq only 215// // Register the REC key press, for ipaq only
216 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 216 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
217 e << 4096; 217 e << 4096;
218 e << QString("QPE/VMemo"); 218 e << QString("QPE/VMemo");
219 e << QString("toggleRecord()"); 219 e << QString("toggleRecord()");
220 } 220 }
221 } 221 }
222} 222}
223 223
224VMemo::~VMemo() 224VMemo::~VMemo()
225{ 225{
226} 226}
227 227
228void VMemo::receive( const QCString &msg, const QByteArray &data ) 228void VMemo::receive( const QCString &msg, const QByteArray &data )
229{ 229{
230 QDataStream stream( data, IO_ReadOnly ); 230 QDataStream stream( data, IO_ReadOnly );
231 if (msg == "toggleRecord()") { 231 if (msg == "toggleRecord()") {
232 if (recording) 232 if (recording)
233 mouseReleaseEvent(NULL); 233 mouseReleaseEvent(NULL);
234 else 234 else
235 mousePressEvent(NULL); 235 mousePressEvent(NULL);
236 } 236 }
237} 237}
238 238
239void VMemo::paintEvent( QPaintEvent* ) 239void VMemo::paintEvent( QPaintEvent* )
240{ 240{
241 QPainter p(this); 241 QPainter p(this);
242 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 242 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
243} 243}
244 244
245void VMemo::mousePressEvent( QMouseEvent *me ) 245void VMemo::mousePressEvent( QMouseEvent *me )
246{ 246{
247 // just to be safe 247 // just to be safe
248 if (recording) { 248 if (recording) {
249 recording = FALSE; 249 recording = FALSE;
250 return; 250 return;
251 } 251 }
252 252
253 /* 253 /*
254 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions 254 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
255 mousePressEvent and mouseReleaseEvent with a NULL parameter. 255 mousePressEvent and mouseReleaseEvent with a NULL parameter.
256 */ 256 */
257 if (!systemZaurus && me != NULL) 257#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
258 return; 258 if (!systemZaurus )
259 259 return;
260#endif
261
260 Config config( "Sound" ); 262 Config config( "Sound" );
261 config.setGroup( "System" ); 263 config.setGroup( "System" );
262 useAlerts = config.readBoolEntry("Alert"); 264 useAlerts = config.readBoolEntry("Alert");
263 265
264// if(useAlerts) 266// if(useAlerts)
265// QMessageBox::message("VMemo","Really Record?");//) ==1) 267// QMessageBox::message("VMemo","Really Record?");//) ==1)
266// return; 268// return;
267// } else { 269// } else {
270 if (!systemZaurus )
268 QSound::play(Resource::findSound("vmemob")); 271 QSound::play(Resource::findSound("vmemob"));
269// } 272// }
270 qDebug("Start recording"); 273 qDebug("Start recording");
271 recording = TRUE; 274 recording = TRUE;
272 if (openDSP() == -1) { 275 if (openDSP() == -1) {
273 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 276 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
274 recording = FALSE; 277 recording = FALSE;
275 return; 278 return;
276 } 279 }
277 280
278 Config vmCfg("VMemo"); 281 Config vmCfg("VMemo");
279 vmCfg.setGroup("Defaults"); 282 vmCfg.setGroup("Defaults");
280 283
281 QDateTime dt = QDateTime::currentDateTime(); 284 QDateTime dt = QDateTime::currentDateTime();
282 285
283 QString fName; 286 QString fName;
284 Config cfg( "Sound" ); 287 Config cfg( "Sound" );
285 cfg.setGroup( "System" ); 288 cfg.setGroup( "System" );
286 fileName = cfg.readEntry("RecLocation",QPEApplication::documentDir() ); 289 fName = QPEApplication::documentDir() ;
290 fileName = cfg.readEntry("RecLocation", fName);
287 291
288 int s; 292 int s;
289 s=fileName.find(':'); 293 s=fileName.find(':');
290 if(s) 294 if(s)
291 fileName=fileName.right(fileName.length()-s-2)+"/"; 295 fileName=fileName.right(fileName.length()-s-2);
292 296 qDebug("filename will be "+fileName);
293// if( !fileName.right(1).find('/') == -1) 297 if( !fileName.right(1).find('/') == -1)
294// fileName+="/audio/"; 298 fileName+="/";
295// else
296// fileName+="audio/";
297 299
298// if(systemZaurus) 300// if(systemZaurus)
299// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs 301// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs
300// else 302// else
301// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); 303// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/");
302 304
303 fName = "vm_"+ dt.toString()+ ".wav"; 305 fName = "vm_"+ dt.toString()+ ".wav";
306
304 fileName+=fName; 307 fileName+=fName;
305 qDebug("filename is "+fileName); 308 qDebug("filename is "+fileName);
306 // No spaces in the filename 309 // No spaces in the filename
307 fileName.replace(QRegExp("'"),""); 310 fileName.replace(QRegExp("'"),"");
308 fileName.replace(QRegExp(" "),"_"); 311 fileName.replace(QRegExp(" "),"_");
309 fileName.replace(QRegExp(":"),"."); 312 fileName.replace(QRegExp(":"),".");
310 fileName.replace(QRegExp(","),""); 313 fileName.replace(QRegExp(","),"");
311 314
312 if(openWAV(fileName.latin1()) == -1) { 315 if(openWAV(fileName.latin1()) == -1) {
313 QString err("Could not open the output file\n"); 316 QString err("Could not open the output file\n");
314 err += fileName; 317 err += fileName;
315 QMessageBox::critical(0, "VMemo", err, "Abort"); 318 QMessageBox::critical(0, "VMemo", err, "Abort");
316 close(dsp); 319 close(dsp);
317 return; 320 return;
318 } 321 }
319 322
320 QArray<int> cats(1); 323 QArray<int> cats(1);
321 cats[0] = vmCfg.readNumEntry("Category", 0); 324 cats[0] = vmCfg.readNumEntry("Category", 0);
322 325
323 QString dlName("vm_"); 326 QString dlName("vm_");
324 dlName += dt.toString(); 327 dlName += dt.toString();
325 DocLnk l; 328 DocLnk l;
326 l.setFile(fileName); 329 l.setFile(fileName);
327 l.setName(dlName); 330 l.setName(dlName);
328 l.setType("audio/x-wav"); 331 l.setType("audio/x-wav");
329 l.setCategories(cats); 332 l.setCategories(cats);
330 l.writeLink(); 333 l.writeLink();
331 334
332 record(); 335 record();
333} 336}
334 337
335void VMemo::mouseReleaseEvent( QMouseEvent * ) 338void VMemo::mouseReleaseEvent( QMouseEvent * )
336{ 339{
337 recording = FALSE; 340 recording = FALSE;
338} 341}
339 342
340int VMemo::openDSP() 343int VMemo::openDSP()
341{ 344{
342 Config cfg("Sound"); 345 Config cfg("Sound");
343 cfg.setGroup("Record"); 346 cfg.setGroup("Record");
344 347
345 speed = cfg.readNumEntry("SampleRate", 22050); 348 speed = cfg.readNumEntry("SampleRate", 22050);
346 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 349 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
347 if (cfg.readNumEntry("SixteenBit", 1)==1) { 350 if (cfg.readNumEntry("SixteenBit", 1)==1) {
348 format = AFMT_S16_LE; 351 format = AFMT_S16_LE;
349 resolution = 16; 352 resolution = 16;
350 } else { 353 } else {
351 format = AFMT_U8; 354 format = AFMT_U8;
352 resolution = 8; 355 resolution = 8;
353 } 356 }
354 357
355 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 358 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
356 359
357 if(systemZaurus) { 360 if(systemZaurus) {
358 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 361 dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1
359 channels=1; //zaurus has one input channel 362 channels=1; //zaurus has one input channel
360 } else { 363 } else {
361 dsp = open("/dev/dsp", O_RDWR); 364 dsp = open("/dev/dsp", O_RDWR);
362 } 365 }
363 366
364 if(dsp == -1) { 367 if(dsp == -1) {
365 perror("open(\"/dev/dsp\")"); 368 perror("open(\"/dev/dsp\")");
366
367 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 369 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
368 return -1; 370 return -1;
369 } 371 }
370 372
371 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 373 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
372 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 374 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
373 errorMsg="ioctl(\"SNDCTL_DSP_SETFMT\")\n%d\n"+(QString)strerror(errno),format; 375 errorMsg="ioctl(\"SNDCTL_DSP_SETFMT\")\n%d\n"+(QString)strerror(errno),format;
374 return -1; 376 return -1;
375 } 377 }
376 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 378 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
377 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 379 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
378 errorMsg="ioctl(\"SNDCTL_DSP_CHANNELS\")\n%d\n"+(QString)strerror(errno),channels; 380 errorMsg="ioctl(\"SNDCTL_DSP_CHANNELS\")\n%d\n"+(QString)strerror(errno),channels;
379 return -1; 381 return -1;
380 } 382 }
381 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 383 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
382 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 384 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
383 errorMsg="ioctl(\"SNDCTL_DSP_SPEED\")\n%d\n"+(QString)strerror(errno),speed; 385 errorMsg="ioctl(\"SNDCTL_DSP_SPEED\")\n%d\n"+(QString)strerror(errno),speed;
384 return -1; 386 return -1;
385 } 387 }
386 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 388 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
387 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 389 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
388 errorMsg="ioctl(\"SOUND_PCM_READ_RATE\")\n%d\n"+(QString)strerror(errno),rate; 390 errorMsg="ioctl(\"SOUND_PCM_READ_RATE\")\n%d\n"+(QString)strerror(errno),rate;
389 return -1; 391 return -1;
390 } 392 }
391 393
392 return 1; 394 return 1;
393} 395}
394 396
395int VMemo::openWAV(const char *filename) 397int VMemo::openWAV(const char *filename)
396{ 398{
397 track.setName(filename); 399 track.setName(filename);
398 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { 400 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
399 errorMsg=filename; 401 errorMsg=filename;
400 return -1; 402 return -1;
401 } 403 }
402 404
403 wav=track.handle(); 405 wav=track.handle();
404 406
405 WaveHeader wh; 407 WaveHeader wh;
406 408
407 wh.main_chunk = RIFF; 409 wh.main_chunk = RIFF;
408 wh.length=0; 410 wh.length=0;
409 wh.chunk_type = WAVE; 411 wh.chunk_type = WAVE;
410 wh.sub_chunk = FMT; 412 wh.sub_chunk = FMT;
411 wh.sc_len = 16; 413 wh.sc_len = 16;
412 wh.format = PCM_CODE; 414 wh.format = PCM_CODE;
413 wh.modus = channels; 415 wh.modus = channels;
414 wh.sample_fq = speed; 416 wh.sample_fq = speed;
415 wh.byte_p_sec = speed * channels * resolution/8; 417 wh.byte_p_sec = speed * channels * resolution/8;
416 wh.byte_p_spl = channels * (resolution / 8); 418 wh.byte_p_spl = channels * (resolution / 8);
417 wh.bit_p_spl = resolution; 419 wh.bit_p_spl = resolution;
418 wh.data_chunk = DATA; 420 wh.data_chunk = DATA;
419 wh.data_length= 0; 421 wh.data_length= 0;
420 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" 422 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d"
421 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); 423 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl );
422 write (wav, &wh, sizeof(WaveHeader)); 424 write (wav, &wh, sizeof(WaveHeader));
423 425
424 return 1; 426 return 1;
425} 427}
426 428
427void VMemo::record(void) 429void VMemo::record(void)
428{ 430{
429 int length=0, result, value; 431 int length=0, result, value;
430 qDebug("Recording"); 432 qDebug("Recording");
431 433
432 if(systemZaurus) { 434 if(systemZaurus) {
433 signed short sound[512], monoBuffer[512]; 435 signed short sound[512], monoBuffer[512];
434 if(format==AFMT_S16_LE) { 436 if(format==AFMT_S16_LE) {
435 while(recording) { 437 while(recording) {
436 result = read(dsp, sound, 512); // 8192 438 result = read(dsp, sound, 512); // 8192
437 qApp->processEvents(); 439 qApp->processEvents();
438 int j=0; 440 int j=0;
439 if(systemZaurus) { 441 if(systemZaurus) {
440 for (int i = 0; i < result; i++) { //since Z is mono do normally 442 for (int i = 0; i < result; i++) { //since Z is mono do normally
441 monoBuffer[i] = sound[i]; 443 monoBuffer[i] = sound[i];
442 } 444 }
443 qApp->processEvents(); 445 qApp->processEvents();
444 length+=write(wav, monoBuffer, result); 446 length+=write(wav, monoBuffer, result);
445 } else { //ipaq /stereo inputs 447 } else { //ipaq /stereo inputs
446 for (int i = 0; i < result; i+=2) { 448 for (int i = 0; i < result; i+=2) {
447 monoBuffer[j] = (sound[i]+sound[i+1])/2; 449 monoBuffer[j] = (sound[i]+sound[i+1])/2;
448 j++; 450 j++;
449 } 451 }
450 qApp->processEvents(); 452 qApp->processEvents();
451 length+=write(wav, monoBuffer, result/2); 453 length+=write(wav, monoBuffer, result/2);
452 } 454 }
453 printf("%d\r",length); 455 printf("%d\r",length);
454 fflush(stdout); 456 fflush(stdout);
455 } 457 }
456 } else { //AFMT_U8 458 } else { //AFMT_U8
457// 8bit unsigned 459// 8bit unsigned
458 unsigned short sound[512], monoBuffer[512]; 460 unsigned short sound[512], monoBuffer[512];
459 while(recording) { 461 while(recording) {
460 result = read(dsp, sound, 512); // 8192 462 result = read(dsp, sound, 512); // 8192
461 qApp->processEvents(); 463 qApp->processEvents();
462 int j=0; 464 int j=0;
463 if(systemZaurus) { 465 if(systemZaurus) {
464 for (int i = 0; i < result; i++) { //since Z is mono do normally 466 for (int i = 0; i < result; i++) { //since Z is mono do normally
465 monoBuffer[i] = sound[i]; 467 monoBuffer[i] = sound[i];
466 } 468 }
467 qApp->processEvents(); 469 qApp->processEvents();
468 length+=write(wav, monoBuffer, result); 470 length+=write(wav, monoBuffer, result);
469 } else { //ipaq /stereo inputs 471 } else { //ipaq /stereo inputs
470 for (int i = 0; i < result; i+=2) { 472 for (int i = 0; i < result; i+=2) {
471 monoBuffer[j] = (sound[i]+sound[i+1])/2; 473 monoBuffer[j] = (sound[i]+sound[i+1])/2;
472 j++; 474 j++;
473 } 475 }
474 qApp->processEvents(); 476 qApp->processEvents();
475 length+=write(wav, monoBuffer, result/2); 477 length+=write(wav, monoBuffer, result/2);
476 } 478 }
477 length += result; 479 length += result;
478 printf("%d\r",length); 480 printf("%d\r",length);
479 fflush(stdout); 481 fflush(stdout);
480 482
481 qApp->processEvents(); 483 qApp->processEvents();
482 } 484 }
483 485
484 qApp->processEvents(); 486 qApp->processEvents();
485 } 487 }
486 488
487 } else { 489 } else {
488 490
489 signed short sound[512], monoBuffer[512]; 491 signed short sound[512], monoBuffer[512];
490 492
491 while(recording) { 493 while(recording) {
492 result = read(dsp, sound, 512); // 8192 494 result = read(dsp, sound, 512); // 8192
493 qApp->processEvents(); 495 qApp->processEvents();
494 496
495 write(wav, sound, result); 497 write(wav, sound, result);
496 length += result; 498 length += result;
497 499
498 qApp->processEvents(); 500 qApp->processEvents();
499 } 501 }
500 printf("%d\r",length); 502 printf("%d\r",length);
501 fflush(stdout); 503 fflush(stdout);
502 // qDebug("file has length of %d lasting %d seconds", 504 // qDebug("file has length of %d lasting %d seconds",
503 // length, (( length / speed) / channels) / 2 ); 505 // length, (( length / speed) / channels) / 2 );
504 // medialplayer states wrong length in secs 506 // medialplayer states wrong length in secs
505 } 507 }
506 508
507 value = length+36; 509 value = length+36;
508 lseek(wav, 4, SEEK_SET); 510 lseek(wav, 4, SEEK_SET);
509 write(wav, &value, 4); 511 write(wav, &value, 4);
510 lseek(wav, 40, SEEK_SET); 512 lseek(wav, 40, SEEK_SET);
511 write(wav, &length, 4); 513 write(wav, &length, 4);
512 track.close(); 514 track.close();
513 515
514 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 516 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
515 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 517 perror("ioctl(\"SNDCTL_DSP_RESET\")");
516 ::close(dsp); 518 ::close(dsp);
519 fileName = fileName.left(fileName.length()-4);
517 if(useAlerts) 520 if(useAlerts)
518 QMessageBox::message("Vmemo"," Done recording\n"+ fileName); 521 QMessageBox::message("Vmemo"," Done recording\n"+ fileName);
522 qDebug("done recording "+fileName);
519 QSound::play(Resource::findSound("vmemoe")); 523 QSound::play(Resource::findSound("vmemoe"));
520} 524}