author | llornkcor <llornkcor> | 2004-04-25 20:38:04 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-25 20:38:04 (UTC) |
commit | 0e3e74030b2a38cfc754d253ab098a1126f382ef (patch) (unidiff) | |
tree | 9eb7544e6c29431cddbcfbc5bfe907d08227dbb2 | |
parent | ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3 (diff) | |
download | opie-0e3e74030b2a38cfc754d253ab098a1126f382ef.zip opie-0e3e74030b2a38cfc754d253ab098a1126f382ef.tar.gz opie-0e3e74030b2a38cfc754d253ab098a1126f382ef.tar.bz2 |
hook things up
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 178 |
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 | |||
@@ -114,16 +114,16 @@ Waveform* waveform; | |||
114 | Device *soundDevice; | 114 | Device *soundDevice; |
115 | 115 | ||
116 | 116 | ||
117 | #ifdef THREADED | 117 | #ifdef THREADED |
118 | void quickRec() | 118 | void quickRec() |
119 | #else | 119 | #else |
120 | void QtRec::quickRec() | 120 | void QtRec::quickRec() |
121 | #endif | 121 | #endif |
122 | { | 122 | { |
123 | 123 | ||
124 | qDebug("%d", | 124 | qDebug("%d", |
125 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | 125 | filePara.numberSamples/filePara.sampleRate * filePara.channels); |
126 | qDebug("samples %d, rate %d, channels %d", | 126 | qDebug("samples %d, rate %d, channels %d", |
127 | filePara.numberSamples, filePara.sampleRate, filePara.channels); | 127 | filePara.numberSamples, filePara.sampleRate, filePara.channels); |
128 | 128 | ||
129 | int total = 0; // Total number of bytes read in so far. | 129 | int total = 0; // Total number of bytes read in so far. |
@@ -132,92 +132,93 @@ void quickRec() | |||
132 | bytesWritten = 0; | 132 | bytesWritten = 0; |
133 | number = 0; | 133 | number = 0; |
134 | QString num; | 134 | QString num; |
135 | int level = 0; | 135 | int level = 0; |
136 | int threshold = 0; | 136 | int threshold = 0; |
137 | // int bits = filePara.resolution; | 137 | // int bits = filePara.resolution; |
138 | // odebug << "bits " << bits << "" << oendl; | 138 | // odebug << "bits " << bits << "" << oendl; |
139 | 139 | ||
140 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 140 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
141 | // odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; | 141 | // odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; |
142 | // odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; | 142 | // odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; |
143 | // odebug << "" << filePara.sd << "" << oendl; | 143 | // odebug << "" << filePara.sd << "" << oendl; |
144 | level = 7; | 144 | level = 7; |
145 | threshold = 0; | 145 | threshold = 0; |
146 | 146 | ||
147 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 147 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
148 | // odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; | 148 | // odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; |
149 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 149 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
150 | char abuf[ BUFSIZE/2 ]; | 150 | char abuf[ BUFSIZE/2 ]; |
151 | short sbuf[ BUFSIZE ]; | 151 | short sbuf[ BUFSIZE ]; |
152 | short sbuf2[ BUFSIZE ]; | 152 | short sbuf2[ BUFSIZE ]; |
153 | memset( abuf, 0, BUFSIZE/2); | 153 | memset( abuf, 0, BUFSIZE/2); |
154 | memset( sbuf, 0, BUFSIZE); | 154 | memset( sbuf, 0, BUFSIZE); |
155 | memset( sbuf2, 0, BUFSIZE); | 155 | memset( sbuf2, 0, BUFSIZE); |
156 | 156 | ||
157 | for(;;) { | 157 | for(;;) { |
158 | if ( stopped) { | 158 | if ( stopped) { |
159 | // odebug << "quickRec:: stopped" << oendl; | 159 | // odebug << "quickRec:: stopped" << oendl; |
160 | break; | 160 | break; |
161 | } | 161 | } |
162 | 162 | ||
163 | // number=::read( filePara.sd, sbuf, BUFSIZE); | 163 | // number=::read( filePara.sd, sbuf, BUFSIZE); |
164 | number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); | 164 | number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); |
165 | 165 | ||
166 | if(number <= 0) { | 166 | if(number <= 0) { |
167 | perror("recording error "); | 167 | perror("recording error "); |
168 | odebug << "" << filePara.fileName << " " << number << "" << oendl; | 168 | odebug << "" << filePara.fileName << " " << number << "" << oendl; |
169 | stopped = true; | 169 | stopped = true; |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | //if(stereo == 2) { | 172 | //if(stereo == 2) { |
173 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 173 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
174 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 174 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
175 | 175 | ||
176 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); | 176 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); |
177 | 177 | ||
178 | waveform->newSamples( (const short *)abuf, bytesWritten ); | 178 | waveform->newSamples( sbuf, number ); |
179 | 179 | ||
180 | total += bytesWritten; | 180 | total += bytesWritten; |
181 | filePara.numberSamples = total; | 181 | filePara.numberSamples = total; |
182 | timeSlider->setValue( total); | 182 | timeSlider->setValue( total); |
183 | 183 | ||
184 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; | 184 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 |
185 | / filePara.channels; | ||
185 | 186 | ||
186 | qApp->processEvents(); | 187 | qApp->processEvents(); |
187 | if( total >= filePara.samplesToRecord) { | 188 | if( total >= filePara.samplesToRecord) { |
188 | stopped = true; | 189 | stopped = true; |
189 | break; | 190 | break; |
190 | } | 191 | } |
191 | } | 192 | } |
192 | } else { | 193 | } else { |
193 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 194 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> |
194 | odebug << "start recording WAVE_FORMAT_PCM" << oendl; | 195 | odebug << "start recording WAVE_FORMAT_PCM" << oendl; |
195 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; | 196 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; |
196 | memset( inbuffer, 0, BUFSIZE); | 197 | memset( inbuffer, 0, BUFSIZE); |
197 | memset( outbuffer, 0, BUFSIZE); | 198 | memset( outbuffer, 0, BUFSIZE); |
198 | 199 | ||
199 | for(;;) { | 200 | for(;;) { |
200 | if ( stopped) { | 201 | if ( stopped) { |
201 | odebug << "quickRec:: stopped" << oendl; | 202 | odebug << "quickRec:: stopped" << oendl; |
202 | stopped = true; | 203 | stopped = true; |
203 | break; // stop if playing was set to false | 204 | break; // stop if playing was set to false |
204 | return; | 205 | return; |
205 | } | 206 | } |
206 | 207 | ||
207 | number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); | 208 | number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); |
208 | waveform->newSamples( inbuffer, number ); | ||
209 | 209 | ||
210 | if( number <= 0) { | 210 | if( number <= 0) { |
211 | perror( "recording error "); | 211 | perror( "recording error "); |
212 | odebug << filePara.fileName << oendl; | 212 | odebug << filePara.fileName << oendl; |
213 | stopped = true; | 213 | stopped = true; |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | 216 | ||
217 | bytesWritten = ::write( filePara.fd , inbuffer, number); | 217 | bytesWritten = ::write( filePara.fd , inbuffer, number); |
218 | waveform->newSamples( inbuffer, number ); | ||
218 | 219 | ||
219 | if( bytesWritten < 0) { | 220 | if( bytesWritten < 0) { |
220 | perror("File writing error "); | 221 | perror("File writing error "); |
221 | stopped = true; | 222 | stopped = true; |
222 | return; | 223 | return; |
223 | } | 224 | } |
@@ -228,13 +229,14 @@ void quickRec() | |||
228 | 229 | ||
229 | if( filePara.SecondsToRecord != 0) | 230 | if( filePara.SecondsToRecord != 0) |
230 | timeSlider->setValue( total); | 231 | timeSlider->setValue( total); |
231 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); | 232 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); |
232 | // fflush(stdout); | 233 | // fflush(stdout); |
233 | 234 | ||
234 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; | 235 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate |
236 | / (float)2/filePara.channels; | ||
235 | qApp->processEvents(); | 237 | qApp->processEvents(); |
236 | 238 | ||
237 | if( total >= filePara.samplesToRecord) { | 239 | if( total >= filePara.samplesToRecord) { |
238 | stopped = true; | 240 | stopped = true; |
239 | break; | 241 | break; |
240 | } | 242 | } |
@@ -246,22 +248,23 @@ void quickRec() | |||
246 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; | 248 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; |
247 | memset( unsigned_inbuffer, 0, BUFSIZE); | 249 | memset( unsigned_inbuffer, 0, BUFSIZE); |
248 | memset( unsigned_outbuffer, 0, BUFSIZE); | 250 | memset( unsigned_outbuffer, 0, BUFSIZE); |
249 | 251 | ||
250 | for(;;) { | 252 | for(;;) { |
251 | if ( stopped) { | 253 | if ( stopped) { |
252 | odebug << "quickRec:: stopped" << oendl; | 254 | odebug << "quickRec:: stopped" << oendl; |
253 | break; // stop if playing was set to false | 255 | break; // stop if playing was set to false |
254 | } | 256 | } |
255 | 257 | ||
256 | number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); | 258 | number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); |
257 | bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); | 259 | bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); |
260 | waveform->newSamples( (const short *) unsigned_inbuffer, number ); | ||
258 | 261 | ||
259 | if(bytesWritten < 0) { | 262 | if(bytesWritten < 0) { |
260 | stopped = true; | 263 | stopped = true; |
261 | QMessageBox::message("Note","There was a problem\nwriting to the file"); | 264 | QMessageBox::message("Note","<p>There was a problem writing to the file</p>"); |
262 | perror("File writing error "); | 265 | perror("File writing error "); |
263 | return; | 266 | return; |
264 | } | 267 | } |
265 | 268 | ||
266 | total += bytesWritten; | 269 | total += bytesWritten; |
267 | filePara.numberSamples = total; | 270 | filePara.numberSamples = total; |
@@ -310,13 +313,13 @@ void playIt() | |||
310 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); | 313 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); |
311 | 314 | ||
312 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 315 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
313 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; | 316 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; |
314 | // } | 317 | // } |
315 | bytesWritten = write ( filePara.sd, sbuf, number * 4); | 318 | bytesWritten = write ( filePara.sd, sbuf, number * 4); |
316 | waveform->newSamples( (const short *)sbuf, number ); | 319 | waveform->newSamples( (const short *)sbuf, number *4); |
317 | // if(filePara.channels==1) | 320 | // if(filePara.channels==1) |
318 | // total += bytesWritten/2; //mono | 321 | // total += bytesWritten/2; //mono |
319 | // else | 322 | // else |
320 | total += bytesWritten; | 323 | total += bytesWritten; |
321 | filePara.numberSamples = total/4; | 324 | filePara.numberSamples = total/4; |
322 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; | 325 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; |
@@ -351,13 +354,13 @@ void playIt() | |||
351 | number = ::read( filePara.fd, inbuffer, BUFSIZE); | 354 | number = ::read( filePara.fd, inbuffer, BUFSIZE); |
352 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 355 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
353 | // // for (int i=0;i< number ; i++) { //2*i is left channel | 356 | // // for (int i=0;i< number ; i++) { //2*i is left channel |
354 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; | 357 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; |
355 | // } | 358 | // } |
356 | bytesWritten = ::write( filePara.sd, inbuffer, number); | 359 | bytesWritten = ::write( filePara.sd, inbuffer, number); |
357 | waveform->newSamples( inbuffer, bytesWritten ); | 360 | waveform->newSamples( inbuffer, number); |
358 | //-------------->>>> out to device | 361 | //-------------->>>> out to device |
359 | // total+=bytesWritten; | 362 | // total+=bytesWritten; |
360 | // if(filePara.channels==1) | 363 | // if(filePara.channels==1) |
361 | // total += bytesWritten/2; //mono | 364 | // total += bytesWritten/2; //mono |
362 | // else | 365 | // else |
363 | total += bytesWritten; | 366 | total += bytesWritten; |
@@ -369,20 +372,20 @@ void playIt() | |||
369 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); | 372 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); |
370 | // timeLabel->setText( timeString + tr(" seconds")); | 373 | // timeLabel->setText( timeString + tr(" seconds")); |
371 | 374 | ||
372 | qApp->processEvents(); | 375 | qApp->processEvents(); |
373 | 376 | ||
374 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 377 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
375 | owarn << "Jane! Stop this crazy thing!" << oendl; | 378 | owarn << "Jane! Stop this crazy thing!" << oendl; |
376 | stopped = true; | 379 | stopped = true; |
377 | // playing = false; | 380 | // playing = false; |
378 | break; | 381 | break; |
379 | } | 382 | } |
380 | } | 383 | } |
381 | printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); | 384 | // printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); |
382 | fflush(stdout); | 385 | // fflush(stdout); |
383 | } //end loop | 386 | } //end loop |
384 | } else { | 387 | } else { |
385 | /////////////////////////////// format = AFMT_U8; | 388 | /////////////////////////////// format = AFMT_U8; |
386 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; | 389 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; |
387 | memset( unsigned_inbuffer, 0, BUFSIZE); | 390 | memset( unsigned_inbuffer, 0, BUFSIZE); |
388 | for(;;) { | 391 | for(;;) { |
@@ -429,13 +432,13 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | |||
429 | renameBox = 0; | 432 | renameBox = 0; |
430 | 433 | ||
431 | // open sound device to get volumes | 434 | // open sound device to get volumes |
432 | Config hwcfg("OpieRec"); | 435 | Config hwcfg("OpieRec"); |
433 | hwcfg.setGroup("Hardware"); | 436 | hwcfg.setGroup("Hardware"); |
434 | 437 | ||
435 | 438 | ||
436 | soundDevice = new Device( this, | 439 | soundDevice = new Device( this, |
437 | hwcfg.readEntry( "Audio",DSPSTROUT), | 440 | hwcfg.readEntry( "Audio",DSPSTROUT), |
438 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); | 441 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); |
439 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); | 442 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); |
440 | 443 | ||
441 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | 444 | // soundDevice->setDeviceFormat(AFMT_S16_LE); |
@@ -447,23 +450,24 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | |||
447 | 450 | ||
448 | soundDevice->closeDevice( true); | 451 | soundDevice->closeDevice( true); |
449 | soundDevice->sd = -1; | 452 | soundDevice->sd = -1; |
450 | soundDevice = 0; | 453 | soundDevice = 0; |
451 | wavFile = 0; | 454 | wavFile = 0; |
452 | 455 | ||
453 | if( soundDevice) delete soundDevice; | 456 | // if( soundDevice) delete soundDevice; |
454 | 457 | ||
455 | initIconView(); | 458 | initIconView(); |
456 | 459 | ||
457 | if( autoMute) | 460 | if( autoMute) |
458 | doMute( true); | 461 | doMute( true); |
459 | ListView1->setFocus(); | 462 | ListView1->setFocus(); |
460 | playing = false; | 463 | playing = false; |
461 | } | 464 | } |
462 | 465 | ||
463 | QtRec::~QtRec() { | 466 | QtRec::~QtRec() { |
467 | // if( soundDevice) delete soundDevice; | ||
464 | 468 | ||
465 | } | 469 | } |
466 | 470 | ||
467 | void QtRec::cleanUp() { | 471 | void QtRec::cleanUp() { |
468 | 472 | ||
469 | if( !stopped) { | 473 | if( !stopped) { |
@@ -473,13 +477,13 @@ void QtRec::cleanUp() { | |||
473 | 477 | ||
474 | ListView1->clear(); | 478 | ListView1->clear(); |
475 | 479 | ||
476 | if( autoMute) | 480 | if( autoMute) |
477 | doMute(false); | 481 | doMute(false); |
478 | 482 | ||
479 | if( wavFile) delete wavFile; | 483 | // if( wavFile) delete wavFile; |
480 | // if(soundDevice) delete soundDevice; | 484 | // if(soundDevice) delete soundDevice; |
481 | } | 485 | } |
482 | 486 | ||
483 | void QtRec::init() { | 487 | void QtRec::init() { |
484 | 488 | ||
485 | needsStereoOut = false; | 489 | needsStereoOut = false; |
@@ -714,13 +718,13 @@ void QtRec::initIconView() { | |||
714 | Config cfg("OpieRec"); | 718 | Config cfg("OpieRec"); |
715 | cfg.setGroup("Sounds"); | 719 | cfg.setGroup("Sounds"); |
716 | QString temp; | 720 | QString temp; |
717 | QPixmap image0( ( const char** ) image0_data ); | 721 | QPixmap image0( ( const char** ) image0_data ); |
718 | 722 | ||
719 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 723 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
720 | // odebug << "init number of files " << nFiles << "" << oendl; | 724 | // odebug << "init number of files " << nFiles << "" << oendl; |
721 | 725 | ||
722 | for(int i=1;i<= nFiles;i++) { | 726 | for(int i=1;i<= nFiles;i++) { |
723 | 727 | ||
724 | QListViewItem * item; | 728 | QListViewItem * item; |
725 | QString fileS, mediaLocation, fileDate, filePath; | 729 | QString fileS, mediaLocation, fileDate, filePath; |
726 | 730 | ||
@@ -775,13 +779,13 @@ void QtRec::initConnections() { | |||
775 | this, SLOT( changeDirCombo(int)) ); | 779 | this, SLOT( changeDirCombo(int)) ); |
776 | connect( sizeLimitCombo, SIGNAL(activated(int)), | 780 | connect( sizeLimitCombo, SIGNAL(activated(int)), |
777 | this, SLOT( changeSizeLimitCombo(int)) ); | 781 | this, SLOT( changeSizeLimitCombo(int)) ); |
778 | 782 | ||
779 | connect( stereoCheckBox, SIGNAL(toggled(bool)), | 783 | connect( stereoCheckBox, SIGNAL(toggled(bool)), |
780 | this, SLOT( changeStereoCheck(bool)) ); | 784 | this, SLOT( changeStereoCheck(bool)) ); |
781 | 785 | ||
782 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), | 786 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), |
783 | this, SLOT( doVolMuting(bool)) ); | 787 | this, SLOT( doVolMuting(bool)) ); |
784 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), | 788 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), |
785 | this, SLOT( doMicMuting(bool)) ); | 789 | this, SLOT( doMicMuting(bool)) ); |
786 | 790 | ||
787 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), | 791 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), |
@@ -856,13 +860,13 @@ void QtRec::initConfig() { | |||
856 | cofg.setGroup( "Volume"); | 860 | cofg.setGroup( "Volume"); |
857 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 861 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
858 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 862 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
859 | } | 863 | } |
860 | 864 | ||
861 | void QtRec::stop() { | 865 | void QtRec::stop() { |
862 | owarn << "STOP" << oendl; | 866 | owarn << "STOP" << oendl; |
863 | setRecordButton(false); | 867 | setRecordButton(false); |
864 | 868 | ||
865 | if( !recording) | 869 | if( !recording) |
866 | endPlaying(); | 870 | endPlaying(); |
867 | else | 871 | else |
868 | endRecording(); | 872 | endRecording(); |
@@ -918,38 +922,38 @@ bool QtRec::rec() { //record | |||
918 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", | 922 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", |
919 | // soundDevice->getDeviceBits(), | 923 | // soundDevice->getDeviceBits(), |
920 | // soundDevice->getDeviceRate(), | 924 | // soundDevice->getDeviceRate(), |
921 | // soundDevice->getDeviceChannels()); | 925 | // soundDevice->getDeviceChannels()); |
922 | 926 | ||
923 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 927 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
924 | // odebug << "sample rate is " << filePara.sampleRate << "" << oendl; | 928 | // odebug << "sample rate is " << filePara.sampleRate << "" << oendl; |
925 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 929 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
926 | 930 | ||
927 | // odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; | 931 | // odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; |
928 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 932 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
929 | 933 | ||
930 | if( filePara.SecondsToRecord == 0) { | 934 | if( filePara.SecondsToRecord == 0) { |
931 | fileSize = diskSize; | 935 | fileSize = diskSize; |
932 | } else if( filePara.format == WAVE_FORMAT_PCM) { | 936 | } else if( filePara.format == WAVE_FORMAT_PCM) { |
933 | // odebug << "WAVE_FORMAT_PCM" << oendl; | 937 | // odebug << "WAVE_FORMAT_PCM" << oendl; |
934 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 938 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
935 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; | 939 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; |
936 | } else { | 940 | } else { |
937 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; | 941 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; |
938 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 942 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
939 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; | 943 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; |
940 | } | 944 | } |
941 | 945 | ||
942 | filePara.samplesToRecord = fileSize; | 946 | filePara.samplesToRecord = fileSize; |
943 | qDebug("filesize should be %d, bits %d, rate %d", | 947 | qDebug("filesize should be %d, bits %d, rate %d", |
944 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); | 948 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); |
945 | if( paused) { | 949 | if( paused) { |
946 | paused = false; | 950 | paused = false; |
947 | } | 951 | } |
948 | // else { | 952 | // else { |
949 | odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; | 953 | odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; |
950 | // if(fileSize != 0) | 954 | // if(fileSize != 0) |
951 | timeSlider->setRange(0, filePara.samplesToRecord); | 955 | timeSlider->setRange(0, filePara.samplesToRecord); |
952 | // } | 956 | // } |
953 | 957 | ||
954 | if( diskSize < fileSize/1024) { | 958 | if( diskSize < fileSize/1024) { |
955 | QMessageBox::warning(this, | 959 | QMessageBox::warning(this, |
@@ -962,13 +966,13 @@ bool QtRec::rec() { //record | |||
962 | QString msg; | 966 | QString msg; |
963 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 967 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
964 | #ifdef DEV_VERSION | 968 | #ifdef DEV_VERSION |
965 | setCaption( msg); | 969 | setCaption( msg); |
966 | #endif | 970 | #endif |
967 | filePara.fileName=currentFile.latin1(); | 971 | filePara.fileName=currentFile.latin1(); |
968 | odebug << "Start recording thread" << oendl; | 972 | odebug << "Start recording thread" << oendl; |
969 | stopped = false; | 973 | stopped = false; |
970 | 974 | ||
971 | #ifdef THREADED | 975 | #ifdef THREADED |
972 | pthread_t thread1; | 976 | pthread_t thread1; |
973 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 977 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
974 | #endif | 978 | #endif |
@@ -998,27 +1002,27 @@ void QtRec::thisTab(QWidget* widg) { | |||
998 | // soundDevice->getOutVol(); | 1002 | // soundDevice->getOutVol(); |
999 | // soundDevice->getInVol(); | 1003 | // soundDevice->getInVol(); |
1000 | } | 1004 | } |
1001 | 1005 | ||
1002 | if( index==2) { //help page | 1006 | if( index==2) { //help page |
1003 | } | 1007 | } |
1004 | 1008 | ||
1005 | qApp->processEvents(); | 1009 | qApp->processEvents(); |
1006 | update(); | 1010 | update(); |
1007 | } | 1011 | } |
1008 | } | 1012 | } |
1009 | 1013 | ||
1010 | void QtRec::getOutVol( ) { | 1014 | void QtRec::getOutVol( ) { |
1011 | filePara.outVol = soundDevice->getOutVolume(); | 1015 | filePara.outVol = soundDevice->getOutVolume(); |
1012 | // odebug << "out vol " << filePara.outVol << "" << oendl; | 1016 | // odebug << "out vol " << filePara.outVol << "" << oendl; |
1013 | OutputSlider->setValue( -filePara.outVol); | 1017 | OutputSlider->setValue( -filePara.outVol); |
1014 | } | 1018 | } |
1015 | 1019 | ||
1016 | void QtRec::getInVol() { | 1020 | void QtRec::getInVol() { |
1017 | filePara.inVol = soundDevice->getInVolume(); | 1021 | filePara.inVol = soundDevice->getInVolume(); |
1018 | // odebug << "in vol " << filePara.inVol << "" << oendl; | 1022 | // odebug << "in vol " << filePara.inVol << "" << oendl; |
1019 | InputSlider->setValue( -filePara.inVol); | 1023 | InputSlider->setValue( -filePara.inVol); |
1020 | } | 1024 | } |
1021 | 1025 | ||
1022 | void QtRec::changedOutVolume() { | 1026 | void QtRec::changedOutVolume() { |
1023 | soundDevice->changedOutVolume( -OutputSlider->value()); | 1027 | soundDevice->changedOutVolume( -OutputSlider->value()); |
1024 | } | 1028 | } |
@@ -1058,13 +1062,13 @@ bool QtRec::setupAudio( bool b) { | |||
1058 | filePara.resolution = 16; | 1062 | filePara.resolution = 16; |
1059 | } else { | 1063 | } else { |
1060 | sampleformat = AFMT_U8; | 1064 | sampleformat = AFMT_U8; |
1061 | filePara.resolution = 8; | 1065 | filePara.resolution = 8; |
1062 | } | 1066 | } |
1063 | #endif | 1067 | #endif |
1064 | 1068 | ||
1065 | stereo = filePara.channels; | 1069 | stereo = filePara.channels; |
1066 | flags = O_WRONLY; | 1070 | flags = O_WRONLY; |
1067 | Config hwcfg("OpieRec"); | 1071 | Config hwcfg("OpieRec"); |
1068 | hwcfg.setGroup("Hardware"); | 1072 | hwcfg.setGroup("Hardware"); |
1069 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); | 1073 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); |
1070 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); | 1074 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); |
@@ -1086,41 +1090,41 @@ bool QtRec::setupAudio( bool b) { | |||
1086 | sampleformat = AFMT_S16_LE; | 1090 | sampleformat = AFMT_S16_LE; |
1087 | else | 1091 | else |
1088 | sampleformat = AFMT_U8; | 1092 | sampleformat = AFMT_U8; |
1089 | 1093 | ||
1090 | if( !compressionCheckBox->isChecked()) { | 1094 | if( !compressionCheckBox->isChecked()) { |
1091 | filePara.format = WAVE_FORMAT_PCM; | 1095 | filePara.format = WAVE_FORMAT_PCM; |
1092 | // odebug << "WAVE_FORMAT_PCM" << oendl; | 1096 | // odebug << "WAVE_FORMAT_PCM" << oendl; |
1093 | } else { | 1097 | } else { |
1094 | filePara.format = WAVE_FORMAT_DVI_ADPCM; | 1098 | filePara.format = WAVE_FORMAT_DVI_ADPCM; |
1095 | sampleformat = AFMT_S16_LE; | 1099 | sampleformat = AFMT_S16_LE; |
1096 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; | 1100 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; |
1097 | } | 1101 | } |
1098 | #endif | 1102 | #endif |
1099 | 1103 | ||
1100 | stereo = filePara.channels; | 1104 | stereo = filePara.channels; |
1101 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1105 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1102 | flags= O_RDWR; | 1106 | flags= O_RDWR; |
1103 | // flags= O_RDONLY; | 1107 | // flags= O_RDONLY; |
1104 | Config hwcfg("OpieRec"); | 1108 | Config hwcfg("OpieRec"); |
1105 | hwcfg.setGroup("Hardware"); | 1109 | hwcfg.setGroup("Hardware"); |
1106 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); | 1110 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); |
1107 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); | 1111 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); |
1108 | recording = true; | 1112 | recording = true; |
1109 | } | 1113 | } |
1110 | 1114 | ||
1111 | // if(soundDevice) delete soundDevice; | 1115 | // if(soundDevice) delete soundDevice; |
1112 | odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; | 1116 | odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; |
1113 | owarn << "change waveform settings" << oendl; | 1117 | owarn << "change waveform settings" << oendl; |
1114 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1118 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1115 | 1119 | ||
1116 | soundDevice = new Device( this, dspString, mixerString, b); | 1120 | soundDevice = new Device( this, dspString, mixerString, b); |
1117 | // soundDevice->openDsp(); | 1121 | // soundDevice->openDsp(); |
1118 | soundDevice->reset(); | 1122 | soundDevice->reset(); |
1119 | 1123 | ||
1120 | odebug << "device has been made " << soundDevice->sd << "" << oendl; | 1124 | odebug << "device has been made " << soundDevice->sd << "" << oendl; |
1121 | 1125 | ||
1122 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | 1126 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> |
1123 | soundDevice->setDeviceFormat( sampleformat); | 1127 | soundDevice->setDeviceFormat( sampleformat); |
1124 | soundDevice->setDeviceChannels( filePara.channels); | 1128 | soundDevice->setDeviceChannels( filePara.channels); |
1125 | soundDevice->setDeviceRate( filePara.sampleRate); | 1129 | soundDevice->setDeviceRate( filePara.sampleRate); |
1126 | soundDevice->getDeviceFragSize(); | 1130 | soundDevice->getDeviceFragSize(); |
@@ -1145,13 +1149,13 @@ bool QtRec::setupAudio( bool b) { | |||
1145 | 1149 | ||
1146 | return true; | 1150 | return true; |
1147 | } | 1151 | } |
1148 | 1152 | ||
1149 | 1153 | ||
1150 | bool QtRec::setUpFile() { //setup file for recording | 1154 | bool QtRec::setUpFile() { //setup file for recording |
1151 | // odebug << "Setting up wavfile" << oendl; | 1155 | // odebug << "Setting up wavfile" << oendl; |
1152 | // if(wavFile) delete wavFile; | 1156 | // if(wavFile) delete wavFile; |
1153 | wavFile = new WavFile( this, (const QString &)"", | 1157 | wavFile = new WavFile( this, (const QString &)"", |
1154 | true, | 1158 | true, |
1155 | filePara.sampleRate, | 1159 | filePara.sampleRate, |
1156 | filePara.channels, | 1160 | filePara.channels, |
1157 | filePara.resolution, | 1161 | filePara.resolution, |
@@ -1178,13 +1182,13 @@ bool QtRec::doPlay() { | |||
1178 | } | 1182 | } |
1179 | playing = true; | 1183 | playing = true; |
1180 | stopped = false; | 1184 | stopped = false; |
1181 | recording = false; | 1185 | recording = false; |
1182 | 1186 | ||
1183 | QString num; | 1187 | QString num; |
1184 | odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; | 1188 | odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; |
1185 | 1189 | ||
1186 | // timeSlider->setRange( 0, filePara.numberSamples); | 1190 | // timeSlider->setRange( 0, filePara.numberSamples); |
1187 | 1191 | ||
1188 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); | 1192 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); |
1189 | timeLabel->setText( timeString+ tr(" seconds")); | 1193 | timeLabel->setText( timeString+ tr(" seconds")); |
1190 | 1194 | ||
@@ -1199,13 +1203,13 @@ bool QtRec::doPlay() { | |||
1199 | 1203 | ||
1200 | startTimer( 1000); | 1204 | startTimer( 1000); |
1201 | #ifdef THREADED | 1205 | #ifdef THREADED |
1202 | pthread_t thread2; | 1206 | pthread_t thread2; |
1203 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | 1207 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); |
1204 | #endif | 1208 | #endif |
1205 | 1209 | ||
1206 | toBeginningButton->setEnabled( false); | 1210 | toBeginningButton->setEnabled( false); |
1207 | toEndButton->setEnabled( false); | 1211 | toEndButton->setEnabled( false); |
1208 | #ifndef THREADED | 1212 | #ifndef THREADED |
1209 | playIt(); | 1213 | playIt(); |
1210 | #endif | 1214 | #endif |
1211 | return true; | 1215 | return true; |
@@ -1230,13 +1234,13 @@ void QtRec::changesamplerateCombo(int i) { | |||
1230 | cfg.setGroup("Settings"); | 1234 | cfg.setGroup("Settings"); |
1231 | int rate=0; | 1235 | int rate=0; |
1232 | bool ok; | 1236 | bool ok; |
1233 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); | 1237 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); |
1234 | cfg.writeEntry( "samplerate",rate); | 1238 | cfg.writeEntry( "samplerate",rate); |
1235 | filePara.sampleRate=rate; | 1239 | filePara.sampleRate=rate; |
1236 | odebug << "Change sample rate " << rate << "" << oendl; | 1240 | odebug << "Change sample rate " << rate << "" << oendl; |
1237 | cfg.write(); | 1241 | cfg.write(); |
1238 | } | 1242 | } |
1239 | 1243 | ||
1240 | 1244 | ||
1241 | void QtRec::changeDirCombo(int index) { | 1245 | void QtRec::changeDirCombo(int index) { |
1242 | Config cfg("OpieRec"); | 1246 | Config cfg("OpieRec"); |
@@ -1250,13 +1254,13 @@ void QtRec::changeDirCombo(int index) { | |||
1250 | for( ; it.current(); ++it ){ | 1254 | for( ; it.current(); ++it ){ |
1251 | if( sName == (*it)->name()+" "+ (*it)->path() || | 1255 | if( sName == (*it)->name()+" "+ (*it)->path() || |
1252 | (*it)->name() == sName ) { | 1256 | (*it)->name() == sName ) { |
1253 | const QString path = (*it)->path(); | 1257 | const QString path = (*it)->path(); |
1254 | recDir = path; | 1258 | recDir = path; |
1255 | cfg.writeEntry("directory", recDir); | 1259 | cfg.writeEntry("directory", recDir); |
1256 | odebug << "new rec dir "+recDir << oendl; | 1260 | odebug << "new rec dir "+recDir << oendl; |
1257 | } | 1261 | } |
1258 | } | 1262 | } |
1259 | cfg.write(); | 1263 | cfg.write(); |
1260 | } | 1264 | } |
1261 | 1265 | ||
1262 | 1266 | ||
@@ -1370,13 +1374,13 @@ void QtRec::keyPressEvent( QKeyEvent *e) { | |||
1370 | // stop(); | 1374 | // stop(); |
1371 | break; | 1375 | break; |
1372 | case Key_Down: | 1376 | case Key_Down: |
1373 | // newSound(); | 1377 | // newSound(); |
1374 | break; | 1378 | break; |
1375 | case Key_Left: { | 1379 | case Key_Left: { |
1376 | odebug << "rewinding" << oendl; | 1380 | odebug << "rewinding" << oendl; |
1377 | if( !e->isAutoRepeat()) | 1381 | if( !e->isAutoRepeat()) |
1378 | rewindPressed(); | 1382 | rewindPressed(); |
1379 | } | 1383 | } |
1380 | break; | 1384 | break; |
1381 | case Key_Right: { | 1385 | case Key_Right: { |
1382 | if( !e->isAutoRepeat()) | 1386 | if( !e->isAutoRepeat()) |
@@ -1424,25 +1428,25 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) { | |||
1424 | break; | 1428 | break; |
1425 | case Key_Delete: | 1429 | case Key_Delete: |
1426 | deleteSound(); | 1430 | deleteSound(); |
1427 | break; | 1431 | break; |
1428 | case Key_Up: | 1432 | case Key_Up: |
1429 | // stop(); | 1433 | // stop(); |
1430 | odebug << "Up" << oendl; | 1434 | odebug << "Up" << oendl; |
1431 | break; | 1435 | break; |
1432 | case Key_Down: | 1436 | case Key_Down: |
1433 | // start(); | 1437 | // start(); |
1434 | // odebug << "Down" << oendl; | 1438 | // odebug << "Down" << oendl; |
1435 | // newSound(); | 1439 | // newSound(); |
1436 | break; | 1440 | break; |
1437 | case Key_Left: | 1441 | case Key_Left: |
1438 | odebug << "Left" << oendl; | 1442 | odebug << "Left" << oendl; |
1439 | rewindReleased(); | 1443 | rewindReleased(); |
1440 | break; | 1444 | break; |
1441 | case Key_Right: | 1445 | case Key_Right: |
1442 | odebug << "Right" << oendl; | 1446 | odebug << "Right" << oendl; |
1443 | FastforwardReleased(); | 1447 | FastforwardReleased(); |
1444 | break; | 1448 | break; |
1445 | } | 1449 | } |
1446 | } | 1450 | } |
1447 | 1451 | ||
1448 | void QtRec::endRecording() { | 1452 | void QtRec::endRecording() { |
@@ -1471,17 +1475,17 @@ void QtRec::endRecording() { | |||
1471 | filePara.fd=0; | 1475 | filePara.fd=0; |
1472 | 1476 | ||
1473 | if( wavFile->isTempFile()) { | 1477 | if( wavFile->isTempFile()) { |
1474 | // move tmp file to regular file | 1478 | // move tmp file to regular file |
1475 | QString cmd; | 1479 | QString cmd; |
1476 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1480 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1477 | // odebug << "moving tmp file to "+currentFileName << oendl; | 1481 | // odebug << "moving tmp file to "+currentFileName << oendl; |
1478 | system( cmd.latin1()); | 1482 | system( cmd.latin1()); |
1479 | } | 1483 | } |
1480 | 1484 | ||
1481 | odebug << "Just moved " + wavFile->currentFileName << oendl; | 1485 | odebug << "Just moved " + wavFile->currentFileName << oendl; |
1482 | Config cfg("OpieRec"); | 1486 | Config cfg("OpieRec"); |
1483 | cfg.setGroup("Sounds"); | 1487 | cfg.setGroup("Sounds"); |
1484 | 1488 | ||
1485 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1489 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1486 | 1490 | ||
1487 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); | 1491 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); |
@@ -1491,20 +1495,20 @@ void QtRec::endRecording() { | |||
1491 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); | 1495 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); |
1492 | cfg.writeEntry( currentFile, wavFile->currentFileName); | 1496 | cfg.writeEntry( currentFile, wavFile->currentFileName); |
1493 | 1497 | ||
1494 | QString time; | 1498 | QString time; |
1495 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1499 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1496 | cfg.writeEntry( wavFile->currentFileName, time ); | 1500 | cfg.writeEntry( wavFile->currentFileName, time ); |
1497 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; | 1501 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
1498 | 1502 | ||
1499 | cfg.write(); | 1503 | cfg.write(); |
1500 | odebug << "finished recording" << oendl; | 1504 | odebug << "finished recording" << oendl; |
1501 | timeLabel->setText(""); | 1505 | timeLabel->setText(""); |
1502 | } | 1506 | } |
1503 | 1507 | ||
1504 | if(soundDevice) delete soundDevice; | 1508 | // if(soundDevice) delete soundDevice; |
1505 | 1509 | ||
1506 | timeSlider->setValue(0); | 1510 | timeSlider->setValue(0); |
1507 | initIconView(); | 1511 | initIconView(); |
1508 | selectItemByName( currentFile); | 1512 | selectItemByName( currentFile); |
1509 | } | 1513 | } |
1510 | 1514 | ||
@@ -1512,39 +1516,39 @@ void QtRec::endPlaying() { | |||
1512 | monitoring = false; | 1516 | monitoring = false; |
1513 | recording = false; | 1517 | recording = false; |
1514 | playing = false; | 1518 | playing = false; |
1515 | stopped = true; | 1519 | stopped = true; |
1516 | waveform->reset(); | 1520 | waveform->reset(); |
1517 | // errorStop(); | 1521 | // errorStop(); |
1518 | // odebug << "end playing" << oendl; | 1522 | // odebug << "end playing" << oendl; |
1519 | setRecordButton( false); | 1523 | setRecordButton( false); |
1520 | 1524 | ||
1521 | toBeginningButton->setEnabled( true); | 1525 | toBeginningButton->setEnabled( true); |
1522 | toEndButton->setEnabled( true); | 1526 | toEndButton->setEnabled( true); |
1523 | 1527 | ||
1524 | if(autoMute) | 1528 | if(autoMute) |
1525 | doMute( true); | 1529 | doMute( true); |
1526 | 1530 | ||
1527 | soundDevice->closeDevice( false); | 1531 | soundDevice->closeDevice( false); |
1528 | soundDevice->sd = -1; | 1532 | soundDevice->sd = -1; |
1529 | // if(soundDevice) delete soundDevice; | 1533 | // if(soundDevice) delete soundDevice; |
1530 | // odebug << "file and sound device closed" << oendl; | 1534 | // odebug << "file and sound device closed" << oendl; |
1531 | timeLabel->setText(""); | 1535 | timeLabel->setText(""); |
1532 | total = 0; | 1536 | total = 0; |
1533 | filePara.numberSamples = 0; | 1537 | filePara.numberSamples = 0; |
1534 | filePara.sd = -1; | 1538 | filePara.sd = -1; |
1535 | // wavFile->closeFile(); | 1539 | // wavFile->closeFile(); |
1536 | filePara.fd = 0; | 1540 | filePara.fd = 0; |
1537 | // if(wavFile) delete wavFile; //this crashes | 1541 | // if(wavFile) delete wavFile; //this crashes |
1538 | 1542 | ||
1539 | // odebug << "track closed" << oendl; | 1543 | // odebug << "track closed" << oendl; |
1540 | killTimers(); | 1544 | killTimers(); |
1541 | owarn << "reset slider" << oendl; | 1545 | owarn << "reset slider" << oendl; |
1542 | timeSlider->setValue(0); | 1546 | timeSlider->setValue(0); |
1543 | 1547 | ||
1544 | if(soundDevice) delete soundDevice; | 1548 | // if(soundDevice) delete soundDevice; |
1545 | 1549 | ||
1546 | } | 1550 | } |
1547 | 1551 | ||
1548 | bool QtRec::openPlayFile() { | 1552 | bool QtRec::openPlayFile() { |
1549 | 1553 | ||
1550 | qApp->processEvents(); | 1554 | qApp->processEvents(); |
@@ -1557,13 +1561,13 @@ bool QtRec::openPlayFile() { | |||
1557 | Config cfg("OpieRec"); | 1561 | Config cfg("OpieRec"); |
1558 | cfg.setGroup("Sounds"); | 1562 | cfg.setGroup("Sounds"); |
1559 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); | 1563 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); |
1560 | for(int i=0;i<nFiles+1;i++) { //look for file | 1564 | for(int i=0;i<nFiles+1;i++) { //look for file |
1561 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { | 1565 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { |
1562 | currentFileName = cfg.readEntry( currentFile, "" ); | 1566 | currentFileName = cfg.readEntry( currentFile, "" ); |
1563 | odebug << "opening for play: " + currentFileName << oendl; | 1567 | odebug << "opening for play: " + currentFileName << oendl; |
1564 | } | 1568 | } |
1565 | } | 1569 | } |
1566 | wavFile = new WavFile(this, | 1570 | wavFile = new WavFile(this, |
1567 | currentFileName, | 1571 | currentFileName, |
1568 | false); | 1572 | false); |
1569 | filePara.fd = wavFile->wavHandle(); | 1573 | filePara.fd = wavFile->wavHandle(); |
@@ -1582,16 +1586,16 @@ bool QtRec::openPlayFile() { | |||
1582 | filePara.sampleRate = wavFile->getSampleRate(); | 1586 | filePara.sampleRate = wavFile->getSampleRate(); |
1583 | filePara.resolution = wavFile->getResolution(); | 1587 | filePara.resolution = wavFile->getResolution(); |
1584 | filePara.channels = wavFile->getChannels(); | 1588 | filePara.channels = wavFile->getChannels(); |
1585 | timeSlider->setPageStep(1); | 1589 | timeSlider->setPageStep(1); |
1586 | monitoring = true; | 1590 | monitoring = true; |
1587 | 1591 | ||
1588 | odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; | 1592 | odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; |
1589 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); | 1593 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); |
1590 | 1594 | ||
1591 | owarn << "seconds " << sec << "" << oendl; | 1595 | owarn << "seconds " << sec << "" << oendl; |
1592 | 1596 | ||
1593 | timeSlider->setRange(0, filePara.numberSamples ); | 1597 | timeSlider->setRange(0, filePara.numberSamples ); |
1594 | } | 1598 | } |
1595 | 1599 | ||
1596 | return true; | 1600 | return true; |
1597 | } | 1601 | } |
@@ -1686,25 +1690,25 @@ void QtRec::doRename() { | |||
1686 | renameBox->setFocus(); | 1690 | renameBox->setFocus(); |
1687 | renameBox->show(); | 1691 | renameBox->show(); |
1688 | 1692 | ||
1689 | } | 1693 | } |
1690 | 1694 | ||
1691 | void QtRec::okRename() { | 1695 | void QtRec::okRename() { |
1692 | odebug << renameBox->text() << oendl; | 1696 | odebug << renameBox->text() << oendl; |
1693 | QString filename = renameBox->text(); | 1697 | QString filename = renameBox->text(); |
1694 | cancelRename(); | 1698 | cancelRename(); |
1695 | 1699 | ||
1696 | if( ListView1->currentItem() == NULL) | 1700 | if( ListView1->currentItem() == NULL) |
1697 | return; | 1701 | return; |
1698 | 1702 | ||
1699 | Config cfg("OpieRec"); | 1703 | Config cfg("OpieRec"); |
1700 | cfg.setGroup("Sounds"); | 1704 | cfg.setGroup("Sounds"); |
1701 | 1705 | ||
1702 | QString file = ListView1->currentItem()->text(0); | 1706 | QString file = ListView1->currentItem()->text(0); |
1703 | 1707 | ||
1704 | odebug << "filename is " + filename << oendl; | 1708 | odebug << "filename is " + filename << oendl; |
1705 | 1709 | ||
1706 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1710 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1707 | 1711 | ||
1708 | for(int i=0;i<nFiles+1;i++) { //look for file | 1712 | for(int i=0;i<nFiles+1;i++) { //look for file |
1709 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { | 1713 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { |
1710 | 1714 | ||
@@ -1769,13 +1773,13 @@ void QtRec::doVolMuting(bool b) { | |||
1769 | cfg.writeEntry( "Mute",b); | 1773 | cfg.writeEntry( "Mute",b); |
1770 | cfg.write(); | 1774 | cfg.write(); |
1771 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; | 1775 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; |
1772 | } | 1776 | } |
1773 | 1777 | ||
1774 | void QtRec::doMicMuting(bool b) { | 1778 | void QtRec::doMicMuting(bool b) { |
1775 | // odebug << "mic mute" << oendl; | 1779 | // odebug << "mic mute" << oendl; |
1776 | Config cfg( "qpe" ); | 1780 | Config cfg( "qpe" ); |
1777 | cfg. setGroup( "Volume" ); | 1781 | cfg. setGroup( "Volume" ); |
1778 | cfg.writeEntry( "MicMute",b); | 1782 | cfg.writeEntry( "MicMute",b); |
1779 | cfg.write(); | 1783 | cfg.write(); |
1780 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; | 1784 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; |
1781 | } | 1785 | } |
@@ -1787,13 +1791,13 @@ void QtRec::compressionSelected(bool b) { | |||
1787 | cfg.writeEntry("bitrate", 16); | 1791 | cfg.writeEntry("bitrate", 16); |
1788 | filePara.resolution = 16; | 1792 | filePara.resolution = 16; |
1789 | cfg.write(); | 1793 | cfg.write(); |
1790 | 1794 | ||
1791 | if(b) { | 1795 | if(b) { |
1792 | bitRateComboBox->setEnabled( false); | 1796 | bitRateComboBox->setEnabled( false); |
1793 | bitRateComboBox->setCurrentItem( 0); | 1797 | bitRateComboBox->setCurrentItem( 1); |
1794 | filePara.resolution = 16; | 1798 | filePara.resolution = 16; |
1795 | } else{ | 1799 | } else{ |
1796 | bitRateComboBox->setEnabled( true); | 1800 | bitRateComboBox->setEnabled( true); |
1797 | } | 1801 | } |
1798 | } | 1802 | } |
1799 | 1803 | ||
@@ -1825,13 +1829,13 @@ long QtRec::checkDiskSpace(const QString &path) { | |||
1825 | // long f_files; /* Total number of file nodes */ | 1829 | // long f_files; /* Total number of file nodes */ |
1826 | // long f_ffree; /* Count of free file nodes */ | 1830 | // long f_ffree; /* Count of free file nodes */ |
1827 | // char f_fname[6]; /* Volumename */ | 1831 | // char f_fname[6]; /* Volumename */ |
1828 | // char f_fpack[6]; /* Pack name */ | 1832 | // char f_fpack[6]; /* Pack name */ |
1829 | 1833 | ||
1830 | void QtRec::receive( const QCString &msg, const QByteArray & ) { | 1834 | void QtRec::receive( const QCString &msg, const QByteArray & ) { |
1831 | odebug << "Voicerecord received message "+msg << oendl; | 1835 | odebug << "Voicerecord received message "+msg << oendl; |
1832 | 1836 | ||
1833 | } | 1837 | } |
1834 | 1838 | ||
1835 | 1839 | ||
1836 | ///////////////////////////// timerEvent | 1840 | ///////////////////////////// timerEvent |
1837 | void QtRec::timerEvent( QTimerEvent * ) { | 1841 | void QtRec::timerEvent( QTimerEvent * ) { |
@@ -1845,18 +1849,18 @@ void QtRec::timerEvent( QTimerEvent * ) { | |||
1845 | stop(); | 1849 | stop(); |
1846 | } | 1850 | } |
1847 | 1851 | ||
1848 | if( stopped && recording ){ | 1852 | if( stopped && recording ){ |
1849 | stop(); | 1853 | stop(); |
1850 | } | 1854 | } |
1851 | 1855 | ||
1852 | if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { | 1856 | if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { |
1853 | stop(); | 1857 | stop(); |
1854 | } | 1858 | } |
1855 | 1859 | ||
1856 | odebug << "" << secCount << "" << oendl; | 1860 | odebug << "" << secCount << "" << oendl; |
1857 | QString timeString; | 1861 | QString timeString; |
1858 | #ifdef DEV_VERSION | 1862 | #ifdef DEV_VERSION |
1859 | QString msg; | 1863 | QString msg; |
1860 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1864 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
1861 | setCaption( msg +" :: "+QString::number(secCount)); | 1865 | setCaption( msg +" :: "+QString::number(secCount)); |
1862 | #endif | 1866 | #endif |
@@ -1866,13 +1870,13 @@ void QtRec::timerEvent( QTimerEvent * ) { | |||
1866 | 1870 | ||
1867 | secCount++; | 1871 | secCount++; |
1868 | } | 1872 | } |
1869 | 1873 | ||
1870 | void QtRec::changeTimeSlider(int index) { | 1874 | void QtRec::changeTimeSlider(int index) { |
1871 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; | 1875 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; |
1872 | // odebug << "Slider moved to " << index << "" << oendl; | 1876 | // odebug << "Slider moved to " << index << "" << oendl; |
1873 | paused = true; | 1877 | paused = true; |
1874 | stopped = true; | 1878 | stopped = true; |
1875 | 1879 | ||
1876 | sliderPos=index; | 1880 | sliderPos=index; |
1877 | 1881 | ||
1878 | QString timeString; | 1882 | QString timeString; |
@@ -1881,22 +1885,22 @@ void QtRec::changeTimeSlider(int index) { | |||
1881 | secCount = (int)filePara.numberOfRecordedSeconds; | 1885 | secCount = (int)filePara.numberOfRecordedSeconds; |
1882 | timeLabel->setText( timeString + tr(" seconds")); | 1886 | timeLabel->setText( timeString + tr(" seconds")); |
1883 | } | 1887 | } |
1884 | 1888 | ||
1885 | void QtRec::timeSliderPressed() { | 1889 | void QtRec::timeSliderPressed() { |
1886 | if( ListView1->currentItem() == 0) return; | 1890 | if( ListView1->currentItem() == 0) return; |
1887 | // odebug << "slider pressed" << oendl; | 1891 | // odebug << "slider pressed" << oendl; |
1888 | paused = true; | 1892 | paused = true; |
1889 | stopped = true; | 1893 | stopped = true; |
1890 | } | 1894 | } |
1891 | 1895 | ||
1892 | void QtRec::timeSliderReleased() { | 1896 | void QtRec::timeSliderReleased() { |
1893 | if( ListView1->currentItem() == 0) return; | 1897 | if( ListView1->currentItem() == 0) return; |
1894 | sliderPos = timeSlider->value(); | 1898 | sliderPos = timeSlider->value(); |
1895 | 1899 | ||
1896 | // odebug << "slider released " << sliderPos << "" << oendl; | 1900 | // odebug << "slider released " << sliderPos << "" << oendl; |
1897 | stopped = false; | 1901 | stopped = false; |
1898 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1902 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1899 | total = newPos*4; | 1903 | total = newPos*4; |
1900 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1904 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1901 | 1905 | ||
1902 | doPlay(); | 1906 | doPlay(); |
@@ -1920,13 +1924,13 @@ void QtRec::rewindPressed() { | |||
1920 | 1924 | ||
1921 | void QtRec::rewindTimerTimeout() { | 1925 | void QtRec::rewindTimerTimeout() { |
1922 | int sliderValue = timeSlider->value(); | 1926 | int sliderValue = timeSlider->value(); |
1923 | sliderValue = sliderValue - ( filePara.numberSamples / 100); | 1927 | sliderValue = sliderValue - ( filePara.numberSamples / 100); |
1924 | // if(toBeginningButton->isDown()) | 1928 | // if(toBeginningButton->isDown()) |
1925 | timeSlider->setValue( sliderValue ) ; | 1929 | timeSlider->setValue( sliderValue ) ; |
1926 | // odebug << "" << sliderValue << "" << oendl; | 1930 | // odebug << "" << sliderValue << "" << oendl; |
1927 | QString timeString; | 1931 | QString timeString; |
1928 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; | 1932 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; |
1929 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1933 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1930 | timeLabel->setText( timeString+ tr(" seconds")); | 1934 | timeLabel->setText( timeString+ tr(" seconds")); |
1931 | } | 1935 | } |
1932 | 1936 | ||
@@ -1934,13 +1938,13 @@ void QtRec::rewindReleased() { | |||
1934 | rewindTimer->stop(); | 1938 | rewindTimer->stop(); |
1935 | if( wavFile->track.isOpen()) { | 1939 | if( wavFile->track.isOpen()) { |
1936 | sliderPos=timeSlider->value(); | 1940 | sliderPos=timeSlider->value(); |
1937 | stopped = false; | 1941 | stopped = false; |
1938 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1942 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1939 | total = newPos * 4; | 1943 | total = newPos * 4; |
1940 | // odebug << "rewind released " << total << "" << oendl; | 1944 | // odebug << "rewind released " << total << "" << oendl; |
1941 | startTimer( 1000); | 1945 | startTimer( 1000); |
1942 | doPlay(); | 1946 | doPlay(); |
1943 | } | 1947 | } |
1944 | } | 1948 | } |
1945 | 1949 | ||
1946 | void QtRec::FastforwardPressed() { | 1950 | void QtRec::FastforwardPressed() { |
@@ -1998,13 +2002,13 @@ QString QtRec::getStorage(const QString &fileName) { | |||
1998 | const QString disk = ( *it)->disk(); | 2002 | const QString disk = ( *it)->disk(); |
1999 | if( fileName.find( path,0,true) != -1) | 2003 | if( fileName.find( path,0,true) != -1) |
2000 | storage = name; | 2004 | storage = name; |
2001 | // const QString options = (*it)->options(); | 2005 | // const QString options = (*it)->options(); |
2002 | // if( name.find( tr("Internal"),0,true) == -1) { | 2006 | // if( name.find( tr("Internal"),0,true) == -1) { |
2003 | // storageComboBox->insertItem( name +" -> "+disk); | 2007 | // storageComboBox->insertItem( name +" -> "+disk); |
2004 | // odebug << name << oendl; | 2008 | // odebug << name << oendl; |
2005 | } | 2009 | } |
2006 | return storage; | 2010 | return storage; |
2007 | // struct mntent *me; | 2011 | // struct mntent *me; |
2008 | // // if(fileName == "/etc/mtab") { | 2012 | // // if(fileName == "/etc/mtab") { |
2009 | // FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 2013 | // FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
2010 | // if ( mntfp ) { | 2014 | // if ( mntfp ) { |
@@ -2121,11 +2125,11 @@ void QtRec::changeStereoCheck(bool b) { | |||
2121 | cfg.setGroup("Settings"); | 2125 | cfg.setGroup("Settings"); |
2122 | int ch = 0; | 2126 | int ch = 0; |
2123 | if ( !b) { ch = 1;} | 2127 | if ( !b) { ch = 1;} |
2124 | else { ch = 2;} | 2128 | else { ch = 2;} |
2125 | cfg.writeEntry("stereo", b); | 2129 | cfg.writeEntry("stereo", b); |
2126 | filePara.channels = ch; | 2130 | filePara.channels = ch; |
2127 | 2131 | ||
2128 | cfg.write(); | 2132 | cfg.write(); |
2129 | } | 2133 | } |
2130 | 2134 | ||
2131 | 2135 | ||