summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opierec') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp178
1 files changed, 91 insertions, 87 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 2187d5a..6eb6524 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -118,8 +118,8 @@ Device *soundDevice;
void quickRec()
#else
- void QtRec::quickRec()
+ void QtRec::quickRec()
#endif
{
-
+
qDebug("%d",
filePara.numberSamples/filePara.sampleRate * filePara.channels);
@@ -136,16 +136,16 @@ void quickRec()
int threshold = 0;
// int bits = filePara.resolution;
-// odebug << "bits " << bits << "" << oendl;
+// 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;
- // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
+// odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
+// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
char abuf[ BUFSIZE/2 ];
short sbuf[ BUFSIZE ];
@@ -157,5 +157,5 @@ void quickRec()
for(;;) {
if ( stopped) {
-// odebug << "quickRec:: stopped" << oendl;
+// odebug << "quickRec:: stopped" << oendl;
break;
}
@@ -166,5 +166,5 @@ void quickRec()
if(number <= 0) {
perror("recording error ");
- odebug << "" << filePara.fileName << " " << number << "" << oendl;
+ odebug << "" << filePara.fileName << " " << number << "" << oendl;
stopped = true;
return;
@@ -176,5 +176,5 @@ void quickRec()
bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
- waveform->newSamples( (const short *)abuf, bytesWritten );
+ waveform->newSamples( sbuf, number );
total += bytesWritten;
@@ -182,5 +182,6 @@ void quickRec()
timeSlider->setValue( total);
- filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
+ filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2
+ / filePara.channels;
qApp->processEvents();
@@ -192,5 +193,5 @@ void quickRec()
} else {
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
- odebug << "start recording WAVE_FORMAT_PCM" << oendl;
+ odebug << "start recording WAVE_FORMAT_PCM" << oendl;
short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
memset( inbuffer, 0, BUFSIZE);
@@ -199,5 +200,5 @@ void quickRec()
for(;;) {
if ( stopped) {
- odebug << "quickRec:: stopped" << oendl;
+ odebug << "quickRec:: stopped" << oendl;
stopped = true;
break; // stop if playing was set to false
@@ -206,9 +207,8 @@ void quickRec()
number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE);
- waveform->newSamples( inbuffer, number );
if( number <= 0) {
perror( "recording error ");
- odebug << filePara.fileName << oendl;
+ odebug << filePara.fileName << oendl;
stopped = true;
return;
@@ -216,4 +216,5 @@ void quickRec()
bytesWritten = ::write( filePara.fd , inbuffer, number);
+ waveform->newSamples( inbuffer, number );
if( bytesWritten < 0) {
@@ -232,5 +233,6 @@ void quickRec()
// fflush(stdout);
- filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels;
+ filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate
+ / (float)2/filePara.channels;
qApp->processEvents();
@@ -250,14 +252,15 @@ void quickRec()
for(;;) {
if ( stopped) {
- odebug << "quickRec:: stopped" << oendl;
+ odebug << "quickRec:: stopped" << oendl;
break; // stop if playing was set to false
}
-
+
number = ::read( 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","There was a problem\nwriting to the file");
+ QMessageBox::message("Note","<p>There was a problem writing to the file</p>");
perror("File writing error ");
return;
@@ -314,5 +317,5 @@ void playIt()
// }
bytesWritten = write ( filePara.sd, sbuf, number * 4);
- waveform->newSamples( (const short *)sbuf, number );
+ waveform->newSamples( (const short *)sbuf, number *4);
// if(filePara.channels==1)
// total += bytesWritten/2; //mono
@@ -355,5 +358,5 @@ void playIt()
// }
bytesWritten = ::write( filePara.sd, inbuffer, number);
- waveform->newSamples( inbuffer, bytesWritten );
+ waveform->newSamples( inbuffer, number);
//-------------->>>> out to device
// total+=bytesWritten;
@@ -373,5 +376,5 @@ void playIt()
if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
- owarn << "Jane! Stop this crazy thing!" << oendl;
+ owarn << "Jane! Stop this crazy thing!" << oendl;
stopped = true;
// playing = false;
@@ -379,6 +382,6 @@ void playIt()
}
}
- printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
- fflush(stdout);
+// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
+// fflush(stdout);
} //end loop
} else {
@@ -433,5 +436,5 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
hwcfg.setGroup("Hardware");
-
+
soundDevice = new Device( this,
hwcfg.readEntry( "Audio",DSPSTROUT),
@@ -451,5 +454,5 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
wavFile = 0;
- if( soundDevice) delete soundDevice;
+// if( soundDevice) delete soundDevice;
initIconView();
@@ -462,4 +465,5 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
QtRec::~QtRec() {
+// if( soundDevice) delete soundDevice;
}
@@ -477,5 +481,5 @@ void QtRec::cleanUp() {
doMute(false);
- if( wavFile) delete wavFile;
+// if( wavFile) delete wavFile;
// if(soundDevice) delete soundDevice;
}
@@ -718,5 +722,5 @@ void QtRec::initIconView() {
int nFiles = cfg.readNumEntry("NumberofFiles",0);
-// odebug << "init number of files " << nFiles << "" << oendl;
+// odebug << "init number of files " << nFiles << "" << oendl;
for(int i=1;i<= nFiles;i++) {
@@ -779,5 +783,5 @@ void QtRec::initConnections() {
connect( stereoCheckBox, SIGNAL(toggled(bool)),
this, SLOT( changeStereoCheck(bool)) );
-
+
connect( outMuteCheckBox, SIGNAL(toggled(bool)),
this, SLOT( doVolMuting(bool)) );
@@ -860,5 +864,5 @@ void QtRec::initConfig() {
void QtRec::stop() {
- owarn << "STOP" << oendl;
+ owarn << "STOP" << oendl;
setRecordButton(false);
@@ -922,8 +926,8 @@ bool QtRec::rec() { //record
//filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
-// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
+// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
filePara.SecondsToRecord = getCurrentSizeLimit();
-// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
+// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
@@ -931,9 +935,9 @@ bool QtRec::rec() { //record
fileSize = diskSize;
} else if( filePara.format == WAVE_FORMAT_PCM) {
-// odebug << "WAVE_FORMAT_PCM" << oendl;
+// odebug << "WAVE_FORMAT_PCM" << oendl;
fileSize = (filePara.SecondsToRecord ) * filePara.channels
* filePara.sampleRate * ( filePara.resolution / 8) + 1000;
} else {
-// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
+// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
fileSize = ((filePara.SecondsToRecord) * filePara.channels
* filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
@@ -947,5 +951,5 @@ bool QtRec::rec() { //record
}
// else {
- odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
+ odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
// if(fileSize != 0)
timeSlider->setRange(0, filePara.samplesToRecord);
@@ -966,5 +970,5 @@ bool QtRec::rec() { //record
#endif
filePara.fileName=currentFile.latin1();
- odebug << "Start recording thread" << oendl;
+ odebug << "Start recording thread" << oendl;
stopped = false;
@@ -1002,5 +1006,5 @@ void QtRec::thisTab(QWidget* widg) {
if( index==2) { //help page
}
-
+
qApp->processEvents();
update();
@@ -1010,5 +1014,5 @@ void QtRec::thisTab(QWidget* widg) {
void QtRec::getOutVol( ) {
filePara.outVol = soundDevice->getOutVolume();
-// odebug << "out vol " << filePara.outVol << "" << oendl;
+// odebug << "out vol " << filePara.outVol << "" << oendl;
OutputSlider->setValue( -filePara.outVol);
}
@@ -1016,5 +1020,5 @@ void QtRec::getOutVol( ) {
void QtRec::getInVol() {
filePara.inVol = soundDevice->getInVolume();
-// odebug << "in vol " << filePara.inVol << "" << oendl;
+// odebug << "in vol " << filePara.inVol << "" << oendl;
InputSlider->setValue( -filePara.inVol);
}
@@ -1062,5 +1066,5 @@ bool QtRec::setupAudio( bool b) {
}
#endif
-
+
stereo = filePara.channels;
flags = O_WRONLY;
@@ -1090,12 +1094,12 @@ bool QtRec::setupAudio( bool b) {
if( !compressionCheckBox->isChecked()) {
filePara.format = WAVE_FORMAT_PCM;
-// odebug << "WAVE_FORMAT_PCM" << oendl;
+// odebug << "WAVE_FORMAT_PCM" << oendl;
} else {
filePara.format = WAVE_FORMAT_DVI_ADPCM;
sampleformat = AFMT_S16_LE;
-// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
+// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
}
#endif
-
+
stereo = filePara.channels;
// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
@@ -1110,6 +1114,6 @@ bool QtRec::setupAudio( bool b) {
// if(soundDevice) delete soundDevice;
- odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
- owarn << "change waveform settings" << oendl;
+ odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
+ owarn << "change waveform settings" << oendl;
waveform->changeSettings( filePara.sampleRate, filePara.channels );
@@ -1118,5 +1122,5 @@ bool QtRec::setupAudio( bool b) {
soundDevice->reset();
- odebug << "device has been made " << soundDevice->sd << "" << oendl;
+ odebug << "device has been made " << soundDevice->sd << "" << oendl;
////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
@@ -1149,5 +1153,5 @@ bool QtRec::setupAudio( bool b) {
bool QtRec::setUpFile() { //setup file for recording
-// odebug << "Setting up wavfile" << oendl;
+// odebug << "Setting up wavfile" << oendl;
// if(wavFile) delete wavFile;
wavFile = new WavFile( this, (const QString &)"",
@@ -1182,5 +1186,5 @@ bool QtRec::doPlay() {
QString num;
- odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
+ odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
// timeSlider->setRange( 0, filePara.numberSamples);
@@ -1203,5 +1207,5 @@ bool QtRec::doPlay() {
pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
#endif
-
+
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
@@ -1234,5 +1238,5 @@ void QtRec::changesamplerateCombo(int i) {
cfg.writeEntry( "samplerate",rate);
filePara.sampleRate=rate;
- odebug << "Change sample rate " << rate << "" << oendl;
+ odebug << "Change sample rate " << rate << "" << oendl;
cfg.write();
}
@@ -1254,5 +1258,5 @@ void QtRec::changeDirCombo(int index) {
recDir = path;
cfg.writeEntry("directory", recDir);
- odebug << "new rec dir "+recDir << oendl;
+ odebug << "new rec dir "+recDir << oendl;
}
}
@@ -1374,5 +1378,5 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
break;
case Key_Left: {
- odebug << "rewinding" << oendl;
+ odebug << "rewinding" << oendl;
if( !e->isAutoRepeat())
rewindPressed();
@@ -1428,17 +1432,17 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
case Key_Up:
// stop();
- odebug << "Up" << oendl;
+ odebug << "Up" << oendl;
break;
case Key_Down:
// start();
- // odebug << "Down" << oendl;
+ // odebug << "Down" << oendl;
// newSound();
break;
case Key_Left:
- odebug << "Left" << oendl;
+ odebug << "Left" << oendl;
rewindReleased();
break;
case Key_Right:
- odebug << "Right" << oendl;
+ odebug << "Right" << oendl;
FastforwardReleased();
break;
@@ -1475,9 +1479,9 @@ void QtRec::endRecording() {
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;
+
+ odebug << "Just moved " + wavFile->currentFileName << oendl;
Config cfg("OpieRec");
cfg.setGroup("Sounds");
@@ -1495,12 +1499,12 @@ void QtRec::endRecording() {
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;
+ odebug << "finished recording" << oendl;
timeLabel->setText("");
}
- if(soundDevice) delete soundDevice;
+// if(soundDevice) delete soundDevice;
timeSlider->setValue(0);
@@ -1516,5 +1520,5 @@ void QtRec::endPlaying() {
waveform->reset();
// errorStop();
-// odebug << "end playing" << oendl;
+// odebug << "end playing" << oendl;
setRecordButton( false);
@@ -1528,5 +1532,5 @@ void QtRec::endPlaying() {
soundDevice->sd = -1;
// if(soundDevice) delete soundDevice;
-// odebug << "file and sound device closed" << oendl;
+// odebug << "file and sound device closed" << oendl;
timeLabel->setText("");
total = 0;
@@ -1537,10 +1541,10 @@ void QtRec::endPlaying() {
// if(wavFile) delete wavFile; //this crashes
-// odebug << "track closed" << oendl;
+// odebug << "track closed" << oendl;
killTimers();
- owarn << "reset slider" << oendl;
+ owarn << "reset slider" << oendl;
timeSlider->setValue(0);
- if(soundDevice) delete soundDevice;
+// if(soundDevice) delete soundDevice;
}
@@ -1561,5 +1565,5 @@ bool QtRec::openPlayFile() {
if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
currentFileName = cfg.readEntry( currentFile, "" );
- odebug << "opening for play: " + currentFileName << oendl;
+ odebug << "opening for play: " + currentFileName << oendl;
}
}
@@ -1586,8 +1590,8 @@ bool QtRec::openPlayFile() {
monitoring = true;
- odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
+ odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
- owarn << "seconds " << sec << "" << oendl;
+ owarn << "seconds " << sec << "" << oendl;
timeSlider->setRange(0, filePara.numberSamples );
@@ -1690,5 +1694,5 @@ void QtRec::doRename() {
void QtRec::okRename() {
- odebug << renameBox->text() << oendl;
+ odebug << renameBox->text() << oendl;
QString filename = renameBox->text();
cancelRename();
@@ -1702,5 +1706,5 @@ void QtRec::okRename() {
QString file = ListView1->currentItem()->text(0);
- odebug << "filename is " + filename << oendl;
+ odebug << "filename is " + filename << oendl;
int nFiles = cfg.readNumEntry("NumberofFiles",0);
@@ -1773,5 +1777,5 @@ void QtRec::doVolMuting(bool b) {
void QtRec::doMicMuting(bool b) {
- // odebug << "mic mute" << oendl;
+ // odebug << "mic mute" << oendl;
Config cfg( "qpe" );
cfg. setGroup( "Volume" );
@@ -1791,5 +1795,5 @@ void QtRec::compressionSelected(bool b) {
if(b) {
bitRateComboBox->setEnabled( false);
- bitRateComboBox->setCurrentItem( 0);
+ bitRateComboBox->setCurrentItem( 1);
filePara.resolution = 16;
} else{
@@ -1829,5 +1833,5 @@ long QtRec::checkDiskSpace(const QString &path) {
void QtRec::receive( const QCString &msg, const QByteArray & ) {
- odebug << "Voicerecord received message "+msg << oendl;
+ odebug << "Voicerecord received message "+msg << oendl;
}
@@ -1849,10 +1853,10 @@ void QtRec::timerEvent( QTimerEvent * ) {
stop();
}
-
+
if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
stop();
}
-
- odebug << "" << secCount << "" << oendl;
+
+ odebug << "" << secCount << "" << oendl;
QString timeString;
#ifdef DEV_VERSION
@@ -1870,5 +1874,5 @@ void QtRec::timerEvent( QTimerEvent * ) {
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;
@@ -1885,5 +1889,5 @@ void QtRec::changeTimeSlider(int index) {
void QtRec::timeSliderPressed() {
if( ListView1->currentItem() == 0) return;
- // odebug << "slider pressed" << oendl;
+ // odebug << "slider pressed" << oendl;
paused = true;
stopped = true;
@@ -1894,5 +1898,5 @@ void QtRec::timeSliderReleased() {
sliderPos = timeSlider->value();
- // odebug << "slider released " << sliderPos << "" << oendl;
+ // odebug << "slider released " << sliderPos << "" << oendl;
stopped = false;
int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
@@ -1924,5 +1928,5 @@ void QtRec::rewindTimerTimeout() {
// if(toBeginningButton->isDown())
timeSlider->setValue( sliderValue ) ;
- // odebug << "" << sliderValue << "" << oendl;
+ // odebug << "" << sliderValue << "" << oendl;
QString timeString;
filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
@@ -1938,5 +1942,5 @@ void QtRec::rewindReleased() {
int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
total = newPos * 4;
- // odebug << "rewind released " << total << "" << oendl;
+ // odebug << "rewind released " << total << "" << oendl;
startTimer( 1000);
doPlay();
@@ -2002,5 +2006,5 @@ QString QtRec::getStorage(const QString &fileName) {
// if( name.find( tr("Internal"),0,true) == -1) {
// storageComboBox->insertItem( name +" -> "+disk);
- // odebug << name << oendl;
+ // odebug << name << oendl;
}
return storage;
@@ -2125,7 +2129,7 @@ void QtRec::changeStereoCheck(bool b) {
cfg.writeEntry("stereo", b);
filePara.channels = ch;
-
+
cfg.write();
}
-
+