summaryrefslogtreecommitdiff
path: root/noncore/multimedia
Unidiff
Diffstat (limited to 'noncore/multimedia') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/opierec.pro5
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp143
-rw-r--r--noncore/multimedia/opierec/qtrec.h2
3 files changed, 62 insertions, 88 deletions
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro
index 39fe493..5651151 100644
--- a/noncore/multimedia/opierec/opierec.pro
+++ b/noncore/multimedia/opierec/opierec.pro
@@ -1,37 +1,38 @@
1#CONFIG = qt qtopia warn_on release pdaudio 1CONFIG = qt qtopia warn_on release pdaudio
2CONFIG = qt warn_on release opie 2#CONFIG = qt warn_on release opie
3#CONFIG = qt warn_on release quick-app 3#CONFIG = qt warn_on release quick-app
4HEADERS = adpcm.h \ 4HEADERS = adpcm.h \
5 pixmaps.h \ 5 pixmaps.h \
6 helpwindow.h \ 6 helpwindow.h \
7 qtrec.h \ 7 qtrec.h \
8 device.h \ 8 device.h \
9 wavFile.h \ 9 wavFile.h \
10 waveform.h 10 waveform.h
11SOURCES = adpcm.c \ 11SOURCES = adpcm.c \
12 helpwindow.cpp \ 12 helpwindow.cpp \
13 main.cpp \ 13 main.cpp \
14 qtrec.cpp \ 14 qtrec.cpp \
15 device.cpp \ 15 device.cpp \
16 wavFile.cpp \ 16 wavFile.cpp \
17 waveform.cpp 17 waveform.cpp
18INTERFACES = 18INTERFACES =
19 19
20contains(CONFIG, pdaudio) { 20contains(CONFIG, pdaudio) {
21# LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz 21# LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz
22 LIBS += -L$(QPEDIR)/lib -lqpe -lpthread -ljpeg -lpng -lz 22 LIBS += -L$(QPEDIR)/lib -lqpe -lpthread -ljpeg -lpng -lz
23 INCLUDEPATH += $(QPEDIR)/include 23 INCLUDEPATH += $(QPEDIR)/include
24 DEPENDPATH += $(QPEDIR)/include 24 DEPENDPATH += $(QPEDIR)/include
25 DEFINES += PDAUDIO 25 DEFINES += PDAUDIO
26 DEFINES += THREADED
26 TARGET = qperec 27 TARGET = qperec
27 28
28# DESTDIR=$(QPEDIR)/bin 29# DESTDIR=$(QPEDIR)/bin
29} 30}
30 31
31contains(CONFIG, opie) { 32contains(CONFIG, opie) {
32 INCLUDEPATH += $(OPIEDIR)/include 33 INCLUDEPATH += $(OPIEDIR)/include
33 DEPENDPATH += $(OPIEDIR)/include 34 DEPENDPATH += $(OPIEDIR)/include
34 DESTDIR=$(OPIEDIR)/bin 35 DESTDIR=$(OPIEDIR)/bin
35 LIBS += -lqpe -lpthread 36 LIBS += -lqpe -lpthread
36 TARGET = opierec 37 TARGET = opierec
37 include ( $(OPIEDIR)/include.pro ) 38 include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index bc6abcc..0a6e5ae 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,18 +1,17 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6
7#define DEV_VERSION 6#define DEV_VERSION
8 7
9#include "pixmaps.h" 8#include "pixmaps.h"
10#include "qtrec.h" 9#include "qtrec.h"
11#include "waveform.h" 10#include "waveform.h"
12#include "device.h" 11#include "device.h"
13 12
14#include <pthread.h> 13#include <pthread.h>
15 14
16extern "C" { 15extern "C" {
17#include "adpcm.h" 16#include "adpcm.h"
18} 17}
@@ -107,29 +106,31 @@ typedef struct {
107 106
108fileParameters filePara; 107fileParameters filePara;
109 108
110bool monitoring, recording, playing; 109bool monitoring, recording, playing;
111bool stopped; 110bool stopped;
112QLabel *timeLabel; 111QLabel *timeLabel;
113QSlider *timeSlider; 112QSlider *timeSlider;
114int sd; 113int sd;
115 114
116Waveform* waveform; 115Waveform* waveform;
117Device *soundDevice; 116Device *soundDevice;
118 117
119// threaded recording 118
120//fuckin fulgy here 119#ifdef THREADED
121//void quickRec() 120void quickRec()
122//{ 121#else
123void QtRec::quickRec() { 122 void QtRec::quickRec()
123#endif
124{
124 125
125 qDebug("%d", 126 qDebug("%d",
126 filePara.numberSamples/filePara.sampleRate * filePara.channels); 127 filePara.numberSamples/filePara.sampleRate * filePara.channels);
127 qDebug("samples %d, rate %d, channels %d", 128 qDebug("samples %d, rate %d, channels %d",
128 filePara.numberSamples, filePara.sampleRate, filePara.channels); 129 filePara.numberSamples, filePara.sampleRate, filePara.channels);
129 130
130 int total = 0; // Total number of bytes read in so far. 131 int total = 0; // Total number of bytes read in so far.
131 int bytesWritten, number; 132 int bytesWritten, number;
132 133
133 bytesWritten = 0; 134 bytesWritten = 0;
134 number = 0; 135 number = 0;
135 QString num; 136 QString num;
@@ -148,25 +149,25 @@ void QtRec::quickRec() {
148 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 149 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
149// qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); 150// qDebug("start recording WAVE_FORMAT_DVI_ADPCM");
150 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 151 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
151 char abuf[ BUFSIZE/2 ]; 152 char abuf[ BUFSIZE/2 ];
152 short sbuf[ BUFSIZE ]; 153 short sbuf[ BUFSIZE ];
153 short sbuf2[ BUFSIZE ]; 154 short sbuf2[ BUFSIZE ];
154 memset( abuf, 0, BUFSIZE/2); 155 memset( abuf, 0, BUFSIZE/2);
155 memset( sbuf, 0, BUFSIZE); 156 memset( sbuf, 0, BUFSIZE);
156 memset( sbuf2, 0, BUFSIZE); 157 memset( sbuf2, 0, BUFSIZE);
157 158
158 for(;;) { 159 for(;;) {
159 if ( stopped) { 160 if ( stopped) {
160 qDebug("quickRec:: stopped"); 161 // qDebug("quickRec:: stopped");
161 break; 162 break;
162 } 163 }
163 164
164// number=::read( filePara.sd, sbuf, BUFSIZE); 165// number=::read( filePara.sd, sbuf, BUFSIZE);
165 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); 166 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
166 167
167 if(number <= 0) { 168 if(number <= 0) {
168 perror("recording error "); 169 perror("recording error ");
169 qDebug( "%s %d", filePara.fileName, number); 170 qDebug( "%s %d", filePara.fileName, number);
170 stopped = true; 171 stopped = true;
171 return; 172 return;
172 } 173 }
@@ -224,35 +225,35 @@ void QtRec::quickRec() {
224 } 225 }
225 226
226 total += bytesWritten; 227 total += bytesWritten;
227 228
228 filePara.numberSamples = total; 229 filePara.numberSamples = total;
229 230
230 if( filePara.SecondsToRecord != 0) 231 if( filePara.SecondsToRecord != 0)
231 timeSlider->setValue( total); 232 timeSlider->setValue( total);
232// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); 233// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total);
233// fflush(stdout); 234// fflush(stdout);
234 235
235 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; 236 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels;
236
237 qApp->processEvents(); 237 qApp->processEvents();
238 238
239 if( total >= filePara.samplesToRecord) { 239 if( total >= filePara.samplesToRecord) {
240 stopped = true; 240 stopped = true;
241 break; 241 break;
242 } 242 }
243 } 243 }
244 } //end main loop 244 } //end main loop
245 245
246 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 246 } else {
247// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
247 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 248 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
248 memset( unsigned_inbuffer, 0, BUFSIZE); 249 memset( unsigned_inbuffer, 0, BUFSIZE);
249 memset( unsigned_outbuffer, 0, BUFSIZE); 250 memset( unsigned_outbuffer, 0, BUFSIZE);
250 251
251 for(;;) { 252 for(;;) {
252 if ( stopped) { 253 if ( stopped) {
253 qDebug("quickRec:: stopped"); 254 qDebug("quickRec:: stopped");
254 break; // stop if playing was set to false 255 break; // stop if playing was set to false
255 } 256 }
256 257
257 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 258 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
258 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 259 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
@@ -273,29 +274,33 @@ void QtRec::quickRec() {
273 274
274 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 275 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
275 276
276 qApp->processEvents(); 277 qApp->processEvents();
277 if( total >= filePara.samplesToRecord) { 278 if( total >= filePara.samplesToRecord) {
278 stopped = true; 279 stopped = true;
279 break; 280 break;
280 } 281 }
281 } //end main loop 282 } //end main loop
282 } 283 }
283} /// END quickRec() 284} /// END quickRec()
284 285
285void QtRec::playIt()
286 286
287//void playIt() 287#ifdef THREADED
288void playIt()
289#else
290 void QtRec::playIt()
291#endif
288{ 292{
289 int bytesWritten, number; 293 int bytesWritten = 0;
294 int number = 0;
290 int total = 0; // Total number of bytes read in so far. 295 int total = 0; // Total number of bytes read in so far.
291 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 296 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
292 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 297 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
293 char abuf[ BUFSIZE / 2 ]; 298 char abuf[ BUFSIZE / 2 ];
294 short sbuf[ BUFSIZE ]; 299 short sbuf[ BUFSIZE ];
295 short sbuf2[ BUFSIZE * 2 ]; 300 short sbuf2[ BUFSIZE * 2 ];
296 memset( abuf, 0, BUFSIZE / 2); 301 memset( abuf, 0, BUFSIZE / 2);
297 memset( sbuf, 0, BUFSIZE); 302 memset( sbuf, 0, BUFSIZE);
298 memset( sbuf2, 0, BUFSIZE * 2); 303 memset( sbuf2, 0, BUFSIZE * 2);
299// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 304// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
300 for(;;) { // play loop 305 for(;;) { // play loop
301 if ( stopped) { 306 if ( stopped) {
@@ -313,26 +318,26 @@ void QtRec::playIt()
313 waveform->newSamples( (const short *)sbuf, number ); 318 waveform->newSamples( (const short *)sbuf, number );
314 // if(filePara.channels==1) 319 // if(filePara.channels==1)
315 // total += bytesWritten/2; //mono 320 // total += bytesWritten/2; //mono
316 // else 321 // else
317 total += bytesWritten; 322 total += bytesWritten;
318 filePara.numberSamples = total/4; 323 filePara.numberSamples = total/4;
319 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 324 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
320 325
321 timeSlider->setValue( total/4); 326 timeSlider->setValue( total/4);
322// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 327// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
323// if(filePara.numberOfRecordedSeconds>1) 328// if(filePara.numberOfRecordedSeconds>1)
324// timeLabel->setText( timeString+ tr(" seconds")); 329// timeLabel->setText( timeString+ tr(" seconds"));
325 printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 330 // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
326 fflush(stdout); 331 // fflush(stdout);
327 332
328 qApp->processEvents(); 333 qApp->processEvents();
329 334
330 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 335 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
331// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { 336// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
332 stopped = true; 337 stopped = true;
333 break; 338 break;
334 } 339 }
335 } 340 }
336 } else { 341 } else {
337 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 342 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
338 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 343 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
@@ -399,44 +404,50 @@ void QtRec::playIt()
399 filePara.numberSamples = total; 404 filePara.numberSamples = total;
400 405
401 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 406 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
402// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 407// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
403// timeLabel->setText( timeString + tr(" seconds")); 408// timeLabel->setText( timeString + tr(" seconds"));
404 qApp->processEvents(); 409 qApp->processEvents();
405 410
406 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 411 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
407// if( total >= filePara.numberSamples ) { 412// if( total >= filePara.numberSamples ) {
408 stopped = true; 413 stopped = true;
409 break; 414 break;
410 } 415 }
411 printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 416 // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
412 fflush(stdout); 417 // fflush(stdout);
413 } 418 }
414 } 419 }
415} 420}
416 421
417/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
418 422
419QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 423QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
420 : QWidget( parent, name, fl ) 424 : QWidget( parent, name, fl )
421{ 425{
422 if ( !name ) 426 if ( !name )
423 setName( "OpieRec" ); 427 setName( "OpieRec" );
424 init(); 428 init();
425 initConfig(); 429 initConfig();
426 initConnections(); 430 initConnections();
427 renameBox = 0; 431 renameBox = 0;
428 432
429// open sound device to get volumes 433// open sound device to get volumes
430 soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false); 434 Config hwcfg("OpieRec");
435 hwcfg.setGroup("Hardware");
436
437
438 soundDevice = new Device( this,
439 hwcfg.readEntry( "Audio",DSPSTROUT),
440 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false);
441 // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false);
431 442
432// soundDevice->setDeviceFormat(AFMT_S16_LE); 443// soundDevice->setDeviceFormat(AFMT_S16_LE);
433// soundDevice->setDeviceChannels(1); 444// soundDevice->setDeviceChannels(1);
434// soundDevice->setDeviceRate( 22050); 445// soundDevice->setDeviceRate( 22050);
435 446
436 getInVol(); 447 getInVol();
437 getOutVol(); 448 getOutVol();
438 449
439 soundDevice->closeDevice( true); 450 soundDevice->closeDevice( true);
440 soundDevice->sd = -1; 451 soundDevice->sd = -1;
441 soundDevice = 0; 452 soundDevice = 0;
442 wavFile = 0; 453 wavFile = 0;
@@ -631,30 +642,24 @@ void QtRec::init() {
631 642
632 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); 643 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
633 644
634 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); 645 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
635 646
636 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); 647 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
637 stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); 648 stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 );
638 649
639 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); 650 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
640 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); 651 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
641 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); 652 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
642 653
643 QWidget *d = QApplication::desktop();
644 int width = d->width();
645 int height = d->height();
646
647 if( width < height) {
648
649 tab_5 = new QWidget( TabWidget, "tab_5" ); 654 tab_5 = new QWidget( TabWidget, "tab_5" );
650 655
651 QHBoxLayout *Layout19a; 656 QHBoxLayout *Layout19a;
652 Layout19a = new QHBoxLayout( tab_5); 657 Layout19a = new QHBoxLayout( tab_5);
653 Layout19a->setSpacing( 2 ); 658 Layout19a->setSpacing( 2 );
654 Layout19a->setMargin( 0 ); 659 Layout19a->setMargin( 0 );
655 660
656 Layout15 = new QVBoxLayout( this); 661 Layout15 = new QVBoxLayout( this);
657 Layout15->setSpacing( 2 ); 662 Layout15->setSpacing( 2 );
658 Layout15->setMargin( 0 ); 663 Layout15->setMargin( 0 );
659 664
660 Layout15b = new QVBoxLayout( this); 665 Layout15b = new QVBoxLayout( this);
@@ -687,89 +692,43 @@ void QtRec::init() {
687 Layout15b->addWidget( inMuteCheckBox ); 692 Layout15b->addWidget( inMuteCheckBox );
688 693
689 694
690 Layout19a->addLayout( Layout15 ); 695 Layout19a->addLayout( Layout15 );
691 Layout19a->addLayout( Layout15b ); 696 Layout19a->addLayout( Layout15b );
692 697
693 fillDirectoryCombo(); 698 fillDirectoryCombo();
694 699
695 TabWidget->insertTab( tab_3, tr( "Options" ) ); 700 TabWidget->insertTab( tab_3, tr( "Options" ) );
696 701
697 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 702 TabWidget->insertTab( tab_5, tr( "Volume" ) );
698 703
699 } else {// landscape
700
701 // Layout16->addWidget( dirGroup );
702 // Layout18->addLayout( Layout16 );
703 Layout15 = new QVBoxLayout(this);
704 Layout15->setSpacing( 2 );
705 Layout15->setMargin( 0 );
706
707 Layout15b = new QVBoxLayout(this);
708 Layout15b->setSpacing( 2 );
709 Layout15b->setMargin( 0 );
710
711 TextLabel2 = new QLabel( tab_3, "InputLabel" );
712 TextLabel2->setText( tr( "In"));
713 TextLabel2->setFixedWidth(35);
714 Layout15->addWidget( TextLabel2 );
715
716 TextLabel3 = new QLabel( tab_3, "OutputLabel" );
717 TextLabel3->setText( tr( "Out" ) );
718 Layout15b->addWidget( TextLabel3 );
719
720 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" );
721 InputSlider->setTickmarks(QSlider::Both);
722 Layout15->addWidget( InputSlider);
723
724 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" );
725 OutputSlider->setTickmarks(QSlider::Both);
726
727 Layout15b->addWidget( OutputSlider );
728
729 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
730 Layout15->addWidget( outMuteCheckBox );
731
732 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
733 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
734 Layout15b->addWidget( inMuteCheckBox );
735
736
737 Layout19->addLayout( Layout15 );
738 Layout19->addLayout( Layout15b );
739
740 fillDirectoryCombo();
741
742 TabWidget->insertTab( tab_3, tr( "Options" ) );
743
744 }
745 704
746 waveform = new Waveform( this, "waveform" ); 705 waveform = new Waveform( this, "waveform" );
747// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); 706// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
748 waveform->setMinimumSize( QSize( 0, 50 ) ); 707 waveform->setMinimumSize( QSize( 0, 50 ) );
749 708
750 layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); 709 layout->addMultiCellWidget( waveform, 8, 8, 0, 7 );
751 waveform->setBackgroundColor ( black ); 710 waveform->setBackgroundColor ( black );
752} 711}
753 712
754void QtRec::initIconView() { 713void QtRec::initIconView() {
755 714
756 ListView1->clear(); 715 ListView1->clear();
757 Config cfg("OpieRec"); 716 Config cfg("OpieRec");
758 cfg.setGroup("Sounds"); 717 cfg.setGroup("Sounds");
759 QString temp; 718 QString temp;
760 QPixmap image0( ( const char** ) image0_data ); 719 QPixmap image0( ( const char** ) image0_data );
761 720
762 int nFiles = cfg.readNumEntry("NumberofFiles",0); 721 int nFiles = cfg.readNumEntry("NumberofFiles",0);
763 qDebug("init number of files %d", nFiles); 722 // qDebug("init number of files %d", nFiles);
764 723
765 for(int i=1;i<= nFiles;i++) { 724 for(int i=1;i<= nFiles;i++) {
766 725
767 QListViewItem * item; 726 QListViewItem * item;
768 QString fileS, mediaLocation, fileDate, filePath; 727 QString fileS, mediaLocation, fileDate, filePath;
769 728
770 temp.sprintf( "%d",i); 729 temp.sprintf( "%d",i);
771 temp = cfg.readEntry( temp,""); //reads currentFile 730 temp = cfg.readEntry( temp,""); //reads currentFile
772 filePath = cfg.readEntry( temp,""); //currentFileName 731 filePath = cfg.readEntry( temp,""); //currentFileName
773 732
774 QFileInfo info(filePath); 733 QFileInfo info(filePath);
775 fileDate = info.lastModified().toString(); 734 fileDate = info.lastModified().toString();
@@ -999,34 +958,38 @@ bool QtRec::rec() { //record
999 tr("Low Disk Space"), 958 tr("Low Disk Space"),
1000 tr("You are running low of\nrecording space\n" 959 tr("You are running low of\nrecording space\n"
1001 "or a card isn't being recognized")); 960 "or a card isn't being recognized"));
1002 stopped = true; //we need to be stopped 961 stopped = true; //we need to be stopped
1003 stop(); 962 stop();
1004 } else { 963 } else {
1005 QString msg; 964 QString msg;
1006 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 965 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1007#ifdef DEV_VERSION 966#ifdef DEV_VERSION
1008 setCaption( msg); 967 setCaption( msg);
1009#endif 968#endif
1010 filePara.fileName=currentFile.latin1(); 969 filePara.fileName=currentFile.latin1();
1011// qDebug("Start recording thread"); 970 qDebug("Start recording thread");
1012 stopped = false; 971 stopped = false;
1013 972
1014// pthread_t thread1; 973#ifdef THREADED
1015// pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 974 pthread_t thread1;
975 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
976#endif
1016 toBeginningButton->setEnabled( false); 977 toBeginningButton->setEnabled( false);
1017 toEndButton->setEnabled( false); 978 toEndButton->setEnabled( false);
1018 979
1019 startTimer(1000); 980 startTimer(1000);
981#ifndef THREADED
1020 quickRec(); 982 quickRec();
983#endif
1021 } 984 }
1022 } //end setUpFile 985 } //end setUpFile
1023 } //end setupAudio 986 } //end setupAudio
1024 return true; 987 return true;
1025} 988}
1026/* 989/*
1027 This happens when a tab is selected*/ 990 This happens when a tab is selected*/
1028void QtRec::thisTab(QWidget* widg) { 991void QtRec::thisTab(QWidget* widg) {
1029 if(widg != NULL) { 992 if(widg != NULL) {
1030 int index = TabWidget->currentPageIndex(); 993 int index = TabWidget->currentPageIndex();
1031 994
1032 if(index == 0) { //file page 995 if(index == 0) { //file page
@@ -1061,59 +1024,61 @@ void QtRec::getInVol() {
1061void QtRec::changedOutVolume() { 1024void QtRec::changedOutVolume() {
1062 soundDevice->changedOutVolume( -OutputSlider->value()); 1025 soundDevice->changedOutVolume( -OutputSlider->value());
1063} 1026}
1064 1027
1065void QtRec::changedInVolume( ) { 1028void QtRec::changedInVolume( ) {
1066 soundDevice->changedInVolume( -InputSlider->value()); 1029 soundDevice->changedInVolume( -InputSlider->value());
1067} 1030}
1068 1031
1069 1032
1070bool QtRec::setupAudio( bool b) { 1033bool QtRec::setupAudio( bool b) {
1071 bool ok; 1034 bool ok;
1072 int sampleformat, stereo, flags; 1035 int sampleformat, stereo, flags;
1073 char * dspString, *mixerString; 1036 QString dspString, mixerString;
1074 1037
1075 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 1038 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
1076 1039
1040 if( !b) {
1041// we want to play
1077#ifdef PDAUDIO //ALSA 1042#ifdef PDAUDIO //ALSA
1078 if( !b) { // we want to play
1079 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1043 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1080 sampleformat = SND_PCM_FORMAT_S16; 1044 sampleformat = SND_PCM_FORMAT_S16;
1081 filePara.resolution = 16; 1045 filePara.resolution = 16;
1082 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { 1046 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) {
1083 sampleformat = SND_PCM_FORMAT_S24; 1047 sampleformat = SND_PCM_FORMAT_S24;
1084 filePara.resolution = 24; 1048 filePara.resolution = 24;
1085 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { 1049 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) {
1086 sampleformat = SND_PCM_FORMAT_S32; 1050 sampleformat = SND_PCM_FORMAT_S32;
1087 filePara.resolution = 32; 1051 filePara.resolution = 32;
1088 } else { 1052 } else {
1089 sampleformat = SND_PCM_FORMAT_U8; 1053 sampleformat = SND_PCM_FORMAT_U8;
1090 filePara.resolution = 8; 1054 filePara.resolution = 8;
1091 } 1055 }
1092#else 1056#else
1093 if( !b) {
1094// we want to play 1057// we want to play
1095 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1058 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1096 sampleformat = AFMT_S16_LE; 1059 sampleformat = AFMT_S16_LE;
1097 filePara.resolution = 16; 1060 filePara.resolution = 16;
1098 } else { 1061 } else {
1099 sampleformat = AFMT_U8; 1062 sampleformat = AFMT_U8;
1100 filePara.resolution = 8; 1063 filePara.resolution = 8;
1101 } 1064 }
1102#endif 1065#endif
1103 1066
1104 stereo = filePara.channels; 1067 stereo = filePara.channels;
1105 flags = O_WRONLY; 1068 flags = O_WRONLY;
1106 dspString = DSPSTROUT; 1069 Config hwcfg("OpieRec");
1107 mixerString = DSPSTRMIXEROUT; 1070 hwcfg.setGroup("Hardware");
1071 dspString = hwcfg.readEntry( "Audio", DSPSTROUT);
1072 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT);
1108 recording = false; 1073 recording = false;
1109 } else { // we want to record 1074 } else { // we want to record
1110 1075
1111#ifdef PDAUDIO //ALSA 1076#ifdef PDAUDIO //ALSA
1112 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1077 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1113 sampleformat = SND_PCM_FORMAT_S16; 1078 sampleformat = SND_PCM_FORMAT_S16;
1114 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") 1079 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
1115 sampleformat = SND_PCM_FORMAT_S24; 1080 sampleformat = SND_PCM_FORMAT_S24;
1116 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") 1081 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
1117 sampleformat = SND_PCM_FORMAT_S32; 1082 sampleformat = SND_PCM_FORMAT_S32;
1118 else 1083 else
1119 sampleformat = SND_PCM_FORMAT_U8; 1084 sampleformat = SND_PCM_FORMAT_U8;
@@ -1129,26 +1094,28 @@ bool QtRec::setupAudio( bool b) {
1129// qDebug("WAVE_FORMAT_PCM"); 1094// qDebug("WAVE_FORMAT_PCM");
1130 } else { 1095 } else {
1131 filePara.format = WAVE_FORMAT_DVI_ADPCM; 1096 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1132 sampleformat = AFMT_S16_LE; 1097 sampleformat = AFMT_S16_LE;
1133// qDebug("WAVE_FORMAT_DVI_ADPCM"); 1098// qDebug("WAVE_FORMAT_DVI_ADPCM");
1134 } 1099 }
1135#endif 1100#endif
1136 1101
1137 stereo = filePara.channels; 1102 stereo = filePara.channels;
1138// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1103// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1139 flags= O_RDWR; 1104 flags= O_RDWR;
1140// flags= O_RDONLY; 1105// flags= O_RDONLY;
1141 dspString = DSPSTRIN; 1106 Config hwcfg("OpieRec");
1142 mixerString = DSPSTRMIXEROUT; 1107 hwcfg.setGroup("Hardware");
1108 dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
1109 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
1143 recording = true; 1110 recording = true;
1144 } 1111 }
1145 1112
1146 // if(soundDevice) delete soundDevice; 1113 // if(soundDevice) delete soundDevice;
1147 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); 1114 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat);
1148 qWarning("change waveform settings"); 1115 qWarning("change waveform settings");
1149 waveform->changeSettings( filePara.sampleRate, filePara.channels ); 1116 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1150 1117
1151 soundDevice = new Device( this, dspString, mixerString, b); 1118 soundDevice = new Device( this, dspString, mixerString, b);
1152// soundDevice->openDsp(); 1119// soundDevice->openDsp();
1153 soundDevice->reset(); 1120 soundDevice->reset();
1154 1121
@@ -1211,44 +1178,47 @@ bool QtRec::doPlay() {
1211 paused = false; 1178 paused = false;
1212 secCount = (int)filePara.numberOfRecordedSeconds; 1179 secCount = (int)filePara.numberOfRecordedSeconds;
1213 } 1180 }
1214 playing = true; 1181 playing = true;
1215 stopped = false; 1182 stopped = false;
1216 recording = false; 1183 recording = false;
1217 1184
1218 QString num; 1185 QString num;
1219 qDebug( "Play number of samples %d", filePara.numberSamples); 1186 qDebug( "Play number of samples %d", filePara.numberSamples);
1220 1187
1221// timeSlider->setRange( 0, filePara.numberSamples); 1188// timeSlider->setRange( 0, filePara.numberSamples);
1222 1189
1223 timeString.sprintf("%d", filePara.numberOfRecordedSeconds); 1190 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1224 timeLabel->setText( timeString+ tr(" seconds")); 1191 timeLabel->setText( timeString+ tr(" seconds"));
1225 1192
1226 QString msg; 1193 QString msg;
1227 msg.sprintf("%d, %d, %d", 1194 msg.sprintf("%d, %d, %d",
1228 filePara.sampleRate, 1195 filePara.sampleRate,
1229 filePara.channels, 1196 filePara.channels,
1230 filePara.resolution); 1197 filePara.resolution);
1231#ifdef DEV_VERSION 1198#ifdef DEV_VERSION
1232 setCaption( msg); 1199 setCaption( msg);
1233#endif 1200#endif
1234 1201
1235 startTimer( 1000); 1202 startTimer( 1000);
1236// pthread_t thread2; 1203#ifdef THREADED
1237// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1204 pthread_t thread2;
1205 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1206#endif
1238 1207
1239 toBeginningButton->setEnabled( false); 1208 toBeginningButton->setEnabled( false);
1240 toEndButton->setEnabled( false); 1209 toEndButton->setEnabled( false);
1210#ifndef THREADED
1241 playIt(); 1211 playIt();
1242 1212#endif
1243 return true; 1213 return true;
1244} 1214}
1245 1215
1246 1216
1247void QtRec::changebitrateCombo(int i) { 1217void QtRec::changebitrateCombo(int i) {
1248 Config cfg("OpieRec"); 1218 Config cfg("OpieRec");
1249 cfg.setGroup("Settings"); 1219 cfg.setGroup("Settings");
1250 int bits = 0; 1220 int bits = 0;
1251 if( i == 1) { bits = 16; } 1221 if( i == 1) { bits = 16; }
1252 else if( i == 2) { bits = 24; } 1222 else if( i == 2) { bits = 24; }
1253 else if( i == 3) { bits = 32; } 1223 else if( i == 3) { bits = 32; }
1254 else { bits=8; } 1224 else { bits=8; }
@@ -1857,25 +1827,25 @@ long QtRec::checkDiskSpace(const QString &path) {
1857// long f_files; /* Total number of file nodes */ 1827// long f_files; /* Total number of file nodes */
1858// long f_ffree; /* Count of free file nodes */ 1828// long f_ffree; /* Count of free file nodes */
1859// char f_fname[6]; /* Volumename */ 1829// char f_fname[6]; /* Volumename */
1860// char f_fpack[6]; /* Pack name */ 1830// char f_fpack[6]; /* Pack name */
1861 1831
1862void QtRec::receive( const QCString &msg, const QByteArray & ) { 1832void QtRec::receive( const QCString &msg, const QByteArray & ) {
1863 qDebug("Voicerecord received message "+msg); 1833 qDebug("Voicerecord received message "+msg);
1864 1834
1865} 1835}
1866 1836
1867 1837
1868///////////////////////////// timerEvent 1838///////////////////////////// timerEvent
1869void QtRec::timerEvent( QTimerEvent *e ) { 1839void QtRec::timerEvent( QTimerEvent * ) {
1870 1840
1871// if(!recording) 1841// if(!recording)
1872// timeSlider->setValue( secCount); 1842// timeSlider->setValue( secCount);
1873// else 1843// else
1874// timeSlider->setValue( filePara.numberOfRecordedSeconds); 1844// timeSlider->setValue( filePara.numberOfRecordedSeconds);
1875 1845
1876 if( stopped && playing) { 1846 if( stopped && playing) {
1877 stop(); 1847 stop();
1878 } 1848 }
1879 1849
1880 if( stopped && recording ){ 1850 if( stopped && recording ){
1881 stop(); 1851 stop();
@@ -2151,12 +2121,13 @@ void QtRec::selectItemByName(const QString & name) {
2151void QtRec::changeStereoCheck(bool b) { 2121void QtRec::changeStereoCheck(bool b) {
2152 Config cfg("OpieRec"); 2122 Config cfg("OpieRec");
2153 cfg.setGroup("Settings"); 2123 cfg.setGroup("Settings");
2154 int ch = 0; 2124 int ch = 0;
2155 if ( !b) { ch = 1;} 2125 if ( !b) { ch = 1;}
2156 else { ch = 2;} 2126 else { ch = 2;}
2157 cfg.writeEntry("stereo", b); 2127 cfg.writeEntry("stereo", b);
2158 filePara.channels = ch; 2128 filePara.channels = ch;
2159 2129
2160 cfg.write(); 2130 cfg.write();
2161} 2131}
2162 2132
2133
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h
index 31cff9e..5878d37 100644
--- a/noncore/multimedia/opierec/qtrec.h
+++ b/noncore/multimedia/opierec/qtrec.h
@@ -168,18 +168,20 @@ protected:
168 bool doPlay(); 168 bool doPlay();
169 bool openPlayFile(); 169 bool openPlayFile();
170 bool setUpFile(); 170 bool setUpFile();
171 bool setupAudio( bool b); 171 bool setupAudio( bool b);
172 void endPlaying(); 172 void endPlaying();
173 void endRecording(); 173 void endRecording();
174 void fileBeamFinished( Ir *ir); 174 void fileBeamFinished( Ir *ir);
175 void initIconView(); 175 void initIconView();
176 void keyPressEvent( QKeyEvent *e); 176 void keyPressEvent( QKeyEvent *e);
177 void keyReleaseEvent( QKeyEvent *e); 177 void keyReleaseEvent( QKeyEvent *e);
178 void receive( const QCString &, const QByteArray & ); 178 void receive( const QCString &, const QByteArray & );
179 void showListMenu(QListViewItem * ); 179 void showListMenu(QListViewItem * );
180#ifndef THREADED
180 void quickRec(); 181 void quickRec();
181 void playIt(); 182 void playIt();
183#endif
182 184
183}; 185};
184 186
185#endif // QTREC_H 187#endif // QTREC_H