Diffstat (limited to 'core/applets/vmemo/vmemo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 9d69130..fea673c 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -148,15 +148,15 @@ VMemo::VMemo( QWidget *parent, const char *name ) | |||
148 | systemZaurus=TRUE; | 148 | systemZaurus=TRUE; |
149 | else { | 149 | else { |
150 | systemZaurus=FALSE; | 150 | systemZaurus=FALSE; |
151 | // myChannel = new QCopChannel( "QPE/VMemo", this ); | 151 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
152 | // connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 152 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
153 | // this, SLOT(receive(const QCString&, const QByteArray&)) ); | 153 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
154 | 154 | ||
155 | // // Register the REC key press, for ipaq only | 155 | // // Register the REC key press, for ipaq only |
156 | // QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 156 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
157 | // e << 4096; | 157 | e << 4096; |
158 | // e << QString("QPE/VMemo"); | 158 | e << QString("QPE/VMemo"); |
159 | // e << QString("toggleRecord()"); | 159 | e << QString("toggleRecord()"); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
@@ -271,11 +271,11 @@ int VMemo::openDSP() | |||
271 | format = AFMT_S16_LE; | 271 | format = AFMT_S16_LE; |
272 | resolution = 16; | 272 | resolution = 16; |
273 | } | 273 | } |
274 | // else { | 274 | else { |
275 | // format = AFMT_U8; | 275 | format = AFMT_S8; |
276 | // resolution = 8; | 276 | resolution = 8; |
277 | // } | 277 | } |
278 | 278 | ||
279 | if(systemZaurus) { | 279 | if(systemZaurus) { |
280 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 280 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
281 | channels=1; //zaurus has one input channel | 281 | channels=1; //zaurus has one input channel |
@@ -317,7 +317,7 @@ int VMemo::openWAV(const char *filename) | |||
317 | wav=track.handle(); | 317 | wav=track.handle(); |
318 | 318 | ||
319 | WaveHeader wh; | 319 | WaveHeader wh; |
320 | 320 | ||
321 | wh.main_chunk = RIFF; | 321 | wh.main_chunk = RIFF; |
322 | wh.length=0; | 322 | wh.length=0; |
323 | wh.chunk_type = WAVE; | 323 | wh.chunk_type = WAVE; |
@@ -343,8 +343,10 @@ void VMemo::record(void) | |||
343 | int length=0, result, value; | 343 | int length=0, result, value; |
344 | qDebug("Recording"); | 344 | qDebug("Recording"); |
345 | 345 | ||
346 | if(format==AFMT_S16_LE) { | 346 | if(systemZaurus) { |
347 | signed short sound[512], monoBuffer[512]; | 347 | signed short sound[512], monoBuffer[512]; |
348 | |||
349 | if(format==AFMT_S16_LE) { | ||
348 | while(recording) { | 350 | while(recording) { |
349 | result = read(dsp, sound, 512); // 8192 | 351 | result = read(dsp, sound, 512); // 8192 |
350 | qApp->processEvents(); | 352 | qApp->processEvents(); |
@@ -367,56 +369,54 @@ void VMemo::record(void) | |||
367 | fflush(stdout); | 369 | fflush(stdout); |
368 | } | 370 | } |
369 | } | 371 | } |
370 | // else { //AFMT_U8 // don't try this yet.. as player doesn't understand | 372 | else { //AFMT_S8 // don't try this yet.. as player doesn't understand 8bit unsigned |
371 | // 8bit unsigned | 373 | while(recording) |
372 | // unsigned short sound[512], monoBuffer[512]; | 374 | { |
373 | // while(recording) | 375 | result = read(dsp, sound, 512); // 8192 |
374 | // { | 376 | qApp->processEvents(); |
375 | // result = read(dsp, sound, 512); // 8192 | 377 | int j=0; |
376 | // qApp->processEvents(); | 378 | if(systemZaurus) |
377 | // int j=0; | 379 | { |
378 | // if(systemZaurus) | 380 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
379 | // { | 381 | monoBuffer[i] = sound[i]; |
380 | // for (int i = 0; i < result; i++) { //since Z is mono do normally | 382 | } |
381 | // monoBuffer[i] = sound[i]; | 383 | qApp->processEvents(); |
382 | // } | 384 | length+=write(wav, monoBuffer, result); |
383 | // qApp->processEvents(); | 385 | } else { //ipaq /stereo inputs |
384 | // length+=write(wav, monoBuffer, result); | 386 | for (int i = 0; i < result; i+=2) { |
385 | // } else { //ipaq /stereo inputs | 387 | monoBuffer[j] = (sound[i]+sound[i+1])/2; |
386 | // for (int i = 0; i < result; i+=2) { | 388 | j++; |
387 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 389 | } |
388 | // j++; | 390 | qApp->processEvents(); |
389 | // } | 391 | length+=write(wav, monoBuffer, result/2); |
390 | // qApp->processEvents(); | 392 | } |
391 | // length+=write(wav, monoBuffer, result/2); | 393 | length += result; |
392 | // } | 394 | printf("%d\r",length); |
393 | // // length += result; | 395 | fflush(stdout); |
394 | // printf("%d\r",length); | 396 | |
395 | // fflush(stdout); | 397 | qApp->processEvents(); |
396 | 398 | } | |
397 | // qApp->processEvents(); | 399 | } |
398 | // } | ||
399 | // } | ||
400 | 400 | ||
401 | } else { | ||
401 | 402 | ||
402 | 403 | char sound[512]; //char is 8 bit | |
403 | // char sound[512]; //char is 8 bit | ||
404 | |||
405 | // while(recording) | ||
406 | // { | ||
407 | // result = read(dsp, sound, 512); // 8192 | ||
408 | // qApp->processEvents(); | ||
409 | 404 | ||
410 | // write(wav, sound, result); | 405 | while(recording) |
411 | // length += result; | 406 | { |
407 | result = read(dsp, sound, 512); // 8192 | ||
408 | qApp->processEvents(); | ||
409 | |||
410 | write(wav, sound, 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); |
@@ -427,7 +427,7 @@ void VMemo::record(void) | |||
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")); |