-rw-r--r-- | noncore/multimedia/opierec/main.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/opierec/opierec.pro | 30 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 121 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 7 | ||||
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 3 |
5 files changed, 127 insertions, 47 deletions
diff --git a/noncore/multimedia/opierec/main.cpp b/noncore/multimedia/opierec/main.cpp index e36d050..714907c 100644 --- a/noncore/multimedia/opierec/main.cpp +++ b/noncore/multimedia/opierec/main.cpp | |||
@@ -6,14 +6,25 @@ | |||
6 | /*************************************************************************** | 6 | /*************************************************************************** |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "qtrec.h" | 12 | #include "qtrec.h" |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | #include <opie/oapplicationfactory.h> | ||
15 | 14 | ||
15 | #ifdef PDAUDIO | ||
16 | int main(int argc, char* argv[]) { | ||
17 | QPEApplication a(argc, argv); | ||
18 | QtRec qtrec; | ||
19 | a.showMainWidget( &qtrec); | ||
20 | return a.exec(); | ||
21 | } | ||
22 | |||
23 | |||
24 | #else | ||
25 | #include <opie/oapplicationfactory.h> | ||
16 | OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) |
17 | 27 | ||
28 | #endif | ||
18 | 29 | ||
19 | 30 | ||
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro index b607c09..39fe493 100644 --- a/noncore/multimedia/opierec/opierec.pro +++ b/noncore/multimedia/opierec/opierec.pro | |||
@@ -1,26 +1,40 @@ | |||
1 | CONFIG = qt warn_on release | 1 | #CONFIG = qt qtopia warn_on release pdaudio |
2 | CONFIG = qt warn_on release opie | ||
2 | #CONFIG = qt warn_on release quick-app | 3 | #CONFIG = qt warn_on release quick-app |
3 | HEADERS = adpcm.h \ | 4 | HEADERS = adpcm.h \ |
4 | pixmaps.h \ | 5 | pixmaps.h \ |
5 | helpwindow.h \ | 6 | helpwindow.h \ |
6 | qtrec.h \ | 7 | qtrec.h \ |
7 | device.h \ | 8 | device.h \ |
8 | wavFile.h \ | 9 | wavFile.h \ |
9 | waveform.h | 10 | waveform.h |
10 | SOURCES = adpcm.c \ | 11 | SOURCES = adpcm.c \ |
11 | helpwindow.cpp \ | 12 | helpwindow.cpp \ |
12 | main.cpp \ | 13 | main.cpp \ |
13 | qtrec.cpp \ | 14 | qtrec.cpp \ |
14 | device.cpp \ | 15 | device.cpp \ |
15 | wavFile.cpp \ | 16 | wavFile.cpp \ |
16 | waveform.cpp | 17 | waveform.cpp |
17 | INCLUDEPATH += $(OPIEDIR)/include | ||
18 | DEPENDPATH += $(OPIEDIR)/include | ||
19 | #LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz | ||
20 | LIBS += -lqpe -lpthread | ||
21 | INTERFACES = | 18 | INTERFACES = |
22 | TARGET = opierec | ||
23 | DESTDIR=$(OPIEDIR)/bin | ||
24 | 19 | ||
25 | include ( $(OPIEDIR)/include.pro ) | 20 | contains(CONFIG, pdaudio) { |
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 | ||
23 | INCLUDEPATH += $(QPEDIR)/include | ||
24 | DEPENDPATH += $(QPEDIR)/include | ||
25 | DEFINES += PDAUDIO | ||
26 | TARGET = qperec | ||
27 | |||
28 | # DESTDIR=$(QPEDIR)/bin | ||
29 | } | ||
30 | |||
31 | contains(CONFIG, opie) { | ||
32 | INCLUDEPATH += $(OPIEDIR)/include | ||
33 | DEPENDPATH += $(OPIEDIR)/include | ||
34 | DESTDIR=$(OPIEDIR)/bin | ||
35 | LIBS += -lqpe -lpthread | ||
36 | TARGET = opierec | ||
37 | include ( $(OPIEDIR)/include.pro ) | ||
38 | } | ||
39 | |||
26 | 40 | ||
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index aeab26d..bc6abcc 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -51,16 +51,26 @@ extern "C" { | |||
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <sys/time.h> | 52 | #include <sys/time.h> |
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #include <sys/vfs.h> | 54 | #include <sys/vfs.h> |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | #include <sys/wait.h> | 56 | #include <sys/wait.h> |
57 | #include <sys/signal.h> | 57 | #include <sys/signal.h> |
58 | 58 | ||
59 | |||
60 | #ifdef PDAUDIO //ALSA | ||
61 | #include <alsa/asoundlib.h> | ||
62 | static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; | ||
63 | static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; | ||
64 | #else //OSS | ||
65 | static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; | ||
66 | static int deviceBitRates[] = { 8, 16, -1 }; | ||
67 | #endif | ||
68 | |||
59 | #if defined(QT_QWS_SL5XXX) | 69 | #if defined(QT_QWS_SL5XXX) |
60 | ///#if defined(QT_QWS_EBX) | 70 | ///#if defined(QT_QWS_EBX) |
61 | 71 | ||
62 | #define DSPSTROUT "/dev/dsp" | 72 | #define DSPSTROUT "/dev/dsp" |
63 | #define DSPSTRIN "/dev/dsp1" | 73 | #define DSPSTRIN "/dev/dsp1" |
64 | #define DSPSTRMIXEROUT "/dev/mixer" | 74 | #define DSPSTRMIXEROUT "/dev/mixer" |
65 | #define DSPSTRMIXERIN "/dev/mixer1" | 75 | #define DSPSTRMIXERIN "/dev/mixer1" |
66 | 76 | ||
@@ -103,19 +113,19 @@ QLabel *timeLabel; | |||
103 | QSlider *timeSlider; | 113 | QSlider *timeSlider; |
104 | int sd; | 114 | int sd; |
105 | 115 | ||
106 | Waveform* waveform; | 116 | Waveform* waveform; |
107 | Device *soundDevice; | 117 | Device *soundDevice; |
108 | 118 | ||
109 | // threaded recording | 119 | // threaded recording |
110 | //fuckin fulgy here | 120 | //fuckin fulgy here |
111 | void quickRec() | 121 | //void quickRec() |
112 | { | 122 | //{ |
113 | //void QtRec::quickRec() { | 123 | void QtRec::quickRec() { |
114 | 124 | ||
115 | qDebug("%d", | 125 | qDebug("%d", |
116 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | 126 | filePara.numberSamples/filePara.sampleRate * filePara.channels); |
117 | qDebug("samples %d, rate %d, channels %d", | 127 | qDebug("samples %d, rate %d, channels %d", |
118 | filePara.numberSamples, filePara.sampleRate, filePara.channels); | 128 | filePara.numberSamples, filePara.sampleRate, filePara.channels); |
119 | 129 | ||
120 | int total = 0; // Total number of bytes read in so far. | 130 | int total = 0; // Total number of bytes read in so far. |
121 | int bytesWritten, number; | 131 | int bytesWritten, number; |
@@ -158,18 +168,20 @@ void quickRec() | |||
158 | perror("recording error "); | 168 | perror("recording error "); |
159 | qDebug( "%s %d", filePara.fileName, number); | 169 | qDebug( "%s %d", filePara.fileName, number); |
160 | stopped = true; | 170 | stopped = true; |
161 | return; | 171 | return; |
162 | } | 172 | } |
163 | //if(stereo == 2) { | 173 | //if(stereo == 2) { |
164 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 174 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
165 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 175 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
166 | bytesWritten = soundDevice->devWrite( filePara.fd , (short *)abuf, number/4); | 176 | |
167 | waveform->newSamples( (const short *)abuf, bytesWritten ); | 177 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); |
178 | |||
179 | waveform->newSamples( (const short *)abuf, bytesWritten ); | ||
168 | 180 | ||
169 | total += bytesWritten; | 181 | total += bytesWritten; |
170 | filePara.numberSamples = total; | 182 | filePara.numberSamples = total; |
171 | timeSlider->setValue( total); | 183 | timeSlider->setValue( total); |
172 | 184 | ||
173 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; | 185 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; |
174 | 186 | ||
175 | qApp->processEvents(); | 187 | qApp->processEvents(); |
@@ -188,27 +200,27 @@ void quickRec() | |||
188 | for(;;) { | 200 | for(;;) { |
189 | if ( stopped) { | 201 | if ( stopped) { |
190 | qDebug("quickRec:: stopped"); | 202 | qDebug("quickRec:: stopped"); |
191 | stopped = true; | 203 | stopped = true; |
192 | break; // stop if playing was set to false | 204 | break; // stop if playing was set to false |
193 | return; | 205 | return; |
194 | } | 206 | } |
195 | 207 | ||
196 | number = soundDevice ->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); | 208 | number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); |
197 | waveform->newSamples( inbuffer, number ); | 209 | waveform->newSamples( inbuffer, number ); |
198 | 210 | ||
199 | if( number <= 0) { | 211 | if( number <= 0) { |
200 | perror( "recording error "); | 212 | perror( "recording error "); |
201 | qDebug( filePara.fileName); | 213 | qDebug( filePara.fileName); |
202 | stopped = true; | 214 | stopped = true; |
203 | return; | 215 | return; |
204 | } | 216 | } |
205 | 217 | ||
206 | bytesWritten = soundDevice->devWrite( filePara.fd , inbuffer, number); | 218 | bytesWritten = ::write( filePara.fd , inbuffer, number); |
207 | 219 | ||
208 | if( bytesWritten < 0) { | 220 | if( bytesWritten < 0) { |
209 | perror("File writing error "); | 221 | perror("File writing error "); |
210 | stopped = true; | 222 | stopped = true; |
211 | return; | 223 | return; |
212 | } | 224 | } |
213 | 225 | ||
214 | total += bytesWritten; | 226 | total += bytesWritten; |
@@ -265,18 +277,19 @@ void quickRec() | |||
265 | if( total >= filePara.samplesToRecord) { | 277 | if( total >= filePara.samplesToRecord) { |
266 | stopped = true; | 278 | stopped = true; |
267 | break; | 279 | break; |
268 | } | 280 | } |
269 | } //end main loop | 281 | } //end main loop |
270 | } | 282 | } |
271 | } /// END quickRec() | 283 | } /// END quickRec() |
272 | 284 | ||
285 | void QtRec::playIt() | ||
273 | 286 | ||
274 | void playIt() | 287 | //void playIt() |
275 | { | 288 | { |
276 | int bytesWritten, number; | 289 | int bytesWritten, number; |
277 | int total = 0; // Total number of bytes read in so far. | 290 | int total = 0; // Total number of bytes read in so far. |
278 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { | 291 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { |
279 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 292 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
280 | char abuf[ BUFSIZE / 2 ]; | 293 | char abuf[ BUFSIZE / 2 ]; |
281 | short sbuf[ BUFSIZE ]; | 294 | short sbuf[ BUFSIZE ]; |
282 | short sbuf2[ BUFSIZE * 2 ]; | 295 | short sbuf2[ BUFSIZE * 2 ]; |
@@ -564,25 +577,23 @@ void QtRec::init() { | |||
564 | //////////////////////////////////// | 577 | //////////////////////////////////// |
565 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 578 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
566 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 579 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
567 | sampleGroup->setFixedSize( 95,50); | 580 | sampleGroup->setFixedSize( 95,50); |
568 | 581 | ||
569 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 582 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
570 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 583 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
571 | //#ifndef QT_QWS_EBX | 584 | //#ifndef QT_QWS_EBX |
572 | sampleRateComboBox->insertItem( tr( "44100")); | 585 | QString s; |
573 | sampleRateComboBox->insertItem( tr( "32000")); | 586 | int z = 0; |
574 | //#endif | 587 | while( deviceSampleRates[z] != -1) { |
575 | sampleRateComboBox->insertItem( tr( "22050")); | 588 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); |
576 | //#ifndef QT_QWS_VERCEL_IDR | 589 | z++; |
577 | sampleRateComboBox->insertItem( tr( "16000")); | 590 | } |
578 | sampleRateComboBox->insertItem( tr( "11025")); | 591 | |
579 | sampleRateComboBox->insertItem( tr( "8000")); | ||
580 | //#endif | ||
581 | 592 | ||
582 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); | 593 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); |
583 | 594 | ||
584 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 595 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
585 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 596 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
586 | sizeGroup->setFixedSize( 80, 50); | 597 | sizeGroup->setFixedSize( 80, 50); |
587 | 598 | ||
588 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 599 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
@@ -604,19 +615,24 @@ void QtRec::init() { | |||
604 | 615 | ||
605 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); | 616 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); |
606 | 617 | ||
607 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); | 618 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); |
608 | bitGroup->setTitle( tr( "Bit Depth" ) ); | 619 | bitGroup->setTitle( tr( "Bit Depth" ) ); |
609 | bitGroup->setFixedSize( 65, 50); | 620 | bitGroup->setFixedSize( 65, 50); |
610 | 621 | ||
611 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); | 622 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); |
612 | bitRateComboBox->insertItem( tr( "16" ) ); | 623 | |
613 | bitRateComboBox->insertItem( tr( "8" ) ); | 624 | z = 0; |
614 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | 625 | while( deviceBitRates[z] != -1) { |
626 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); | ||
627 | z++; | ||
628 | } | ||
629 | |||
630 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | ||
615 | 631 | ||
616 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); | 632 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); |
617 | 633 | ||
618 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); | 634 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); |
619 | 635 | ||
620 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); | 636 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); |
621 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); | 637 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); |
622 | 638 | ||
@@ -839,20 +855,25 @@ void QtRec::initConfig() { | |||
839 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 855 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
840 | if( index == fred) { | 856 | if( index == fred) { |
841 | filePara.sampleRate = fred; | 857 | filePara.sampleRate = fred; |
842 | sampleRateComboBox->setCurrentItem(ws); | 858 | sampleRateComboBox->setCurrentItem(ws); |
843 | } | 859 | } |
844 | } | 860 | } |
845 | 861 | ||
846 | i = cfg.readNumEntry("bitrate",16); | 862 | i = cfg.readNumEntry("bitrate",16); |
847 | if(i == 16) | 863 | if(i == 16) |
848 | bitRateComboBox->setCurrentItem( 0); | 864 | bitRateComboBox->setCurrentItem( 1); |
849 | else | 865 | elseif(i == 24) |
850 | bitRateComboBox->setCurrentItem( 1); | 866 | bitRateComboBox->setCurrentItem( 2); |
867 | elseif(i == 32) | ||
868 | bitRateComboBox->setCurrentItem( 3); | ||
869 | else | ||
870 | bitRateComboBox->setCurrentItem( 0); | ||
871 | |||
851 | filePara.resolution = i; | 872 | filePara.resolution = i; |
852 | 873 | ||
853 | i = cfg.readNumEntry("sizeLimit", 5 ); | 874 | i = cfg.readNumEntry("sizeLimit", 5 ); |
854 | QString temp; | 875 | QString temp; |
855 | sizeLimitCombo->setCurrentItem((i/5)); | 876 | sizeLimitCombo->setCurrentItem((i/5)); |
856 | 877 | ||
857 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 878 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
858 | if( stereoCheckBox->isChecked()) { | 879 | if( stereoCheckBox->isChecked()) { |
@@ -985,23 +1006,23 @@ bool QtRec::rec() { //record | |||
985 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1006 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
986 | #ifdef DEV_VERSION | 1007 | #ifdef DEV_VERSION |
987 | setCaption( msg); | 1008 | setCaption( msg); |
988 | #endif | 1009 | #endif |
989 | filePara.fileName=currentFile.latin1(); | 1010 | filePara.fileName=currentFile.latin1(); |
990 | // qDebug("Start recording thread"); | 1011 | // qDebug("Start recording thread"); |
991 | stopped = false; | 1012 | stopped = false; |
992 | 1013 | ||
993 | pthread_t thread1; | 1014 | // pthread_t thread1; |
994 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 1015 | // pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
995 | toBeginningButton->setEnabled( false); | 1016 | toBeginningButton->setEnabled( false); |
996 | toEndButton->setEnabled( false); | 1017 | toEndButton->setEnabled( false); |
997 | 1018 | ||
998 | startTimer(1000); | 1019 | startTimer(1000); |
999 | // quickRec(); | 1020 | quickRec(); |
1000 | } | 1021 | } |
1001 | } //end setUpFile | 1022 | } //end setUpFile |
1002 | } //end setupAudio | 1023 | } //end setupAudio |
1003 | return true; | 1024 | return true; |
1004 | } | 1025 | } |
1005 | /* | 1026 | /* |
1006 | This happens when a tab is selected*/ | 1027 | This happens when a tab is selected*/ |
1007 | void QtRec::thisTab(QWidget* widg) { | 1028 | void QtRec::thisTab(QWidget* widg) { |
@@ -1048,47 +1069,76 @@ void QtRec::changedInVolume( ) { | |||
1048 | 1069 | ||
1049 | bool QtRec::setupAudio( bool b) { | 1070 | bool QtRec::setupAudio( bool b) { |
1050 | bool ok; | 1071 | bool ok; |
1051 | int sampleformat, stereo, flags; | 1072 | int sampleformat, stereo, flags; |
1052 | char * dspString, *mixerString; | 1073 | char * dspString, *mixerString; |
1053 | 1074 | ||
1054 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 | 1075 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 |
1055 | 1076 | ||
1077 | #ifdef PDAUDIO //ALSA | ||
1078 | if( !b) { // we want to play | ||
1079 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | ||
1080 | sampleformat = SND_PCM_FORMAT_S16; | ||
1081 | filePara.resolution = 16; | ||
1082 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { | ||
1083 | sampleformat = SND_PCM_FORMAT_S24; | ||
1084 | filePara.resolution = 24; | ||
1085 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { | ||
1086 | sampleformat = SND_PCM_FORMAT_S32; | ||
1087 | filePara.resolution = 32; | ||
1088 | } else { | ||
1089 | sampleformat = SND_PCM_FORMAT_U8; | ||
1090 | filePara.resolution = 8; | ||
1091 | } | ||
1092 | #else | ||
1056 | if( !b) { | 1093 | if( !b) { |
1057 | // we want to play | 1094 | // we want to play |
1058 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1095 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1059 | sampleformat = AFMT_S16_LE; | 1096 | sampleformat = AFMT_S16_LE; |
1060 | filePara.resolution = 16; | 1097 | filePara.resolution = 16; |
1061 | } else { | 1098 | } else { |
1062 | sampleformat = AFMT_U8; | 1099 | sampleformat = AFMT_U8; |
1063 | filePara.resolution = 8; | 1100 | filePara.resolution = 8; |
1064 | } | 1101 | } |
1065 | 1102 | #endif | |
1103 | |||
1066 | stereo = filePara.channels; | 1104 | stereo = filePara.channels; |
1067 | flags = O_WRONLY; | 1105 | flags = O_WRONLY; |
1068 | dspString = DSPSTROUT; | 1106 | dspString = DSPSTROUT; |
1069 | mixerString = DSPSTRMIXEROUT; | 1107 | mixerString = DSPSTRMIXEROUT; |
1070 | recording = false; | 1108 | recording = false; |
1071 | } else { // we want to record | 1109 | } else { // we want to record |
1072 | 1110 | ||
1073 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1111 | #ifdef PDAUDIO //ALSA |
1112 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | ||
1113 | sampleformat = SND_PCM_FORMAT_S16; | ||
1114 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") | ||
1115 | sampleformat = SND_PCM_FORMAT_S24; | ||
1116 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") | ||
1117 | sampleformat = SND_PCM_FORMAT_S32; | ||
1118 | else | ||
1119 | sampleformat = SND_PCM_FORMAT_U8; | ||
1120 | |||
1121 | #else | ||
1122 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | ||
1074 | sampleformat = AFMT_S16_LE; | 1123 | sampleformat = AFMT_S16_LE; |
1075 | else | 1124 | else |
1076 | sampleformat = AFMT_U8; | 1125 | sampleformat = AFMT_U8; |
1077 | 1126 | ||
1078 | if( !compressionCheckBox->isChecked()) { | 1127 | if( !compressionCheckBox->isChecked()) { |
1079 | filePara.format = WAVE_FORMAT_PCM; | 1128 | filePara.format = WAVE_FORMAT_PCM; |
1080 | // qDebug("WAVE_FORMAT_PCM"); | 1129 | // qDebug("WAVE_FORMAT_PCM"); |
1081 | } else { | 1130 | } else { |
1082 | filePara.format = WAVE_FORMAT_DVI_ADPCM; | 1131 | filePara.format = WAVE_FORMAT_DVI_ADPCM; |
1083 | sampleformat = AFMT_S16_LE; | 1132 | sampleformat = AFMT_S16_LE; |
1084 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 1133 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
1085 | } | 1134 | } |
1086 | 1135 | #endif | |
1136 | |||
1087 | stereo = filePara.channels; | 1137 | stereo = filePara.channels; |
1088 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1138 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1089 | flags= O_RDWR; | 1139 | flags= O_RDWR; |
1090 | // flags= O_RDONLY; | 1140 | // flags= O_RDONLY; |
1091 | dspString = DSPSTRIN; | 1141 | dspString = DSPSTRIN; |
1092 | mixerString = DSPSTRMIXEROUT; | 1142 | mixerString = DSPSTRMIXEROUT; |
1093 | recording = true; | 1143 | recording = true; |
1094 | } | 1144 | } |
@@ -1178,32 +1228,35 @@ bool QtRec::doPlay() { | |||
1178 | filePara.sampleRate, | 1228 | filePara.sampleRate, |
1179 | filePara.channels, | 1229 | filePara.channels, |
1180 | filePara.resolution); | 1230 | filePara.resolution); |
1181 | #ifdef DEV_VERSION | 1231 | #ifdef DEV_VERSION |
1182 | setCaption( msg); | 1232 | setCaption( msg); |
1183 | #endif | 1233 | #endif |
1184 | 1234 | ||
1185 | startTimer( 1000); | 1235 | startTimer( 1000); |
1186 | pthread_t thread2; | 1236 | // pthread_t thread2; |
1187 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | 1237 | // pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); |
1188 | 1238 | ||
1189 | toBeginningButton->setEnabled( false); | 1239 | toBeginningButton->setEnabled( false); |
1190 | toEndButton->setEnabled( false); | 1240 | toEndButton->setEnabled( false); |
1241 | playIt(); | ||
1191 | 1242 | ||
1192 | return true; | 1243 | return true; |
1193 | } | 1244 | } |
1194 | 1245 | ||
1195 | 1246 | ||
1196 | void QtRec::changebitrateCombo(int i) { | 1247 | void QtRec::changebitrateCombo(int i) { |
1197 | Config cfg("OpieRec"); | 1248 | Config cfg("OpieRec"); |
1198 | cfg.setGroup("Settings"); | 1249 | cfg.setGroup("Settings"); |
1199 | int bits = 0; | 1250 | int bits = 0; |
1200 | if( i == 0) { bits = 16; } | 1251 | if( i == 1) { bits = 16; } |
1201 | else { bits=8; } | 1252 | else if( i == 2) { bits = 24; } |
1253 | else if( i == 3) { bits = 32; } | ||
1254 | else { bits=8; } | ||
1202 | cfg.writeEntry("bitrate", bits); | 1255 | cfg.writeEntry("bitrate", bits); |
1203 | filePara.resolution = bits; | 1256 | filePara.resolution = bits; |
1204 | cfg.write(); | 1257 | cfg.write(); |
1205 | } | 1258 | } |
1206 | 1259 | ||
1207 | void QtRec::changesamplerateCombo(int i) { | 1260 | void QtRec::changesamplerateCombo(int i) { |
1208 | Config cfg("OpieRec"); | 1261 | Config cfg("OpieRec"); |
1209 | cfg.setGroup("Settings"); | 1262 | cfg.setGroup("Settings"); |
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h index 93b9b5f..31cff9e 100644 --- a/noncore/multimedia/opierec/qtrec.h +++ b/noncore/multimedia/opierec/qtrec.h | |||
@@ -1,15 +1,15 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Created: Thu Jan 17 11:19:45 2002 | 2 | ** Created: Thu Jan 17 11:19:45 2002 |
3 | copyright 2002 by L.J. Potter ljp@llornkcor.com | 3 | copyright 2002 by L.J. Potter ljp@llornkcor.com |
4 | ****************************************************************************/ | 4 | ****************************************************************************/ |
5 | #ifndef QTREC_H | 5 | #ifndef QTREC_H |
6 | #define QTREC_H | 6 | #define QTREC_H |
7 | #define VERSION 20030920 | 7 | #define VERSION 20040101 |
8 | 8 | ||
9 | #include <qpe/ir.h> | 9 | #include <qpe/ir.h> |
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qimage.h> | 12 | #include <qimage.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
15 | #include <qvariant.h> | 15 | #include <qvariant.h> |
@@ -172,13 +172,14 @@ protected: | |||
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 | // void quickRec(); | 180 | void quickRec(); |
181 | 181 | void playIt(); | |
182 | |||
182 | }; | 183 | }; |
183 | 184 | ||
184 | #endif // QTREC_H | 185 | #endif // QTREC_H |
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index 987fa32..1d58bb3 100644 --- a/noncore/multimedia/opierec/wavFile.cpp +++ b/noncore/multimedia/opierec/wavFile.cpp | |||
@@ -42,17 +42,18 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int | |||
42 | bool WavFile::newFile() { | 42 | bool WavFile::newFile() { |
43 | 43 | ||
44 | // qDebug("Set up new file"); | 44 | // qDebug("Set up new file"); |
45 | Config cfg("OpieRec"); | 45 | Config cfg("OpieRec"); |
46 | cfg.setGroup("Settings"); | 46 | cfg.setGroup("Settings"); |
47 | 47 | ||
48 | currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); | 48 | currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); |
49 | QString date; | 49 | QString date; |
50 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 50 | QDateTime dt = QDateTime::currentDateTime(); |
51 | date = dt.toString();//TimeString::dateString( QDateTime::currentDateTime(),false,true); | ||
51 | date.replace(QRegExp("'"),""); | 52 | date.replace(QRegExp("'"),""); |
52 | date.replace(QRegExp(" "),"_"); | 53 | date.replace(QRegExp(" "),"_"); |
53 | date.replace(QRegExp(":"),"."); | 54 | date.replace(QRegExp(":"),"."); |
54 | date.replace(QRegExp(","),""); | 55 | date.replace(QRegExp(","),""); |
55 | 56 | ||
56 | QString currentFile=date; | 57 | QString currentFile=date; |
57 | if(currentFileName.right(1).find("/",0,true) == -1) | 58 | if(currentFileName.right(1).find("/",0,true) == -1) |
58 | currentFileName += "/" + date; | 59 | currentFileName += "/" + date; |