summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec/qtrec.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index e827083..9b761aa 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -147,36 +147,36 @@ void quickRec()
number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE);
if(number <= 0) {
perror("recording error ");
odebug << "" << filePara.fileName << " " << number << "" << oendl;
stopped = true;
return;
}
//if(stereo == 2) {
// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
adpcm_coder( sbuf, abuf, number/2, &encoder_state);
- bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
+ bytesWritten = ::write( filePara.fd , abuf, number/4);
waveform->newSamples( sbuf, number );
total += bytesWritten;
filePara.numberSamples = total;
timeSlider->setValue( total);
printf("%d, bytes %d,total %d\r", number, bytesWritten, total);
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();
if( total >= filePara.samplesToRecord) {
stopped = true;
break;
}
}
} else {
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
odebug << "start recording WAVE_FORMAT_PCM" << oendl;
short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
memset( inbuffer, 0, BUFSIZE);
@@ -292,26 +292,28 @@ void playIt()
for(;;) { // play loop
if ( stopped) {
break;
return;
}// stop if playing was set to false
number = ::read( filePara.fd, abuf, BUFSIZE / 2);
adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
// sbuf2[i+1]=sbuf2[i]=sbuf[i];
// }
- bytesWritten = write ( filePara.sd, sbuf, number * 4);
- waveform->newSamples( (const short *)sbuf, number *4);
+ bytesWritten = write ( soundDevice->sd , sbuf, number * 4);
+
+ waveform->newSamples( sbuf, number );
+
// if(filePara.channels==1)
// total += bytesWritten/2; //mono
// else
total += bytesWritten;
filePara.numberSamples = total/4;
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
timeSlider->setValue( total/4);
// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
// if(filePara.numberOfRecordedSeconds>1)
// timeLabel->setText( timeString+ tr(" seconds"));
// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
@@ -333,25 +335,25 @@ void playIt()
for(;;) { // play loop
if ( stopped) {
break;
return;
}
// stop if playing was set to false
number = ::read( filePara.fd, inbuffer, BUFSIZE);
// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
// // for (int i=0;i< number ; i++) { //2*i is left channel
// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
// }
- bytesWritten = ::write( filePara.sd, inbuffer, number);
+ bytesWritten = ::write( soundDevice->sd, inbuffer, number);
waveform->newSamples( inbuffer, number);
//-------------->>>> out to device
// total+=bytesWritten;
// if(filePara.channels==1)
// total += bytesWritten/2; //mono
// else
total += bytesWritten;
timeSlider->setValue( total);
filePara.numberSamples = total;
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
@@ -779,26 +781,26 @@ void QtRec::initConfig() {
QString temp;
sizeLimitCombo->setCurrentItem((i/5));
stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1));
if( stereoCheckBox->isChecked()) {
filePara.channels = 2;
} else {
filePara.channels = 1;
}
compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
if( compressionCheckBox->isChecked()) {
+ bitRateComboBox->setCurrentItem(1);
bitRateComboBox->setEnabled(false);
- bitRateComboBox->setCurrentItem(0);
filePara.resolution=16;
}
autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
if( autoMuteCheckBox->isChecked())
slotAutoMute(true);
else
slotAutoMute(false);
Config cofg( "qpe");
cofg.setGroup( "Volume");
outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
@@ -1039,25 +1041,25 @@ bool QtRec::setupAudio( bool b) {
// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
}
#endif
stereo = filePara.channels;
// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
flags= O_RDWR;
// flags= O_RDONLY;
recording = true;
}
// if(soundDevice) delete soundDevice;
- odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
+ owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
// owarn << "change waveform settings" << oendl;
waveform->changeSettings( filePara.sampleRate, filePara.channels );
soundDevice = new Device( this, b); //open rec
// soundDevice->openDsp();
soundDevice->reset();
odebug << "device has been made " << soundDevice->sd << "" << oendl;
////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
soundDevice->setDeviceFormat( sampleformat);
soundDevice->setDeviceChannels( filePara.channels);
@@ -1474,25 +1476,25 @@ void QtRec::endPlaying() {
// if(wavFile) delete wavFile; //this crashes
odebug << "track closed" << oendl;
killTimers();
// owarn << "reset slider" << oendl;
timeSlider->setValue(0);
// if(soundDevice) delete soundDevice;
}
bool QtRec::openPlayFile() {
-
+ qWarning("opening file");
qApp->processEvents();
if( currentFile.isEmpty()) {
QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
endPlaying();
return false;
}
QString currentFileName;
Config cfg("OpieRec");
cfg.setGroup("Sounds");
int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
for(int i=0;i<nFiles+1;i++) { //look for file
if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
@@ -1717,26 +1719,27 @@ void QtRec::doMicMuting(bool b) {
QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
}
void QtRec::compressionSelected(bool b) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
cfg.writeEntry("wavCompression", b);
cfg.writeEntry("bitrate", 16);
filePara.resolution = 16;
cfg.write();
if(b) {
- bitRateComboBox->setEnabled( false);
+ qWarning("set adpcm");
bitRateComboBox->setCurrentItem( 1);
+ bitRateComboBox->setEnabled( false);
filePara.resolution = 16;
} else{
bitRateComboBox->setEnabled( true);
}
}
long QtRec::checkDiskSpace(const QString &path) {
struct statfs fs;
if ( !statfs( path.latin1(), &fs ) ) {