author | llornkcor <llornkcor> | 2004-06-28 11:35:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-06-28 11:35:26 (UTC) |
commit | 6944350eaea708414b9c0ff26122d7b2d19cd8f5 (patch) (side-by-side diff) | |
tree | 725c3e90cd724a6f43c03bcdadfa40d88508aa34 | |
parent | dd7341867ccd9f9718c4d10698f5ee0d292dba24 (diff) | |
download | opie-6944350eaea708414b9c0ff26122d7b2d19cd8f5.zip opie-6944350eaea708414b9c0ff26122d7b2d19cd8f5.tar.gz opie-6944350eaea708414b9c0ff26122d7b2d19cd8f5.tar.bz2 |
fix up interface
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 137 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 2 |
2 files changed, 72 insertions, 67 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 3b8cb0d..fb2d819 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp @@ -73,8 +73,8 @@ static int deviceBitRates[] = { 8, 16, -1 }; #else -#define DSPSTROUT "/dev/dsp" -#define DSPSTRIN "/dev/dsp" +#define DSPSTROUT "/dev/dsp1" +#define DSPSTRIN "/dev/dsp1" #define DSPSTRMIXERIN "/dev/mixer" #define DSPSTRMIXEROUT "/dev/mixer" @@ -133,18 +133,18 @@ void quickRec() QString num; int level = 0; int threshold = 0; -// int bits = filePara.resolution; -// odebug << "bits " << bits << "" << oendl; + int bits = filePara.resolution; + odebug << "bits " << bits << "" << oendl; if( filePara.resolution == 16 ) { //AFMT_S16_LE) -// odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; -// odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; -// odebug << "" << filePara.sd << "" << oendl; + odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; + odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; + odebug << "" << filePara.sd << "" << oendl; level = 7; threshold = 0; if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { -// odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; + odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> char abuf[ BUFSIZE/2 ]; short sbuf[ BUFSIZE ]; @@ -155,7 +155,7 @@ void quickRec() for(;;) { if ( stopped) { -// odebug << "quickRec:: stopped" << oendl; + odebug << "quickRec:: stopped" << oendl; break; } @@ -180,8 +180,10 @@ void quickRec() filePara.numberSamples = total; timeSlider->setValue( total); - filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 - / filePara.channels; + printf("%d, bytes %d,total %d\r",number, bytesWritten, total); + fflush(stdout); + + filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; qApp->processEvents(); if( total >= filePara.samplesToRecord) { @@ -204,7 +206,7 @@ void quickRec() return; } - number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); + number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE); if( number <= 0) { perror( "recording error "); @@ -228,8 +230,8 @@ void quickRec() if( filePara.SecondsToRecord != 0) timeSlider->setValue( total); -// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); -// fflush(stdout); + printf("%d, bytes %d,total %d\r",number, bytesWritten , total); + fflush(stdout); filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; @@ -254,7 +256,7 @@ void quickRec() break; // stop if playing was set to false } - number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); + number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE); bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); waveform->newSamples( (const short *) unsigned_inbuffer, number ); @@ -267,7 +269,7 @@ void quickRec() total += bytesWritten; filePara.numberSamples = total; - // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); + // printf("%d, bytes %d,total %d \r",number, bytesWritten , total); // fflush(stdout); if( filePara.SecondsToRecord !=0) timeSlider->setValue( total); @@ -497,7 +499,7 @@ void QtRec::init() { layout->setMargin( 2); TabWidget = new QTabWidget( this, "TabWidget" ); - layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); + layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); // TabWidget->setTabShape(QTabWidget::Triangular); ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** @@ -510,13 +512,13 @@ void QtRec::init() { timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); - timeLabel = new QLabel( tab, "TimeLabel" ); - layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); +// timeLabel = new QLabel( tab, "TimeLabel" ); +// layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); - playLabel2 = new QLabel(tab, "PlayLabel2" ); - playLabel2->setText(tr("Play") ); - playLabel2->setFixedHeight( 18); - layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); +// playLabel2 = new QLabel(tab, "PlayLabel2" ); +// playLabel2->setText(tr("Play") ); +// playLabel2->setFixedHeight( 18); +// layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); @@ -533,11 +535,11 @@ void QtRec::init() { toEndButton->setFixedSize( 22, 22); toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); - QLabel *recLabel2; - recLabel2 = new QLabel( tab, "recLabel2" ); - recLabel2->setText(tr("Rec")); - recLabel2->setFixedHeight( 18); - layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); +// QLabel *recLabel2; +// recLabel2 = new QLabel( tab, "recLabel2" ); +// recLabel2->setText(tr("Rec")); +// recLabel2->setFixedHeight( 18); +// layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); @@ -557,25 +559,27 @@ void QtRec::init() { deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); - deleteSoundButton->setText( tr( "Delete" ) ); + deleteSoundButton->setText( tr( "Del" ) ); ListView1 = new QListView( tab, "IconView1" ); layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); ListView1->addColumn( tr( "Name" ) ); - ListView1->setColumnWidth( 0, 140); +// ListView1->setColumnWidth( 0, 140); ListView1->setSorting( 1, false); ListView1->addColumn( tr( "Time" ) ); //in seconds - ListView1->setColumnWidth( 1, 50); - ListView1->addColumn( tr("Location") ); - ListView1->setColumnWidth( 2, 50); - ListView1->addColumn( tr("Date") ); - ListView1->setColumnWidth( 3, 63); - - ListView1->setColumnWidthMode( 0, QListView::Manual); +// ListView1->setColumnWidth( 1, -1); +// ListView1->addColumn( tr("Location") ); +// ListView1->setColumnWidth( 2, -1); +// ListView1->addColumn( tr("Date") ); +// ListView1->setColumnWidth( 3, -1); + ListView1->setColumnWidthMode(0, QListView::Maximum); +// ListView1->setColumnWidthMode(1, QListView::Maximum); + +// ListView1->setColumnWidthMode( 0, QListView::Manual); ListView1->setColumnAlignment( 1, QListView::AlignCenter); - ListView1->setColumnAlignment( 2, QListView::AlignRight); - ListView1->setColumnAlignment( 3, QListView::AlignLeft); +// ListView1->setColumnAlignment( 2, QListView::AlignRight); +// ListView1->setColumnAlignment( 3, QListView::AlignLeft); ListView1->setAllColumnsShowFocus( true ); QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); @@ -646,7 +650,7 @@ void QtRec::init() { compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); - stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); + stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); @@ -707,7 +711,7 @@ void QtRec::init() { // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); waveform->setMinimumSize( QSize( 0, 50 ) ); - layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); + layout->addMultiCellWidget( waveform, 8, 8, 0, 8); waveform->setBackgroundColor ( black ); } @@ -737,7 +741,7 @@ void QtRec::initIconView() { fileS = cfg.readEntry( filePath, "0" );// file length in seconds mediaLocation = getStorage( filePath); if( info.exists()) { - item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); + item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); item->setPixmap( 0, image0); if( currentFileName == filePath) ListView1->setSelected( item, true); @@ -875,11 +879,11 @@ void QtRec::stop() { void QtRec::doPlayBtn() { if(!stopped) { - playLabel2->setText(tr("Play")); +// playLabel2->setText(tr("Play")); stop(); } else { if(ListView1->currentItem() == 0) return; - playLabel2->setText(tr("Stop")); +// playLabel2->setText(tr("Stop")); currentFile = ListView1->currentItem()->text(0); start(); } @@ -903,13 +907,13 @@ void QtRec::start() { //play bool QtRec::rec() { //record QString timeString; timeString.sprintf("%.0f", 0.0); - timeLabel->setText( timeString+ " seconds"); +// timeLabel->setText( timeString+ " seconds"); if(!stopped) { monitoring = true; return false; } else { secCount = 1; - playLabel2->setText(tr("Stop")); +// playLabel2->setText(tr("Stop")); monitoring = false; setRecordButton( true); @@ -967,10 +971,11 @@ bool QtRec::rec() { //record setCaption( msg); #endif filePara.fileName=currentFile.latin1(); - odebug << "Start recording thread" << oendl; + odebug << "Start recording" << oendl; stopped = false; #ifdef THREADED + odebug << "Start recording thread" << oendl; pthread_t thread1; pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); #endif @@ -1188,7 +1193,7 @@ bool QtRec::doPlay() { // timeSlider->setRange( 0, filePara.numberSamples); timeString.sprintf("%f", filePara.numberOfRecordedSeconds); - timeLabel->setText( timeString+ tr(" seconds")); +// timeLabel->setText( timeString+ tr(" seconds")); QString msg; msg.sprintf("%d, %d, %d", @@ -1476,7 +1481,7 @@ void QtRec::endRecording() { // move tmp file to regular file QString cmd; cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); -// odebug << "moving tmp file to "+currentFileName << oendl; + odebug << "moving tmp file to "+currentFileName << oendl; system( cmd.latin1()); } @@ -1496,11 +1501,11 @@ void QtRec::endRecording() { QString time; time.sprintf("%.2f", filePara.numberOfRecordedSeconds); cfg.writeEntry( wavFile->currentFileName, time ); -// odebug << "writing config numberOfRecordedSeconds "+time << oendl; + odebug << "writing config numberOfRecordedSeconds "+time << oendl; cfg.write(); odebug << "finished recording" << oendl; - timeLabel->setText(""); +// timeLabel->setText(""); } // if(soundDevice) delete soundDevice; @@ -1517,7 +1522,7 @@ void QtRec::endPlaying() { stopped = true; waveform->reset(); // errorStop(); -// odebug << "end playing" << oendl; + odebug << "end playing" << oendl; setRecordButton( false); toBeginningButton->setEnabled( true); @@ -1529,8 +1534,8 @@ void QtRec::endPlaying() { soundDevice->closeDevice( false); soundDevice->sd = -1; // if(soundDevice) delete soundDevice; -// odebug << "file and sound device closed" << oendl; - timeLabel->setText(""); + odebug << "file and sound device closed" << oendl; +// timeLabel->setText(""); total = 0; filePara.numberSamples = 0; filePara.sd = -1; @@ -1538,7 +1543,7 @@ void QtRec::endPlaying() { filePara.fd = 0; // if(wavFile) delete wavFile; //this crashes -// odebug << "track closed" << oendl; + odebug << "track closed" << oendl; killTimers(); owarn << "reset slider" << oendl; timeSlider->setValue(0); @@ -1864,14 +1869,14 @@ void QtRec::timerEvent( QTimerEvent * ) { #endif timeString.sprintf("%d", secCount); - timeLabel->setText( timeString + " seconds"); +// timeLabel->setText( timeString + " seconds"); secCount++; } void QtRec::changeTimeSlider(int index) { if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; - // odebug << "Slider moved to " << index << "" << oendl; + odebug << "Slider moved to " << index << "" << oendl; paused = true; stopped = true; @@ -1881,12 +1886,12 @@ void QtRec::changeTimeSlider(int index) { filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); secCount = (int)filePara.numberOfRecordedSeconds; - timeLabel->setText( timeString + tr(" seconds")); +// timeLabel->setText( timeString + tr(" seconds")); } void QtRec::timeSliderPressed() { if( ListView1->currentItem() == 0) return; - // odebug << "slider pressed" << oendl; + odebug << "slider pressed" << oendl; paused = true; stopped = true; } @@ -1895,7 +1900,7 @@ void QtRec::timeSliderReleased() { if( ListView1->currentItem() == 0) return; sliderPos = timeSlider->value(); - // odebug << "slider released " << sliderPos << "" << oendl; + odebug << "slider released " << sliderPos << "" << oendl; stopped = false; int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); total = newPos*4; @@ -1925,11 +1930,11 @@ void QtRec::rewindTimerTimeout() { sliderValue = sliderValue - ( filePara.numberSamples / 100); // if(toBeginningButton->isDown()) timeSlider->setValue( sliderValue ) ; - // odebug << "" << sliderValue << "" << oendl; + odebug << "" << sliderValue << "" << oendl; QString timeString; filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); - timeLabel->setText( timeString+ tr(" seconds")); +// timeLabel->setText( timeString+ tr(" seconds")); } void QtRec::rewindReleased() { @@ -1939,7 +1944,7 @@ void QtRec::rewindReleased() { stopped = false; int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); total = newPos * 4; - // odebug << "rewind released " << total << "" << oendl; + odebug << "rewind released " << total << "" << oendl; startTimer( 1000); doPlay(); } @@ -1971,7 +1976,7 @@ void QtRec::forwardTimerTimeout() { QString timeString; filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); - timeLabel->setText( timeString+ tr(" seconds")); +// timeLabel->setText( timeString+ tr(" seconds")); } void QtRec::FastforwardReleased() { @@ -2027,7 +2032,7 @@ void QtRec::setRecordButton(bool b) { Stop_PushButton->setPixmap( image3 ); if(Stop_PushButton->isDown()) Stop_PushButton->setDown( true); - playLabel2->setText( tr("Stop") ); +// playLabel2->setText( tr("Stop") ); } else { //about to stop @@ -2035,7 +2040,7 @@ void QtRec::setRecordButton(bool b) { Stop_PushButton->setPixmap( image4); if(Stop_PushButton->isDown()) Stop_PushButton->setDown( false); - playLabel2->setText( tr("Play") ); +// playLabel2->setText( tr("Play") ); if(Rec_PushButton->isDown()) Rec_PushButton->setDown( false); } diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h index 5878d37..3808d99 100644 --- a/noncore/multimedia/opierec/qtrec.h +++ b/noncore/multimedia/opierec/qtrec.h @@ -4,7 +4,7 @@ copyright 2002 by L.J. Potter ljp@llornkcor.com ****************************************************************************/ #ifndef QTREC_H #define QTREC_H -#define VERSION 20040101 +#define VERSION 20040628 #include <qpe/ir.h> |