Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 121 |
1 files changed, 28 insertions, 93 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 6793b4e..e827083 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -3,7 +3,7 @@ | |||
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 | #define DEV_VERSION | 6 | //#define DEV_VERSION |
7 | 7 | ||
8 | #include "pixmaps.h" | 8 | #include "pixmaps.h" |
9 | #include "qtrec.h" | 9 | #include "qtrec.h" |
@@ -63,35 +63,6 @@ static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; | |||
63 | static int deviceBitRates[] = { 8, 16, -1 }; | 63 | static int deviceBitRates[] = { 8, 16, -1 }; |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #if defined(QT_QWS_SL5XXX) | ||
67 | ///#if defined(QT_QWS_EBX) | ||
68 | |||
69 | #define DSPSTROUT "/dev/dsp" | ||
70 | #define DSPSTRMIXEROUT "/dev/mixer" | ||
71 | |||
72 | #ifdef SHARP | ||
73 | #define DSPSTRIN "/dev/dsp1" | ||
74 | #define DSPSTRMIXERIN "/dev/mixer1" | ||
75 | #else | ||
76 | #define DSPSTRIN "/dev/dsp" | ||
77 | #define DSPSTRMIXERIN "/dev/mixer" | ||
78 | #endif | ||
79 | |||
80 | #else | ||
81 | |||
82 | #ifdef QT_QWS_DEVFS | ||
83 | #define DSPSTROUT "/dev/sound/dsp" | ||
84 | #define DSPSTRIN "/dev/sound/dsp" | ||
85 | #define DSPSTRMIXERIN "/dev/sound/mixer" | ||
86 | #define DSPSTRMIXEROUT "/dev/sound/mixer" | ||
87 | #else | ||
88 | #define DSPSTROUT "/dev/dsp" | ||
89 | #define DSPSTRIN "/dev/dsp" | ||
90 | #define DSPSTRMIXERIN "/dev/mixer" | ||
91 | #define DSPSTRMIXEROUT "/dev/mixer" | ||
92 | #endif | ||
93 | |||
94 | #endif | ||
95 | 66 | ||
96 | //#define ZAURUS 0 | 67 | //#define ZAURUS 0 |
97 | struct adpcm_state encoder_state; | 68 | struct adpcm_state encoder_state; |
@@ -193,8 +164,8 @@ void quickRec() | |||
193 | filePara.numberSamples = total; | 164 | filePara.numberSamples = total; |
194 | timeSlider->setValue( total); | 165 | timeSlider->setValue( total); |
195 | 166 | ||
196 | printf("%d, bytes %d,total %d\r",number, bytesWritten, total); | 167 | printf("%d, bytes %d,total %d\r", number, bytesWritten, total); |
197 | fflush(stdout); | 168 | fflush(stdout); |
198 | 169 | ||
199 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; | 170 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; |
200 | 171 | ||
@@ -243,8 +214,8 @@ void quickRec() | |||
243 | 214 | ||
244 | if( filePara.SecondsToRecord != 0) | 215 | if( filePara.SecondsToRecord != 0) |
245 | timeSlider->setValue( total); | 216 | timeSlider->setValue( total); |
246 | printf("%d, bytes %d,total %d\r",number, bytesWritten , total); | 217 | printf("%d, bytes %d,total %d\r",number, bytesWritten , total); |
247 | fflush(stdout); | 218 | fflush(stdout); |
248 | 219 | ||
249 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate | 220 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate |
250 | / (float)2/filePara.channels; | 221 | / (float)2/filePara.channels; |
@@ -296,6 +267,7 @@ void quickRec() | |||
296 | } | 267 | } |
297 | } //end main loop | 268 | } //end main loop |
298 | } | 269 | } |
270 | printf("\n"); | ||
299 | } /// END quickRec() | 271 | } /// END quickRec() |
300 | 272 | ||
301 | 273 | ||
@@ -450,14 +422,7 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | |||
450 | hwcfg.setGroup("Hardware"); | 422 | hwcfg.setGroup("Hardware"); |
451 | 423 | ||
452 | 424 | ||
453 | soundDevice = new Device( this, | 425 | soundDevice = new Device( this, false); //open play |
454 | hwcfg.readEntry( "Audio",DSPSTROUT), | ||
455 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); | ||
456 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); | ||
457 | |||
458 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | ||
459 | // soundDevice->setDeviceChannels(1); | ||
460 | // soundDevice->setDeviceRate( 22050); | ||
461 | 426 | ||
462 | getInVol(); | 427 | getInVol(); |
463 | getOutVol(); | 428 | getOutVol(); |
@@ -504,7 +469,7 @@ void QtRec::init() { | |||
504 | QPixmap image6( ( const char** ) image6_data ); | 469 | QPixmap image6( ( const char** ) image6_data ); |
505 | 470 | ||
506 | stopped = true; | 471 | stopped = true; |
507 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 472 | setCaption( tr( "OpieRecord " )); |
508 | QGridLayout *layout = new QGridLayout( this ); | 473 | QGridLayout *layout = new QGridLayout( this ); |
509 | layout->setSpacing( 2); | 474 | layout->setSpacing( 2); |
510 | layout->setMargin( 2); | 475 | layout->setMargin( 2); |
@@ -576,21 +541,10 @@ void QtRec::init() { | |||
576 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); | 541 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); |
577 | 542 | ||
578 | ListView1->addColumn( tr( "Name" ) ); | 543 | ListView1->addColumn( tr( "Name" ) ); |
579 | // ListView1->setColumnWidth( 0, 140); | ||
580 | ListView1->setSorting( 1, false); | 544 | ListView1->setSorting( 1, false); |
581 | ListView1->addColumn( tr( "Time" ) ); //in seconds | 545 | ListView1->addColumn( tr( "Time" ) ); //in seconds |
582 | // ListView1->setColumnWidth( 1, -1); | ||
583 | // ListView1->addColumn( tr("Location") ); | ||
584 | // ListView1->setColumnWidth( 2, -1); | ||
585 | // ListView1->addColumn( tr("Date") ); | ||
586 | // ListView1->setColumnWidth( 3, -1); | ||
587 | ListView1->setColumnWidthMode(0, QListView::Maximum); | 546 | ListView1->setColumnWidthMode(0, QListView::Maximum); |
588 | // ListView1->setColumnWidthMode(1, QListView::Maximum); | ||
589 | |||
590 | // ListView1->setColumnWidthMode( 0, QListView::Manual); | ||
591 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); | 547 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); |
592 | // ListView1->setColumnAlignment( 2, QListView::AlignRight); | ||
593 | // ListView1->setColumnAlignment( 3, QListView::AlignLeft); | ||
594 | ListView1->setAllColumnsShowFocus( true ); | 548 | ListView1->setAllColumnsShowFocus( true ); |
595 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); | 549 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); |
596 | 550 | ||
@@ -608,7 +562,6 @@ void QtRec::init() { | |||
608 | 562 | ||
609 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 563 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
610 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 564 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
611 | //#ifndef QT_QWS_EBX | ||
612 | QString s; | 565 | QString s; |
613 | int z = 0; | 566 | int z = 0; |
614 | while( deviceSampleRates[z] != -1) { | 567 | while( deviceSampleRates[z] != -1) { |
@@ -717,9 +670,7 @@ void QtRec::init() { | |||
717 | 670 | ||
718 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 671 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
719 | 672 | ||
720 | |||
721 | waveform = new Waveform( this, "waveform" ); | 673 | waveform = new Waveform( this, "waveform" ); |
722 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); | ||
723 | waveform->setMinimumSize( QSize( 0, 50 ) ); | 674 | waveform->setMinimumSize( QSize( 0, 50 ) ); |
724 | 675 | ||
725 | layout->addMultiCellWidget( waveform, 8, 8, 0, 8); | 676 | layout->addMultiCellWidget( waveform, 8, 8, 0, 8); |
@@ -727,7 +678,6 @@ void QtRec::init() { | |||
727 | } | 678 | } |
728 | 679 | ||
729 | void QtRec::initIconView() { | 680 | void QtRec::initIconView() { |
730 | owarn << "initIconView" << oendl; | ||
731 | ListView1->clear(); | 681 | ListView1->clear(); |
732 | Config cfg("OpieRec"); | 682 | Config cfg("OpieRec"); |
733 | cfg.setGroup("Sounds"); | 683 | cfg.setGroup("Sounds"); |
@@ -735,7 +685,7 @@ void QtRec::initIconView() { | |||
735 | QPixmap image0( ( const char** ) image0_data ); | 685 | QPixmap image0( ( const char** ) image0_data ); |
736 | 686 | ||
737 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 687 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
738 | owarn << "init number of files " << nFiles << "" << oendl; | 688 | // owarn << "init number of files " << nFiles << "" << oendl; |
739 | 689 | ||
740 | for(int i = 1; i <= nFiles; i++) { | 690 | for(int i = 1; i <= nFiles; i++) { |
741 | 691 | ||
@@ -752,7 +702,7 @@ void QtRec::initIconView() { | |||
752 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds | 702 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds |
753 | mediaLocation = getStorage( filePath); | 703 | mediaLocation = getStorage( filePath); |
754 | if( info.exists()) { | 704 | if( info.exists()) { |
755 | owarn << "new item " << temp << oendl; | 705 | // owarn << "new item " << temp << oendl; |
756 | item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); | 706 | item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); |
757 | item->setPixmap( 0, image0); | 707 | item->setPixmap( 0, image0); |
758 | if( currentFileName == filePath) | 708 | if( currentFileName == filePath) |
@@ -856,7 +806,7 @@ void QtRec::initConfig() { | |||
856 | } | 806 | } |
857 | 807 | ||
858 | void QtRec::stop() { | 808 | void QtRec::stop() { |
859 | owarn << "STOP" << oendl; | 809 | // owarn << "STOP" << oendl; |
860 | setRecordButton(false); | 810 | setRecordButton(false); |
861 | 811 | ||
862 | if( !recording) | 812 | if( !recording) |
@@ -1061,10 +1011,6 @@ bool QtRec::setupAudio( bool b) { | |||
1061 | 1011 | ||
1062 | stereo = filePara.channels; | 1012 | stereo = filePara.channels; |
1063 | flags = O_WRONLY; | 1013 | flags = O_WRONLY; |
1064 | Config hwcfg("OpieRec"); | ||
1065 | hwcfg.setGroup("Hardware"); | ||
1066 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); | ||
1067 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); | ||
1068 | recording = false; | 1014 | recording = false; |
1069 | } else { // we want to record | 1015 | } else { // we want to record |
1070 | 1016 | ||
@@ -1098,19 +1044,15 @@ bool QtRec::setupAudio( bool b) { | |||
1098 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1044 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1099 | flags= O_RDWR; | 1045 | flags= O_RDWR; |
1100 | // flags= O_RDONLY; | 1046 | // flags= O_RDONLY; |
1101 | Config hwcfg("OpieRec"); | ||
1102 | hwcfg.setGroup("Hardware"); | ||
1103 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); | ||
1104 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); | ||
1105 | recording = true; | 1047 | recording = true; |
1106 | } | 1048 | } |
1107 | 1049 | ||
1108 | // if(soundDevice) delete soundDevice; | 1050 | // if(soundDevice) delete soundDevice; |
1109 | odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; | 1051 | odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; |
1110 | owarn << "change waveform settings" << oendl; | 1052 | // owarn << "change waveform settings" << oendl; |
1111 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1053 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1112 | 1054 | ||
1113 | soundDevice = new Device( this, dspString, mixerString, b); | 1055 | soundDevice = new Device( this, b); //open rec |
1114 | // soundDevice->openDsp(); | 1056 | // soundDevice->openDsp(); |
1115 | soundDevice->reset(); | 1057 | soundDevice->reset(); |
1116 | 1058 | ||
@@ -1281,13 +1223,13 @@ void QtRec::deleteSound() { | |||
1281 | cfg.setGroup("Sounds"); | 1223 | cfg.setGroup("Sounds"); |
1282 | if( ListView1->currentItem() == NULL) | 1224 | if( ListView1->currentItem() == NULL) |
1283 | return; | 1225 | return; |
1284 | #ifndef DEV_VERSION | 1226 | // #ifndef DEV_VERSION |
1285 | switch ( QMessageBox::warning(this,tr("Delete"), | 1227 | // switch ( QMessageBox::warning(this,tr("Delete"), |
1286 | tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), | 1228 | // tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), |
1287 | tr("Yes"),tr("No"),0,1,1) ) { | 1229 | // tr("Yes"),tr("No"),0,1,1) ) { |
1288 | case 0: | 1230 | // case 0: |
1289 | #endif | 1231 | // #endif |
1290 | { | 1232 | // { |
1291 | QString file = ListView1->currentItem()->text(0); | 1233 | QString file = ListView1->currentItem()->text(0); |
1292 | QString fileName; | 1234 | QString fileName; |
1293 | fileName = cfg.readEntry( file, ""); | 1235 | fileName = cfg.readEntry( file, ""); |
@@ -1320,12 +1262,7 @@ void QtRec::deleteSound() { | |||
1320 | ListView1->setSelected( ListView1->firstChild(), true); | 1262 | ListView1->setSelected( ListView1->firstChild(), true); |
1321 | initIconView(); | 1263 | initIconView(); |
1322 | update(); | 1264 | update(); |
1323 | } | 1265 | setCaption( tr( "OpieRecord " )); |
1324 | #ifndef DEV_VERSION | ||
1325 | }; | ||
1326 | #endif | ||
1327 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | ||
1328 | |||
1329 | } | 1266 | } |
1330 | 1267 | ||
1331 | void QtRec::keyPressEvent( QKeyEvent *e) { | 1268 | void QtRec::keyPressEvent( QKeyEvent *e) { |
@@ -1443,6 +1380,7 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) { | |||
1443 | } | 1380 | } |
1444 | 1381 | ||
1445 | void QtRec::endRecording() { | 1382 | void QtRec::endRecording() { |
1383 | |||
1446 | monitoring = false; | 1384 | monitoring = false; |
1447 | recording = false; | 1385 | recording = false; |
1448 | stopped = true; | 1386 | stopped = true; |
@@ -1503,6 +1441,8 @@ void QtRec::endRecording() { | |||
1503 | timeSlider->setValue(0); | 1441 | timeSlider->setValue(0); |
1504 | initIconView(); | 1442 | initIconView(); |
1505 | selectItemByName( currentFile); | 1443 | selectItemByName( currentFile); |
1444 | setCaption( tr( "OpieRecord " )); | ||
1445 | |||
1506 | } | 1446 | } |
1507 | 1447 | ||
1508 | void QtRec::endPlaying() { | 1448 | void QtRec::endPlaying() { |
@@ -1535,7 +1475,7 @@ void QtRec::endPlaying() { | |||
1535 | 1475 | ||
1536 | odebug << "track closed" << oendl; | 1476 | odebug << "track closed" << oendl; |
1537 | killTimers(); | 1477 | killTimers(); |
1538 | owarn << "reset slider" << oendl; | 1478 | // owarn << "reset slider" << oendl; |
1539 | timeSlider->setValue(0); | 1479 | timeSlider->setValue(0); |
1540 | 1480 | ||
1541 | // if(soundDevice) delete soundDevice; | 1481 | // if(soundDevice) delete soundDevice; |
@@ -1568,7 +1508,7 @@ bool QtRec::openPlayFile() { | |||
1568 | // if(!track.open(IO_ReadOnly)) { | 1508 | // if(!track.open(IO_ReadOnly)) { |
1569 | QString errorMsg = (QString)strerror(errno); | 1509 | QString errorMsg = (QString)strerror(errno); |
1570 | monitoring = false; | 1510 | monitoring = false; |
1571 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1511 | setCaption( tr( "OpieRecord " )); |
1572 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") | 1512 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") |
1573 | + errorMsg + "\n" + currentFile); | 1513 | + errorMsg + "\n" + currentFile); |
1574 | return false; | 1514 | return false; |
@@ -1585,7 +1525,7 @@ bool QtRec::openPlayFile() { | |||
1585 | odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; | 1525 | odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; |
1586 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); | 1526 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); |
1587 | 1527 | ||
1588 | owarn << "seconds " << sec << "" << oendl; | 1528 | // owarn << "seconds " << sec << "" << oendl; |
1589 | 1529 | ||
1590 | timeSlider->setRange(0, filePara.numberSamples ); | 1530 | timeSlider->setRange(0, filePara.numberSamples ); |
1591 | } | 1531 | } |
@@ -1602,7 +1542,7 @@ void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { | |||
1602 | cancelRename(); | 1542 | cancelRename(); |
1603 | 1543 | ||
1604 | currentFile = item->text(0); | 1544 | currentFile = item->text(0); |
1605 | setCaption( "OpieRecord " + currentFile); | 1545 | // setCaption( "OpieRecord " + currentFile); |
1606 | } | 1546 | } |
1607 | break; | 1547 | break; |
1608 | case 2: | 1548 | case 2: |
@@ -1852,11 +1792,6 @@ void QtRec::timerEvent( QTimerEvent * ) { | |||
1852 | 1792 | ||
1853 | odebug << "" << secCount << "" << oendl; | 1793 | odebug << "" << secCount << "" << oendl; |
1854 | QString timeString; | 1794 | QString timeString; |
1855 | #ifdef DEV_VERSION | ||
1856 | QString msg; | ||
1857 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | ||
1858 | setCaption( msg +" :: "+QString::number(secCount)); | ||
1859 | #endif | ||
1860 | 1795 | ||
1861 | timeString.sprintf("%d", secCount); | 1796 | timeString.sprintf("%d", secCount); |
1862 | // timeLabel->setText( timeString + " seconds"); | 1797 | // timeLabel->setText( timeString + " seconds"); |