summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp154
1 files changed, 77 insertions, 77 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index b3edbc1..ae5cf0c 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -340,95 +340,95 @@ int VMemo::openWAV(const char *filename)
340 340
341void VMemo::record(void) 341void VMemo::record(void)
342{ 342{
343 int length=0, result, value; 343 int length=0, result, value;
344 qDebug("Recording"); 344 qDebug("Recording");
345 345
346 if(systemZaurus) { 346 if(systemZaurus) {
347 signed short sound[512], monoBuffer[512]; 347 signed short sound[512], monoBuffer[512];
348 348
349 if(format==AFMT_S16_LE) { 349 if(format==AFMT_S16_LE) {
350 while(recording) { 350 while(recording) {
351 result = read(dsp, sound, 512); // 8192 351 result = read(dsp, sound, 512); // 8192
352 qApp->processEvents(); 352 qApp->processEvents();
353 int j=0; 353 int j=0;
354 if(systemZaurus) { 354 if(systemZaurus) {
355 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
356 monoBuffer[i] = sound[i]; 356 monoBuffer[i] = sound[i];
357 } 357 }
358 qApp->processEvents(); 358 qApp->processEvents();
359 length+=write(wav, monoBuffer, result); 359 length+=write(wav, monoBuffer, result);
360 } else { //ipaq /stereo inputs 360 } else { //ipaq /stereo inputs
361 for (int i = 0; i < result; i+=2) { 361 for (int i = 0; i < result; i+=2) {
362 monoBuffer[j] = (sound[i]+sound[i+1])/2; 362 monoBuffer[j] = (sound[i]+sound[i+1])/2;
363 j++; 363 j++;
364 } 364 }
365 qApp->processEvents(); 365 qApp->processEvents();
366 length+=write(wav, monoBuffer, result/2); 366 length+=write(wav, monoBuffer, result/2);
367 } 367 }
368 printf("%d\r",length); 368 printf("%d\r",length);
369 fflush(stdout); 369 fflush(stdout);
370 } 370 }
371 } 371 }
372 else { //AFMT_S8 // don't try this yet.. as player doesn't understand 8bit unsigned 372 else { //AFMT_S8 // don't try this yet.. as player doesn't understand 8bit unsigned
373 while(recording) 373 while(recording)
374 { 374 {
375 result = read(dsp, sound, 512); // 8192 375 result = read(dsp, sound, 512); // 8192
376 qApp->processEvents(); 376 qApp->processEvents();
377 int j=0; 377 int j=0;
378 if(systemZaurus) 378 if(systemZaurus)
379 { 379 {
380 for (int i = 0; i < result; i++) { //since Z is mono do normally 380 for (int i = 0; i < result; i++) { //since Z is mono do normally
381 monoBuffer[i] = sound[i]; 381 monoBuffer[i] = sound[i];
382 } 382 }
383 qApp->processEvents(); 383 qApp->processEvents();
384 length+=write(wav, monoBuffer, result); 384 length+=write(wav, monoBuffer, result);
385 } else { //ipaq /stereo inputs 385 } else { //ipaq /stereo inputs
386 for (int i = 0; i < result; i+=2) { 386 for (int i = 0; i < result; i+=2) {
387 monoBuffer[j] = (sound[i]+sound[i+1])/2; 387 monoBuffer[j] = (sound[i]+sound[i+1])/2;
388 j++; 388 j++;
389 } 389 }
390 qApp->processEvents(); 390 qApp->processEvents();
391 length+=write(wav, monoBuffer, result/2); 391 length+=write(wav, monoBuffer, result/2);
392 } 392 }
393 length += result; 393 length += result;
394 printf("%d\r",length); 394 printf("%d\r",length);
395 fflush(stdout); 395 fflush(stdout);
396 396
397 qApp->processEvents(); 397 qApp->processEvents();
398 } 398 }
399} 399 }
400 400
401} else { 401 } else {
402 402
403 char sound[512]; //char is 8 bit 403 char sound[512]; //char is 8 bit
404 404
405 while(recording) 405 while(recording)
406{ 406 {
407 result = read(dsp, sound, 512); // 8192 407 result = read(dsp, sound, 512); // 8192
408 qApp->processEvents(); 408 qApp->processEvents();
409 409
410 write(wav, sound, result); 410 write(wav, sound, result);
411 length += result; 411 length += result;
412 412
413 qApp->processEvents(); 413 qApp->processEvents();
414} 414 }
415// qDebug("file has length of %d lasting %d seconds", 415 // qDebug("file has length of %d lasting %d seconds",
416// length, (( length / speed) / channels) / 2 ); 416 // length, (( length / speed) / channels) / 2 );
417// medialplayer states wrong length in secs 417 // medialplayer states wrong length in secs
418} 418 }
419 419
420 value = length+36; 420 value = length+36;
421 lseek(wav, 4, SEEK_SET); 421 lseek(wav, 4, SEEK_SET);
422 write(wav, &value, 4); 422 write(wav, &value, 4);
423 lseek(wav, 40, SEEK_SET); 423 lseek(wav, 40, SEEK_SET);
424 write(wav, &length, 4); 424 write(wav, &length, 4);
425 track.close(); 425 track.close();
426 426
427 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 427 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
428 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 428 perror("ioctl(\"SNDCTL_DSP_RESET\")");
429 ::close(dsp); 429 ::close(dsp);
430 if(systemZaurus) 430 if(systemZaurus)
431 QMessageBox::message("Vmemo"," Done recording"); 431 QMessageBox::message("Vmemo"," Done recording");
432 432
433 QSound::play(Resource::findSound("vmemoe")); 433 QSound::play(Resource::findSound("vmemoe"));
434} 434}