author | llornkcor <llornkcor> | 2005-03-12 01:54:52 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-03-12 01:54:52 (UTC) |
commit | 84af289057291a49a52a60b390bc5320c02b5a55 (patch) (side-by-side diff) | |
tree | 523f2d36240efd4f500bfbc35996771bebd7360d /noncore/multimedia/opierec/qtrec.cpp | |
parent | 6b67c3b2685b2d3f1bc7a787216aa769d4ea257a (diff) | |
download | opie-84af289057291a49a52a60b390bc5320c02b5a55.zip opie-84af289057291a49a52a60b390bc5320c02b5a55.tar.gz opie-84af289057291a49a52a60b390bc5320c02b5a55.tar.bz2 |
fix irregularity with adpcm and bits
Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 21 |
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 @@ -153,24 +153,24 @@ void quickRec() 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; } @@ -298,14 +298,16 @@ void playIt() 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; @@ -339,13 +341,13 @@ void playIt() // 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 @@ -785,14 +787,14 @@ void QtRec::initConfig() { } 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); @@ -1045,13 +1047,13 @@ bool QtRec::setupAudio( bool b) { 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(); @@ -1480,13 +1482,13 @@ void QtRec::endPlaying() { // 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; } @@ -1723,14 +1725,15 @@ void QtRec::compressionSelected(bool b) { 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); } } |