-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 8a0f8db..28f6546 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -189,33 +189,33 @@ void quickRec() { | |||
189 | // filePara.fileName); | 189 | // filePara.fileName); |
190 | return; | 190 | return; |
191 | } | 191 | } |
192 | //if(stereo == 2) { | 192 | //if(stereo == 2) { |
193 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 193 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
194 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 194 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
195 | 195 | ||
196 | bytesWritten = ::write( filePara.fd , abuf, number/4); | 196 | bytesWritten = ::write( filePara.fd , abuf, number/4); |
197 | 197 | ||
198 | long peak; | 198 | long peak; |
199 | for (int i = 0; i < number; i++) | 199 | for (int i = 0; i < number; i++) |
200 | { //since Z is mono do normally | 200 | { //since Z is mono do normally |
201 | peak = findPeak((long)sbuf[i]); | 201 | peak = findPeak((long)sbuf[i]); |
202 | printf("peak %ld\r",peak); | 202 | printf("peak %ld\r",peak); |
203 | fflush(stdout); | 203 | fflush(stdout); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | //------------->>>> out to file | 207 | //------------->>>> out to file |
208 | // if(filePara.channels==1) | 208 | // if(filePara.channels==1) |
209 | // total += bytesWritten/2; //mono | 209 | // total += bytesWritten/2; //mono |
210 | // else | 210 | // else |
211 | total += bytesWritten; | 211 | total += bytesWritten; |
212 | filePara.numberSamples = total; | 212 | filePara.numberSamples = total; |
213 | // if( total >= filePara.samplesToRecord) | 213 | // if( total >= filePara.samplesToRecord) |
214 | // timeSlider->setValue(0); | 214 | // timeSlider->setValue(0); |
215 | // else if( filePara.SecondsToRecord !=0) | 215 | // else if( filePara.SecondsToRecord !=0) |
216 | timeSlider->setValue( total); | 216 | timeSlider->setValue( total); |
217 | 217 | ||
218 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; | 218 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; |
219 | 219 | ||
220 | // printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n", | 220 | // printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n", |
221 | // number, | 221 | // number, |
@@ -267,43 +267,43 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please | |||
267 | // errorStop(); | 267 | // errorStop(); |
268 | perror("File writing error "); | 268 | perror("File writing error "); |
269 | return;// false; | 269 | return;// false; |
270 | } | 270 | } |
271 | 271 | ||
272 | // if(filePara.channels==1) | 272 | // if(filePara.channels==1) |
273 | // total += bytesWritten/2; //mono | 273 | // total += bytesWritten/2; //mono |
274 | // else | 274 | // else |
275 | total += bytesWritten; | 275 | total += bytesWritten; |
276 | long peak; | 276 | long peak; |
277 | for (int i = 0; i < number; i++) | 277 | for (int i = 0; i < number; i++) |
278 | { //since Z is mono do normally | 278 | { //since Z is mono do normally |
279 | peak = findPeak((long)inbuffer[i]); | 279 | peak = findPeak((long)inbuffer[i]); |
280 | printf("peak %ld\r",peak); | 280 | printf("peak %ld\r",peak); |
281 | fflush(stdout); | 281 | fflush(stdout); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | filePara.numberSamples = total; | 285 | filePara.numberSamples = total; |
286 | if(filePara.SecondsToRecord !=0) | 286 | if(filePara.SecondsToRecord !=0) |
287 | timeSlider->setValue( total); | 287 | timeSlider->setValue( total); |
288 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); | 288 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); |
289 | // fflush(stdout); | 289 | // fflush(stdout); |
290 | 290 | ||
291 | ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); | 291 | ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); |
292 | // qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2); | 292 | // qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2); |
293 | 293 | ||
294 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; | 294 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; |
295 | 295 | ||
296 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 296 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
297 | timeLabel->setText( timeString + " seconds"); | 297 | timeLabel->setText( timeString + " seconds"); |
298 | 298 | ||
299 | qApp->processEvents(); | 299 | qApp->processEvents(); |
300 | if( total >= filePara.samplesToRecord) | 300 | if( total >= filePara.samplesToRecord) |
301 | break; | 301 | break; |
302 | } | 302 | } |
303 | } //end main loop | 303 | } //end main loop |
304 | 304 | ||
305 | } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; | 305 | } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; |
306 | unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; | 306 | unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; |
307 | memset( unsigned_inbuffer, 0, BUFSIZE); | 307 | memset( unsigned_inbuffer, 0, BUFSIZE); |
308 | memset( unsigned_outbuffer, 0, BUFSIZE); | 308 | memset( unsigned_outbuffer, 0, BUFSIZE); |
309 | 309 | ||
@@ -545,33 +545,33 @@ void QtRec::init() { | |||
545 | Layout17 = new QHBoxLayout(this); | 545 | Layout17 = new QHBoxLayout(this); |
546 | Layout17->setSpacing( 2 ); | 546 | Layout17->setSpacing( 2 ); |
547 | Layout17->setMargin( 0 ); | 547 | Layout17->setMargin( 0 ); |
548 | 548 | ||
549 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 549 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
550 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 550 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
551 | sampleGroup->setFixedSize( 95,50); | 551 | sampleGroup->setFixedSize( 95,50); |
552 | 552 | ||
553 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 553 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
554 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 554 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
555 | //#ifndef QT_QWS_EBX | 555 | //#ifndef QT_QWS_EBX |
556 | sampleRateComboBox->insertItem( tr( "44100")); | 556 | sampleRateComboBox->insertItem( tr( "44100")); |
557 | sampleRateComboBox->insertItem( tr( "32000")); | 557 | sampleRateComboBox->insertItem( tr( "32000")); |
558 | //#endif | 558 | //#endif |
559 | sampleRateComboBox->insertItem( tr( "22050")); | 559 | sampleRateComboBox->insertItem( tr( "22050")); |
560 | //#ifndef QT_QWS_VERCEL_IDR | 560 | //#ifndef QT_QWS_VERCEL_IDR |
561 | sampleRateComboBox->insertItem( tr( "16000")); | 561 | sampleRateComboBox->insertItem( tr( "16000")); |
562 | sampleRateComboBox->insertItem( tr( "11025")); | 562 | sampleRateComboBox->insertItem( tr( "11025")); |
563 | sampleRateComboBox->insertItem( tr( "8000")); | 563 | sampleRateComboBox->insertItem( tr( "8000")); |
564 | //#endif | 564 | //#endif |
565 | 565 | ||
566 | Layout17->addWidget( sampleGroup ); | 566 | Layout17->addWidget( sampleGroup ); |
567 | 567 | ||
568 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 568 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
569 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 569 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
570 | sizeGroup->setFixedSize(80,50); | 570 | sizeGroup->setFixedSize(80,50); |
571 | 571 | ||
572 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 572 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
573 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); | 573 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); |
574 | sizeLimitCombo->insertItem(tr("Unlimited")); | 574 | sizeLimitCombo->insertItem(tr("Unlimited")); |
575 | for(int i=1;i<13; i++) { | 575 | for(int i=1;i<13; i++) { |
576 | sizeLimitCombo->insertItem( QString::number(i*5)); | 576 | sizeLimitCombo->insertItem( QString::number(i*5)); |
577 | } | 577 | } |
@@ -714,56 +714,56 @@ void QtRec::init() { | |||
714 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | 714 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); |
715 | Layout15b->addWidget( inMuteCheckBox ); | 715 | Layout15b->addWidget( inMuteCheckBox ); |
716 | 716 | ||
717 | 717 | ||
718 | Layout19->addLayout( Layout15 ); | 718 | Layout19->addLayout( Layout15 ); |
719 | Layout19->addLayout( Layout15b ); | 719 | Layout19->addLayout( Layout15b ); |
720 | 720 | ||
721 | fillDirectoryCombo(); | 721 | fillDirectoryCombo(); |
722 | 722 | ||
723 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | 723 | TabWidget->insertTab( tab_3, tr( "Options" ) ); |
724 | 724 | ||
725 | } | 725 | } |
726 | 726 | ||
727 | 727 | ||
728 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 728 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
729 | 729 | ||
730 | tab_4 = new QWidget( TabWidget, "tab_4" ); | 730 | // tab_4 = new QWidget( TabWidget, "tab_4" ); |
731 | QGridLayout *layout4 = new QGridLayout( tab_4); | 731 | // QGridLayout *layout4 = new QGridLayout( tab_4); |
732 | layout4->setSpacing( 2); | 732 | // layout4->setSpacing( 2); |
733 | layout4->setMargin( 2); | 733 | // layout4->setMargin( 2); |
734 | TabWidget->insertTab( tab_4, tr( "Help")); | 734 | // TabWidget->insertTab( tab_4, tr( "Help")); |
735 | 735 | ||
736 | ///////////////////////////////////////////// FIXME change to a real helpfile path | 736 | // ///////////////////////////////////////////// FIXME change to a real helpfile path |
737 | QString url="/index.html"; | 737 | // QString url="/index.html"; |
738 | HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help"); | 738 | // HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help"); |
739 | layout4->addMultiCellWidget( help, 0, 1, 0, 1); | 739 | // layout4->addMultiCellWidget( help, 0, 1, 0, 1); |
740 | if( !QFile(url).exists()) { | 740 | // if( !QFile(url).exists()) { |
741 | help->hide(); | 741 | // help->hide(); |
742 | //help->showMaximized(); | 742 | // //help->showMaximized(); |
743 | QLabel *helpLabel; | 743 | // QLabel *helpLabel; |
744 | helpLabel = new QLabel( tab_4, "TimeLabel" ); | 744 | // helpLabel = new QLabel( tab_4, "TimeLabel" ); |
745 | layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 ); | 745 | // layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 ); |
746 | helpLabel->setText( "<B>OpieRec</B><br>" | 746 | // helpLabel->setText( "<B>OpieRec</B><br>" |
747 | "Records files in standard wav format<br>" | 747 | // "Records files in standard wav format<br>" |
748 | "or a compressed version<br>" | 748 | // "or a compressed version<br>" |
749 | "For help, please email the author<br>" | 749 | // "For help, please email the author<br>" |
750 | "<B>OpieRec</B> is copyright© 2002 by" | 750 | // "<B>OpieRec</B> is copyright© 2002 by" |
751 | " L.J. Potter<br>llornkcor@handhelds.org<BR>" | 751 | // " L.J. Potter<br>llornkcor@handhelds.org<BR>" |
752 | "and is licensed under the <B>QPL</B>"); | 752 | // "and is licensed under the <B>QPL</B>"); |
753 | } | 753 | // } |
754 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 754 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
755 | 755 | ||
756 | } | 756 | } |
757 | 757 | ||
758 | void QtRec::initIconView() { | 758 | void QtRec::initIconView() { |
759 | 759 | ||
760 | ListView1->clear(); | 760 | ListView1->clear(); |
761 | Config cfg("OpieRec"); | 761 | Config cfg("OpieRec"); |
762 | cfg.setGroup("Sounds"); | 762 | cfg.setGroup("Sounds"); |
763 | QString temp; | 763 | QString temp; |
764 | QPixmap image0( ( const char** ) image0_data ); | 764 | QPixmap image0( ( const char** ) image0_data ); |
765 | 765 | ||
766 | 766 | ||
767 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 767 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
768 | for(int i=1;i<= nFiles;i++) { | 768 | for(int i=1;i<= nFiles;i++) { |
769 | 769 | ||
@@ -835,33 +835,33 @@ void QtRec::initConfig() { | |||
835 | filePara.sampleRate = fred; | 835 | filePara.sampleRate = fred; |
836 | sampleRateComboBox->setCurrentItem(ws); | 836 | sampleRateComboBox->setCurrentItem(ws); |
837 | } | 837 | } |
838 | } | 838 | } |
839 | 839 | ||
840 | i=cfg.readNumEntry("bitrate",16); | 840 | i=cfg.readNumEntry("bitrate",16); |
841 | if(i == 16) | 841 | if(i == 16) |
842 | bitRateComboBox->setCurrentItem( 0); | 842 | bitRateComboBox->setCurrentItem( 0); |
843 | else | 843 | else |
844 | bitRateComboBox->setCurrentItem( 1); | 844 | bitRateComboBox->setCurrentItem( 1); |
845 | filePara.resolution = i; | 845 | filePara.resolution = i; |
846 | 846 | ||
847 | i=cfg.readNumEntry("sizeLimit", 5 ); | 847 | i=cfg.readNumEntry("sizeLimit", 5 ); |
848 | QString temp; | 848 | QString temp; |
849 | // for(int i=1;i<13; i++) { | 849 | // for(int i=1;i<13; i++) { |
850 | // temp = sizeLimitCombo->text(i); | 850 | // temp = sizeLimitCombo->text(i); |
851 | 851 | ||
852 | // sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs")); | 852 | // sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs")); |
853 | // } | 853 | // } |
854 | sizeLimitCombo->setCurrentItem((i/5)); | 854 | sizeLimitCombo->setCurrentItem((i/5)); |
855 | 855 | ||
856 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 856 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
857 | if( compressionCheckBox->isChecked()) { | 857 | if( compressionCheckBox->isChecked()) { |
858 | bitRateComboBox->setEnabled(false); | 858 | bitRateComboBox->setEnabled(false); |
859 | bitRateComboBox->setCurrentItem(0); | 859 | bitRateComboBox->setCurrentItem(0); |
860 | filePara.resolution=16; | 860 | filePara.resolution=16; |
861 | } | 861 | } |
862 | 862 | ||
863 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 863 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
864 | if( autoMuteCheckBox->isChecked()) | 864 | if( autoMuteCheckBox->isChecked()) |
865 | slotAutoMute(true); | 865 | slotAutoMute(true); |
866 | else | 866 | else |
867 | slotAutoMute(false); | 867 | slotAutoMute(false); |
@@ -917,34 +917,34 @@ void QtRec::start() { //play | |||
917 | } | 917 | } |
918 | } | 918 | } |
919 | 919 | ||
920 | bool QtRec::rec() { //record | 920 | bool QtRec::rec() { //record |
921 | qDebug("rec()"); | 921 | qDebug("rec()"); |
922 | if(!stopped) { | 922 | if(!stopped) { |
923 | qDebug("rec:: !stopped"); | 923 | qDebug("rec:: !stopped"); |
924 | monitoring=true; | 924 | monitoring=true; |
925 | return false; | 925 | return false; |
926 | } else { | 926 | } else { |
927 | qDebug("go ahead and record"); | 927 | qDebug("go ahead and record"); |
928 | secCount=1; | 928 | secCount=1; |
929 | playLabel2->setText("Stop"); | 929 | playLabel2->setText("Stop"); |
930 | monitoring=false; | 930 | monitoring=false; |
931 | setRecordButton(true); | 931 | setRecordButton(true); |
932 | stopped=false; | 932 | stopped=false; |
933 | 933 | ||
934 | if( setupAudio( true)) | 934 | if( setupAudio( true)) |
935 | if(setUpFile()) { | 935 | if(setUpFile()) { |
936 | qDebug("Ok to start recording"); | 936 | qDebug("Ok to start recording"); |
937 | int fileSize=0; | 937 | int fileSize=0; |
938 | Config cfg("OpieRec"); | 938 | Config cfg("OpieRec"); |
939 | cfg.setGroup("Settings"); | 939 | cfg.setGroup("Settings"); |
940 | qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", | 940 | qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", |
941 | soundDevice->getDeviceBits(), | 941 | soundDevice->getDeviceBits(), |
942 | soundDevice->getDeviceRate(), | 942 | soundDevice->getDeviceRate(), |
943 | soundDevice->getDeviceChannels()); | 943 | soundDevice->getDeviceChannels()); |
944 | 944 | ||
945 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 945 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
946 | qDebug("sample rate is %d", filePara.sampleRate); | 946 | qDebug("sample rate is %d", filePara.sampleRate); |
947 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 947 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
948 | 948 | ||
949 | qDebug("size limit %d sec", filePara.SecondsToRecord); | 949 | qDebug("size limit %d sec", filePara.SecondsToRecord); |
950 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 950 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
@@ -987,33 +987,33 @@ bool QtRec::rec() { //record | |||
987 | setCaption( msg); | 987 | setCaption( msg); |
988 | #endif | 988 | #endif |
989 | filePara.fileName=currentFile.latin1(); | 989 | filePara.fileName=currentFile.latin1(); |
990 | qDebug("Start recording thread"); | 990 | qDebug("Start recording thread"); |
991 | 991 | ||
992 | pthread_t thread1; | 992 | pthread_t thread1; |
993 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 993 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
994 | // quickRec(); | 994 | // quickRec(); |
995 | toBeginningButton->setEnabled(false); | 995 | toBeginningButton->setEnabled(false); |
996 | toEndButton->setEnabled(false); | 996 | toEndButton->setEnabled(false); |
997 | 997 | ||
998 | startTimer(1000); | 998 | startTimer(1000); |
999 | } | 999 | } |
1000 | } //end setUpFile | 1000 | } //end setUpFile |
1001 | } //end setupAudio | 1001 | } //end setupAudio |
1002 | // _exit( 0); | 1002 | // _exit( 0); |
1003 | 1003 | ||
1004 | // ///* default: | 1004 | // ///* default: |
1005 | // // /* pid greater than zero is parent getting the child's pid */ | 1005 | // // /* pid greater than zero is parent getting the child's pid */ |
1006 | // /* printf("Child's pid is %d\n",pid); | 1006 | // /* printf("Child's pid is %d\n",pid); |
1007 | // waitpid( pid, &status, 0); | 1007 | // waitpid( pid, &status, 0); |
1008 | // printf("Child[%d] exited with status %d\n", pid, status);*/ | 1008 | // printf("Child[%d] exited with status %d\n", pid, status);*/ |
1009 | // while (wait(NULL) != pid) | 1009 | // while (wait(NULL) != pid) |
1010 | // ; | 1010 | // ; |
1011 | // printf("child %ld terminated normally, return status is zero\n", (long) pid); | 1011 | // printf("child %ld terminated normally, return status is zero\n", (long) pid); |
1012 | // endRecording(); | 1012 | // endRecording(); |
1013 | /* else { //device was not opened | 1013 | /* else { //device was not opened |
1014 | qDebug("Audio device open failed"); | 1014 | qDebug("Audio device open failed"); |
1015 | return false; | 1015 | return false; |
1016 | } | 1016 | } |
1017 | }*/ | 1017 | }*/ |
1018 | // } //end fork | 1018 | // } //end fork |
1019 | // } | 1019 | // } |
@@ -1103,43 +1103,43 @@ bool QtRec::setupAudio( bool b) { | |||
1103 | 1103 | ||
1104 | stereo = filePara.channels = 1; | 1104 | stereo = filePara.channels = 1; |
1105 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1105 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1106 | flags= O_RDWR; | 1106 | flags= O_RDWR; |
1107 | // flags= O_RDONLY; | 1107 | // flags= O_RDONLY; |
1108 | dspString = DSPSTRIN; | 1108 | dspString = DSPSTRIN; |
1109 | mixerString = DSPSTRMIXEROUT; | 1109 | mixerString = DSPSTRMIXEROUT; |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | // if(soundDevice) delete soundDevice; | 1112 | // if(soundDevice) delete soundDevice; |
1113 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); | 1113 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); |
1114 | soundDevice = new Device( this, dspString, mixerString, b); | 1114 | soundDevice = new Device( this, dspString, mixerString, b); |
1115 | // soundDevice->openDsp(); | 1115 | // soundDevice->openDsp(); |
1116 | soundDevice->reset(); | 1116 | soundDevice->reset(); |
1117 | 1117 | ||
1118 | qDebug("device has been made %d", soundDevice->sd); | 1118 | qDebug("device has been made %d", soundDevice->sd); |
1119 | 1119 | ||
1120 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | 1120 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> |
1121 | soundDevice->setDeviceFormat( sampleformat); | 1121 | soundDevice->setDeviceFormat( sampleformat); |
1122 | soundDevice->setDeviceChannels( filePara.channels); | 1122 | soundDevice->setDeviceChannels( filePara.channels); |
1123 | soundDevice->setDeviceRate( filePara.sampleRate); | 1123 | soundDevice->setDeviceRate( filePara.sampleRate); |
1124 | soundDevice->getDeviceFragSize(); | 1124 | soundDevice->getDeviceFragSize(); |
1125 | #ifdef QT_QWS_EBX | 1125 | #ifdef QT_QWS_EBX |
1126 | int frag = FRAGSIZE; | 1126 | int frag = FRAGSIZE; |
1127 | soundDevice->setFragSize( frag); | 1127 | soundDevice->setFragSize( frag); |
1128 | soundDevice->getDeviceFragSize(); | 1128 | soundDevice->getDeviceFragSize(); |
1129 | #endif | 1129 | #endif |
1130 | ///////////////// | 1130 | ///////////////// |
1131 | filePara.sd = soundDevice->sd; | 1131 | filePara.sd = soundDevice->sd; |
1132 | 1132 | ||
1133 | if ( filePara.sd == -1) { | 1133 | if ( filePara.sd == -1) { |
1134 | 1134 | ||
1135 | monitoring=false; | 1135 | monitoring=false; |
1136 | stopped=true; | 1136 | stopped=true; |
1137 | update(); | 1137 | update(); |
1138 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1138 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
1139 | stopped=true; | 1139 | stopped=true; |
1140 | return false; | 1140 | return false; |
1141 | } | 1141 | } |
1142 | if(autoMute) | 1142 | if(autoMute) |
1143 | doMute(false); | 1143 | doMute(false); |
1144 | 1144 | ||
1145 | return true; | 1145 | return true; |
@@ -1338,37 +1338,37 @@ void QtRec::changebitrateCombo(int i) { | |||
1338 | else { bits=8; } | 1338 | else { bits=8; } |
1339 | cfg.writeEntry("bitrate", bits); | 1339 | cfg.writeEntry("bitrate", bits); |
1340 | filePara.resolution=bits; | 1340 | filePara.resolution=bits; |
1341 | cfg.write(); | 1341 | cfg.write(); |
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | void QtRec::changesamplerateCombo(int i) { | 1344 | void QtRec::changesamplerateCombo(int i) { |
1345 | Config cfg("OpieRec"); | 1345 | Config cfg("OpieRec"); |
1346 | cfg.setGroup("Settings"); | 1346 | cfg.setGroup("Settings"); |
1347 | int rate=0; | 1347 | int rate=0; |
1348 | bool ok; | 1348 | bool ok; |
1349 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); | 1349 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); |
1350 | cfg.writeEntry("samplerate",rate); | 1350 | cfg.writeEntry("samplerate",rate); |
1351 | filePara.sampleRate=rate; | 1351 | filePara.sampleRate=rate; |
1352 | /* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false); | 1352 | /* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false); |
1353 | soundDevice->openDsp();*/ | 1353 | soundDevice->openDsp();*/ |
1354 | // | 1354 | // |
1355 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | 1355 | // soundDevice->setDeviceFormat(AFMT_S16_LE); |
1356 | // soundDevice->setDeviceChannels(filePara.channels); | 1356 | // soundDevice->setDeviceChannels(filePara.channels); |
1357 | // soundDevice->setDeviceRate(filePara.sampleRate); | 1357 | // soundDevice->setDeviceRate(filePara.sampleRate); |
1358 | // | 1358 | // |
1359 | // soundDevice->closeDevice( true); | 1359 | // soundDevice->closeDevice( true); |
1360 | // soundDevice=0; | 1360 | // soundDevice=0; |
1361 | // delete soundDevice; | 1361 | // delete soundDevice; |
1362 | qDebug("Change sample rate %d", rate); | 1362 | qDebug("Change sample rate %d", rate); |
1363 | cfg.write(); | 1363 | cfg.write(); |
1364 | 1364 | ||
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | 1367 | ||
1368 | void QtRec::changeDirCombo(int index) { | 1368 | void QtRec::changeDirCombo(int index) { |
1369 | Config cfg("OpieRec"); | 1369 | Config cfg("OpieRec"); |
1370 | cfg.setGroup("Settings"); | 1370 | cfg.setGroup("Settings"); |
1371 | QString sName = directoryComboBox->text(index); | 1371 | QString sName = directoryComboBox->text(index); |
1372 | 1372 | ||
1373 | StorageInfo storageInfo; | 1373 | StorageInfo storageInfo; |
1374 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1374 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
@@ -1976,33 +1976,33 @@ long QtRec::checkDiskSpace(const QString &path) { | |||
1976 | // long f_ffree; /* Count of free file nodes */ | 1976 | // long f_ffree; /* Count of free file nodes */ |
1977 | // char f_fname[6]; /* Volumename */ | 1977 | // char f_fname[6]; /* Volumename */ |
1978 | // char f_fpack[6]; /* Pack name */ | 1978 | // char f_fpack[6]; /* Pack name */ |
1979 | 1979 | ||
1980 | void QtRec::receive( const QCString &msg, const QByteArray & ) { | 1980 | void QtRec::receive( const QCString &msg, const QByteArray & ) { |
1981 | qDebug("Voicerecord received message "+msg); | 1981 | qDebug("Voicerecord received message "+msg); |
1982 | 1982 | ||
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | 1985 | ||
1986 | ///////////////////////////// timerEvent | 1986 | ///////////////////////////// timerEvent |
1987 | void QtRec::timerEvent( QTimerEvent *e ) { | 1987 | void QtRec::timerEvent( QTimerEvent *e ) { |
1988 | // qDebug( "%d", secCount ); | 1988 | // qDebug( "%d", secCount ); |
1989 | #ifdef DEV_VERSION | 1989 | #ifdef DEV_VERSION |
1990 | QString msg; | 1990 | QString msg; |
1991 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1991 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
1992 | setCaption( msg +" :: "+QString::number(secCount)); | 1992 | setCaption( msg +" :: "+QString::number(secCount)); |
1993 | #endif | 1993 | #endif |
1994 | 1994 | ||
1995 | if( !playing ) { | 1995 | if( !playing ) { |
1996 | if(!recording ){ | 1996 | if(!recording ){ |
1997 | killTimer(e->timerId()); | 1997 | killTimer(e->timerId()); |
1998 | ///* stopped=true; | 1998 | ///* stopped=true; |
1999 | // recording=false; | 1999 | // recording=false; |
2000 | ///*/ | 2000 | ///*/ |
2001 | // _exit( 0); | 2001 | // _exit( 0); |
2002 | } | 2002 | } |
2003 | if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) { | 2003 | if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) { |
2004 | killTimer(e->timerId()); | 2004 | killTimer(e->timerId()); |
2005 | stop(); | 2005 | stop(); |
2006 | } | 2006 | } |
2007 | } | 2007 | } |
2008 | // if( stopped && !paused) { | 2008 | // if( stopped && !paused) { |
@@ -2245,26 +2245,26 @@ long findPeak(long input ) { | |||
2245 | // halfLife = time in seconds for output to decay to half value after an impulse | 2245 | // halfLife = time in seconds for output to decay to half value after an impulse |
2246 | static float output = 0.0; | 2246 | static float output = 0.0; |
2247 | int halfLife = .25; | 2247 | int halfLife = .25; |
2248 | float vsf = .0025; | 2248 | float vsf = .0025; |
2249 | float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); | 2249 | float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); |
2250 | if( input < 0.0 ) | 2250 | if( input < 0.0 ) |
2251 | input = -input; // Absolute value. | 2251 | input = -input; // Absolute value. |
2252 | if ( input >= output ) | 2252 | if ( input >= output ) |
2253 | { | 2253 | { |
2254 | // When we hit a peak, ride the peak to the top. | 2254 | // When we hit a peak, ride the peak to the top. |
2255 | output = input; | 2255 | output = input; |
2256 | } | 2256 | } |
2257 | else | 2257 | else |
2258 | { | 2258 | { |
2259 | // Exponential decay of output when signal is low. | 2259 | // Exponential decay of output when signal is low. |
2260 | output = output * scalar; | 2260 | output = output * scalar; |
2261 | // | 2261 | // |
2262 | // When current gets close to 0.0, set current to 0.0 to prevent FP underflow | 2262 | // When current gets close to 0.0, set current to 0.0 to prevent FP underflow |
2263 | // which can cause a severe performance degradation due to a flood | 2263 | // which can cause a severe performance degradation due to a flood |
2264 | // of interrupts. | 2264 | // of interrupts. |
2265 | // | 2265 | // |
2266 | if( output < vsf ) output = 0.0; | 2266 | if( output < vsf ) output = 0.0; |
2267 | } | 2267 | } |
2268 | 2268 | ||
2269 | return output; | 2269 | return output; |
2270 | } | 2270 | } |