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() | |||
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | //if(stereo == 2) { | 155 | //if(stereo == 2) { |
156 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 156 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
157 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 157 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
158 | 158 | ||
159 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); | 159 | bytesWritten = ::write( filePara.fd , abuf, number/4); |
160 | 160 | ||
161 | waveform->newSamples( sbuf, number ); | 161 | waveform->newSamples( sbuf, number ); |
162 | 162 | ||
163 | total += bytesWritten; | 163 | total += bytesWritten; |
164 | filePara.numberSamples = total; | 164 | filePara.numberSamples = total; |
165 | timeSlider->setValue( total); | 165 | timeSlider->setValue( total); |
166 | 166 | ||
167 | printf("%d, bytes %d,total %d\r", number, bytesWritten, total); | 167 | printf("%d, bytes %d,total %d\r", number, bytesWritten, total); |
168 | fflush(stdout); | 168 | fflush(stdout); |
169 | 169 | ||
170 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; | 170 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;/// filePara.channels; |
171 | 171 | ||
172 | qApp->processEvents(); | 172 | qApp->processEvents(); |
173 | if( total >= filePara.samplesToRecord) { | 173 | if( total >= filePara.samplesToRecord) { |
174 | stopped = true; | 174 | stopped = true; |
175 | break; | 175 | break; |
176 | } | 176 | } |
@@ -298,14 +298,16 @@ void playIt() | |||
298 | number = ::read( filePara.fd, abuf, BUFSIZE / 2); | 298 | number = ::read( filePara.fd, abuf, BUFSIZE / 2); |
299 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); | 299 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); |
300 | 300 | ||
301 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 301 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
302 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; | 302 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; |
303 | // } | 303 | // } |
304 | bytesWritten = write ( filePara.sd, sbuf, number * 4); | 304 | bytesWritten = write ( soundDevice->sd , sbuf, number * 4); |
305 | waveform->newSamples( (const short *)sbuf, number *4); | 305 | |
306 | waveform->newSamples( sbuf, number ); | ||
307 | |||
306 | // if(filePara.channels==1) | 308 | // if(filePara.channels==1) |
307 | // total += bytesWritten/2; //mono | 309 | // total += bytesWritten/2; //mono |
308 | // else | 310 | // else |
309 | total += bytesWritten; | 311 | total += bytesWritten; |
310 | filePara.numberSamples = total/4; | 312 | filePara.numberSamples = total/4; |
311 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; | 313 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; |
@@ -339,13 +341,13 @@ void playIt() | |||
339 | // stop if playing was set to false | 341 | // stop if playing was set to false |
340 | number = ::read( filePara.fd, inbuffer, BUFSIZE); | 342 | number = ::read( filePara.fd, inbuffer, BUFSIZE); |
341 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 343 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
342 | // // for (int i=0;i< number ; i++) { //2*i is left channel | 344 | // // for (int i=0;i< number ; i++) { //2*i is left channel |
343 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; | 345 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; |
344 | // } | 346 | // } |
345 | bytesWritten = ::write( filePara.sd, inbuffer, number); | 347 | bytesWritten = ::write( soundDevice->sd, inbuffer, number); |
346 | waveform->newSamples( inbuffer, number); | 348 | waveform->newSamples( inbuffer, number); |
347 | //-------------->>>> out to device | 349 | //-------------->>>> out to device |
348 | // total+=bytesWritten; | 350 | // total+=bytesWritten; |
349 | // if(filePara.channels==1) | 351 | // if(filePara.channels==1) |
350 | // total += bytesWritten/2; //mono | 352 | // total += bytesWritten/2; //mono |
351 | // else | 353 | // else |
@@ -785,14 +787,14 @@ void QtRec::initConfig() { | |||
785 | } else { | 787 | } else { |
786 | filePara.channels = 1; | 788 | filePara.channels = 1; |
787 | } | 789 | } |
788 | 790 | ||
789 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 791 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
790 | if( compressionCheckBox->isChecked()) { | 792 | if( compressionCheckBox->isChecked()) { |
793 | bitRateComboBox->setCurrentItem(1); | ||
791 | bitRateComboBox->setEnabled(false); | 794 | bitRateComboBox->setEnabled(false); |
792 | bitRateComboBox->setCurrentItem(0); | ||
793 | filePara.resolution=16; | 795 | filePara.resolution=16; |
794 | } | 796 | } |
795 | 797 | ||
796 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 798 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
797 | if( autoMuteCheckBox->isChecked()) | 799 | if( autoMuteCheckBox->isChecked()) |
798 | slotAutoMute(true); | 800 | slotAutoMute(true); |
@@ -1045,13 +1047,13 @@ bool QtRec::setupAudio( bool b) { | |||
1045 | flags= O_RDWR; | 1047 | flags= O_RDWR; |
1046 | // flags= O_RDONLY; | 1048 | // flags= O_RDONLY; |
1047 | recording = true; | 1049 | recording = true; |
1048 | } | 1050 | } |
1049 | 1051 | ||
1050 | // if(soundDevice) delete soundDevice; | 1052 | // if(soundDevice) delete soundDevice; |
1051 | odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; | 1053 | owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; |
1052 | // owarn << "change waveform settings" << oendl; | 1054 | // owarn << "change waveform settings" << oendl; |
1053 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1055 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1054 | 1056 | ||
1055 | soundDevice = new Device( this, b); //open rec | 1057 | soundDevice = new Device( this, b); //open rec |
1056 | // soundDevice->openDsp(); | 1058 | // soundDevice->openDsp(); |
1057 | soundDevice->reset(); | 1059 | soundDevice->reset(); |
@@ -1480,13 +1482,13 @@ void QtRec::endPlaying() { | |||
1480 | 1482 | ||
1481 | // if(soundDevice) delete soundDevice; | 1483 | // if(soundDevice) delete soundDevice; |
1482 | 1484 | ||
1483 | } | 1485 | } |
1484 | 1486 | ||
1485 | bool QtRec::openPlayFile() { | 1487 | bool QtRec::openPlayFile() { |
1486 | 1488 | qWarning("opening file"); | |
1487 | qApp->processEvents(); | 1489 | qApp->processEvents(); |
1488 | if( currentFile.isEmpty()) { | 1490 | if( currentFile.isEmpty()) { |
1489 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); | 1491 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); |
1490 | endPlaying(); | 1492 | endPlaying(); |
1491 | return false; | 1493 | return false; |
1492 | } | 1494 | } |
@@ -1723,14 +1725,15 @@ void QtRec::compressionSelected(bool b) { | |||
1723 | cfg.writeEntry("wavCompression", b); | 1725 | cfg.writeEntry("wavCompression", b); |
1724 | cfg.writeEntry("bitrate", 16); | 1726 | cfg.writeEntry("bitrate", 16); |
1725 | filePara.resolution = 16; | 1727 | filePara.resolution = 16; |
1726 | cfg.write(); | 1728 | cfg.write(); |
1727 | 1729 | ||
1728 | if(b) { | 1730 | if(b) { |
1729 | bitRateComboBox->setEnabled( false); | 1731 | qWarning("set adpcm"); |
1730 | bitRateComboBox->setCurrentItem( 1); | 1732 | bitRateComboBox->setCurrentItem( 1); |
1733 | bitRateComboBox->setEnabled( false); | ||
1731 | filePara.resolution = 16; | 1734 | filePara.resolution = 16; |
1732 | } else{ | 1735 | } else{ |
1733 | bitRateComboBox->setEnabled( true); | 1736 | bitRateComboBox->setEnabled( true); |
1734 | } | 1737 | } |
1735 | } | 1738 | } |
1736 | 1739 | ||