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 /noncore/multimedia | |
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 @@ -70,14 +70,14 @@ static int deviceBitRates[] = { 8, 16, -1 }; #define DSPSTRIN "/dev/dsp1" #define DSPSTRMIXEROUT "/dev/mixer" #define DSPSTRMIXERIN "/dev/mixer1" #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" #endif //#define ZAURUS 0 @@ -130,35 +130,35 @@ void quickRec() bytesWritten = 0; number = 0; 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 ]; short sbuf2[ BUFSIZE ]; memset( abuf, 0, BUFSIZE/2); memset( sbuf, 0, BUFSIZE); memset( sbuf2, 0, BUFSIZE); for(;;) { if ( stopped) { -// odebug << "quickRec:: stopped" << oendl; + odebug << "quickRec:: stopped" << oendl; break; } // number=::read( filePara.sd, sbuf, BUFSIZE); number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); @@ -177,14 +177,16 @@ void quickRec() waveform->newSamples( sbuf, number ); total += bytesWritten; 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) { stopped = true; break; } @@ -201,13 +203,13 @@ void quickRec() odebug << "quickRec:: stopped" << oendl; stopped = true; break; // stop if playing was set to false 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 "); odebug << filePara.fileName << oendl; stopped = true; return; @@ -225,14 +227,14 @@ void quickRec() total += bytesWritten; filePara.numberSamples = total; 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; qApp->processEvents(); if( total >= filePara.samplesToRecord) { @@ -251,26 +253,26 @@ void quickRec() for(;;) { if ( stopped) { odebug << "quickRec:: stopped" << oendl; 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 ); if(bytesWritten < 0) { stopped = true; QMessageBox::message("Note","<p>There was a problem writing to the file</p>"); perror("File writing error "); return; } 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); filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; @@ -494,32 +496,32 @@ void QtRec::init() { setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 2); 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); ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** tab = new QWidget( TabWidget, "tab" ); QGridLayout *layout1 = new QGridLayout( tab); layout1->setSpacing( 2); layout1->setMargin( 2); 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); Stop_PushButton->setFixedSize( 22, 22); Stop_PushButton->setPixmap( image4 ); @@ -530,17 +532,17 @@ void QtRec::init() { toEndButton = new QPushButton( tab, "End_PushButton" ); layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 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); Rec_PushButton->setFixedSize( 22, 22); Rec_PushButton->setPixmap( image6 ); @@ -554,31 +556,33 @@ void QtRec::init() { forwardTimer = new QTimer( this ); connect( forwardTimer, SIGNAL( timeout() ), this, SLOT( forwardTimerTimeout() ) ); 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); TabWidget->insertTab( tab, tr( "Files" ) ); ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** @@ -643,13 +647,13 @@ void QtRec::init() { glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); 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); glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); tab_5 = new QWidget( TabWidget, "tab_5" ); @@ -704,13 +708,13 @@ void QtRec::init() { waveform = new Waveform( this, "waveform" ); // 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 ); } void QtRec::initIconView() { ListView1->clear(); @@ -734,13 +738,13 @@ void QtRec::initIconView() { QFileInfo info(filePath); fileDate = info.lastModified().toString(); 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); } } } @@ -872,17 +876,17 @@ void QtRec::stop() { timeSlider->setValue(0); } 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(); } } void QtRec::start() { //play @@ -900,19 +904,19 @@ 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); if( setupAudio( true)) if(setUpFile()) { int fileSize = 0; @@ -964,16 +968,17 @@ bool QtRec::rec() { //record QString msg; msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); #ifdef DEV_VERSION 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 toBeginningButton->setEnabled( false); toEndButton->setEnabled( false); @@ -1185,13 +1190,13 @@ bool QtRec::doPlay() { QString num; odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; // 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", filePara.sampleRate, filePara.channels, filePara.resolution); @@ -1473,13 +1478,13 @@ void QtRec::endRecording() { filePara.fd=0; if( wavFile->isTempFile()) { // 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()); } odebug << "Just moved " + wavFile->currentFileName << oendl; Config cfg("OpieRec"); cfg.setGroup("Sounds"); @@ -1493,17 +1498,17 @@ void QtRec::endRecording() { cfg.writeEntry( QString::number( nFiles + 1), currentFile); cfg.writeEntry( currentFile, wavFile->currentFileName); 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; timeSlider->setValue(0); initIconView(); @@ -1514,34 +1519,34 @@ void QtRec::endPlaying() { monitoring = false; recording = false; playing = false; stopped = true; waveform->reset(); // errorStop(); -// odebug << "end playing" << oendl; + odebug << "end playing" << oendl; setRecordButton( false); toBeginningButton->setEnabled( true); toEndButton->setEnabled( true); if(autoMute) doMute( true); 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; // wavFile->closeFile(); 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); // if(soundDevice) delete soundDevice; @@ -1861,44 +1866,44 @@ void QtRec::timerEvent( QTimerEvent * ) { QString msg; msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); setCaption( msg +" :: "+QString::number(secCount)); #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; sliderPos=index; QString timeString; 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; } 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; filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; doPlay(); @@ -1922,27 +1927,27 @@ void QtRec::rewindPressed() { void QtRec::rewindTimerTimeout() { int sliderValue = timeSlider->value(); 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() { rewindTimer->stop(); if( wavFile->track.isOpen()) { sliderPos=timeSlider->value(); 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(); } } void QtRec::FastforwardPressed() { @@ -1968,13 +1973,13 @@ void QtRec::forwardTimerTimeout() { // if(toEndButton->isDown()) timeSlider->setValue( sliderValue); 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() { forwardTimer->stop(); if( wavFile->track.isOpen()) { sliderPos=timeSlider->value(); @@ -2024,21 +2029,21 @@ void QtRec::setRecordButton(bool b) { Rec_PushButton->setDown( true); QPixmap image3( ( const char** ) image3_data ); Stop_PushButton->setPixmap( image3 ); if(Stop_PushButton->isDown()) Stop_PushButton->setDown( true); - playLabel2->setText( tr("Stop") ); +// playLabel2->setText( tr("Stop") ); } else { //about to stop QPixmap image4( ( const char** ) image4_data ); 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); } } void QtRec::fillDirectoryCombo() { 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 @@ -1,13 +1,13 @@ /**************************************************************************** ** Created: Thu Jan 17 11:19:45 2002 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> #include <qfile.h> #include <qimage.h> #include <qlineedit.h> |