summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 006e0ba..aa23ba7 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -306,98 +306,98 @@ int VMemo::openDSP()
306 } 306 }
307 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) 307 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1)
308 { 308 {
309 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 309 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
310 return -1; 310 return -1;
311 } 311 }
312 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) 312 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1)
313 { 313 {
314 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 314 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
315 return -1; 315 return -1;
316 } 316 }
317 317
318 return 1; 318 return 1;
319} 319}
320 320
321int VMemo::openWAV(const char *filename) 321int VMemo::openWAV(const char *filename)
322{ 322{
323 qDebug("Creating %s ",filename); 323 qDebug("Creating %s ",filename);
324 track.setName(filename); 324 track.setName(filename);
325 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) 325 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw))
326 { 326 {
327 qDebug("Could not open file"); 327 qDebug("Could not open file");
328 return -1; 328 return -1;
329 } 329 }
330 wav=track.handle(); 330 wav=track.handle();
331 331
332 WaveHeader wh; 332 WaveHeader wh;
333 333
334 wh.main_chunk = RIFF; 334 wh.main_chunk = RIFF;
335 wh.length=0; 335 wh.length=0;
336 wh.chunk_type = WAVE; 336 wh.chunk_type = WAVE;
337 wh.sub_chunk = FMT; 337 wh.sub_chunk = FMT;
338 wh.sc_len = 16; 338 wh.sc_len = 16;
339 wh.format = PCM_CODE; 339 wh.format = PCM_CODE;
340 wh.modus = channels; 340 wh.modus = channels;
341 wh.sample_fq = speed; 341 wh.sample_fq = speed;
342 wh.byte_p_sec = speed * channels * resolution/8; 342 wh.byte_p_sec = speed * channels * resolution/8;
343 wh.byte_p_spl = channels * (resolution / 8); 343 wh.byte_p_spl = channels * (resolution / 8);
344 wh.bit_p_spl = resolution; 344 wh.bit_p_spl = resolution;
345 wh.data_chunk = DATA; 345 wh.data_chunk = DATA;
346 wh.data_length= 0; 346 wh.data_length= 0;
347 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" 347 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d"
348 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); 348 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl );
349 write (wav, &wh, sizeof(WaveHeader)); 349 write (wav, &wh, sizeof(WaveHeader));
350 350
351 return 1; 351 return 1;
352} 352}
353 353
354void VMemo::record(void) 354void VMemo::record(void)
355{ 355{
356 int length=0, result, value; //, i; 356 int length=0, result, value; //, i;
357 char sound[512]; //, leftBuffer[256], rightBuffer[256]; 357 char sound[512]; //, leftBuffer[256], rightBuffer[256];
358 358
359 qWarning("VMemo::record()"); 359 qWarning("VMemo::record()");
360 360
361 while(recording) 361 while(recording)
362 { 362 {
363 result = read(dsp, sound, 512); // 8192 363 result = read(dsp, sound, 512); // 8192
364 qApp->processEvents(); 364 qApp->processEvents();
365 365
366 /* attempt to write only one channel...didnt work. 366 /* attempt to write only one channel...didnt work.
367 for (i = 0; i < result; i++) { 367 for (i = 0; i < result; i++) {
368 leftBuffer[i] = sound[2*i]; 368 leftBuffer[i] = sound[2*i];
369 rightBuffer[i] = sound[2*i+1]; 369 rightBuffer[i] = sound[2*i+1];
370 } 370 }
371 */ 371 */
372 qApp->processEvents(); 372 qApp->processEvents();
373 373
374 /* needed to only write one channel. comment out above "write/length" code. 374 /* needed to only write one channel. comment out above "write/length" code.
375 write(wav, leftBuffer, result / 2); 375 write(wav, leftBuffer, result / 2);
376 length += result/2; 376 length += result/2;
377 */ 377 */
378 378
379 write(wav, sound, result); 379 write(wav, sound, result);
380 length += result; 380 length += result;
381 381
382 qApp->processEvents(); 382 qApp->processEvents();
383 } 383 }
384 384
385 qWarning("VMemo::record() -> Done recording"); 385 qWarning("VMemo::record() -> Done recording");
386 qWarning("VMemo::record() -> Closing dsp"); 386 qWarning("VMemo::record() -> Closing dsp");
387 387
388 value = length+36; 388 value = length+36;
389 lseek(wav, 4, SEEK_SET); 389 lseek(wav, 4, SEEK_SET);
390 write(wav, &value, 4); 390 write(wav, &value, 4);
391 lseek(wav, 40, SEEK_SET); 391 lseek(wav, 40, SEEK_SET);
392 write(wav, &length, 4); 392 write(wav, &length, 4);
393 track.close(); 393 track.close();
394 394
395 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 395 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
396 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 396 perror("ioctl(\"SNDCTL_DSP_RESET\")");
397 ::close(dsp); 397 ::close(dsp);
398 398
399 qWarning("VMemo::record() -> playing done recording sound"); 399 qWarning("VMemo::record() -> playing done recording sound");
400 QSound::play(Resource::findSound("vmemoe")); 400 QSound::play(Resource::findSound("vmemoe"));
401 qWarning("VMemo::record() -> terminating"); 401 qWarning("VMemo::record() -> terminating");
402 QMessageBox::information(0, "VMemo", "Recording Done", 1); 402 //QMessageBox::information(0, "VMemo", "Recording Done", 1);
403} 403}