summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp200
-rw-r--r--noncore/multimedia/opierec/qtrec.h2
2 files changed, 58 insertions, 144 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 147f63d..2bf795f 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -78,369 +78,320 @@ typedef struct {
78 float numberOfRecordedSeconds; //total number of samples recorded 78 float numberOfRecordedSeconds; //total number of samples recorded
79 int samplesToRecord; //number of samples to be recorded 79 int samplesToRecord; //number of samples to be recorded
80 int inVol; //input volume 80 int inVol; //input volume
81 int outVol; //output volume 81 int outVol; //output volume
82 int format; //wavfile format PCM.. ADPCM 82 int format; //wavfile format PCM.. ADPCM
83 const char *fileName; //name of fiel to be played/recorded 83 const char *fileName; //name of fiel to be played/recorded
84} fileParameters; 84} fileParameters;
85 85
86fileParameters filePara; 86fileParameters filePara;
87 87
88bool monitoring, recording; 88bool monitoring, recording;
89bool stopped; 89bool stopped;
90QLabel *timeLabel; 90QLabel *timeLabel;
91QSlider *timeSlider; 91QSlider *timeSlider;
92int sd; 92int sd;
93 93
94#if defined(QT_QWS_EBX) 94#if defined(QT_QWS_EBX)
95#define DSPSTROUT "/dev/dsp" 95#define DSPSTROUT "/dev/dsp"
96#define DSPSTRIN "/dev/dsp1" 96#define DSPSTRIN "/dev/dsp1"
97#define DSPSTRMIXEROUT "/dev/mixer" 97#define DSPSTRMIXEROUT "/dev/mixer"
98#define DSPSTRMIXERIN "/dev/mixer1" 98#define DSPSTRMIXERIN "/dev/mixer1"
99#else 99#else
100#define DSPSTROUT "/dev/dsp" 100#define DSPSTROUT "/dev/dsp"
101#define DSPSTRIN "/dev/dsp" 101#define DSPSTRIN "/dev/dsp"
102#define DSPSTRMIXERIN "/dev/mixer" 102#define DSPSTRMIXERIN "/dev/mixer"
103#define DSPSTRMIXEROUT "/dev/mixer" 103#define DSPSTRMIXEROUT "/dev/mixer"
104#endif 104#endif
105 105
106// threaded recording 106// threaded recording
107void quickRec() { 107void quickRec() {
108//void QtRec::quickRec() { 108//void QtRec::quickRec() {
109 109
110 qDebug("%d",
111 filePara.numberSamples/filePara.sampleRate * filePara.channels);
112 qDebug("samples %d, rate %d, channels %d",
113 filePara.numberSamples, filePara.sampleRate, filePara.channels);
114
115 int total = 0; // Total number of bytes read in so far. 110 int total = 0; // Total number of bytes read in so far.
116 int bytesWritten, number; 111 int bytesWritten, number;
117 112
118 count_info info; 113 count_info info;
119 114
120 bytesWritten=0; 115 bytesWritten=0;
121 number=0; 116 number=0;
122 QString num, timeString; 117 QString num, timeString;
123 int level=0; 118 int level=0;
124 int threshold=0; 119 int threshold=0;
125 // if(limit != 0) 120 // if(limit != 0)
126 // t->start( ( limit +.3) , true); 121 // t->start( ( limit +.3) , true);
127 122
128 recording = true; 123 recording = true;
129 //rate=filePara.sampleRate; 124 //rate=filePara.sampleRate;
130 int bits = filePara.resolution; 125 // int bits = filePara.resolution;
131 qDebug("bits %d", bits);
132// if( filePara.format==WAVE_FORMAT_DVI_ADPCM)
133// else
134 audio_buf_info inInfo; 126 audio_buf_info inInfo;
135 ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo); 127 ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo);
136 qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal); 128 // qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal);
137 129
138 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 130 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
139 qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord);
140 qDebug("samples to record %d", filePara.samplesToRecord);
141 qDebug("%d", filePara.sd);
142 level=7; 131 level=7;
143 threshold=0; 132 threshold=0;
144 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 133 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
145 timeLabel->setText( timeString+ " seconds"); 134 timeLabel->setText( timeString+ " seconds");
146 135
147 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 136 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
148 qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); 137 // qDebug("start recording WAVE_FORMAT_DVI_ADPCM");
149 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
150 char abuf[BUFSIZE/2]; 138 char abuf[BUFSIZE/2];
151 short sbuf[BUFSIZE]; 139 short sbuf[BUFSIZE];
152 short sbuf2[BUFSIZE]; 140 short sbuf2[BUFSIZE];
153 memset( abuf,0,BUFSIZE/2); 141 memset( abuf,0,BUFSIZE/2);
154 memset( sbuf,0,BUFSIZE); 142 memset( sbuf,0,BUFSIZE);
155 memset( sbuf2,0,BUFSIZE); 143 memset( sbuf2,0,BUFSIZE);
156 144
157 for(;;) { 145 for(;;) {
158 if (stopped) { 146 if (stopped) {
159 qDebug("quickRec:: stopped");
160 break; // stop if playing was set to false 147 break; // stop if playing was set to false
161// return;
162 } 148 }
163 149
164 number=::read( filePara.sd, sbuf, BUFSIZE); 150 number=::read( filePara.sd, sbuf, BUFSIZE);
165
166 if(number <= 0) { 151 if(number <= 0) {
167 perror("recording error "); 152 perror("recording error ");
168 qDebug( "%s %d", filePara.fileName, number); 153 // qDebug( "%s %d", filePara.fileName, number);
169 // errorStop(); 154 // errorStop();
170 recording=stopped=false; 155 recording=stopped=false;
171// QMessageBox::message("Note", 156// QMessageBox::message("Note", "Error recording to file\n%s",filePara.fileName);
172// "Error recording to file\n%s",
173// filePara.fileName);
174 return; 157 return;
175 } 158 }
176 //if(stereo == 2) { 159 //if(stereo == 2) {
177// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 160// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
178 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 161 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
179
180 bytesWritten = ::write( filePara.fd , abuf, number/4); 162 bytesWritten = ::write( filePara.fd , abuf, number/4);
181
182 long peak; 163 long peak;
183 for (int i = 0; i < number; i++) 164 for (int i = 0; i < number; i++)
184 { //since Z is mono do normally 165 { //since Z is mono do normally
185 peak = findPeak((long)sbuf[i]); 166 peak = findPeak((long)sbuf[i]);
186 printf("peak %ld\r",peak); 167 printf("peak %ld\r",peak);
187 fflush(stdout); 168 fflush(stdout);
188 } 169 }
189
190
191 //------------->>>> out to file 170 //------------->>>> out to file
192 // if(filePara.channels==1) 171 // if(filePara.channels==1)
193 // total += bytesWritten/2; //mono 172 // total += bytesWritten/2; //mono
194 // else 173 // else
195 total += bytesWritten; 174 total += bytesWritten;
196 filePara.numberSamples = total; 175 filePara.numberSamples = total;
197// if( total >= filePara.samplesToRecord) 176// if( total >= filePara.samplesToRecord)
198// timeSlider->setValue(0); 177// timeSlider->setValue(0);
199// else if( filePara.SecondsToRecord !=0) 178// else if( filePara.SecondsToRecord !=0)
200 timeSlider->setValue( total); 179 timeSlider->setValue( total);
201 180
202 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; 181 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;
203
204// printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n",
205// number,
206// bytesWritten ,
207// total,
208// filePara.sampleRate,
209// filePara.numberOfRecordedSeconds);
210// fflush(stdout);
211 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); 182 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info);
212// qDebug("%d, %d", info.bytes, (info.bytes / filePara.sampleRate) / 2);
213
214 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 183 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
215 timeLabel->setText( timeString + " seconds"); 184 timeLabel->setText( timeString + " seconds");
216 185
217 qApp->processEvents(); 186 qApp->processEvents();
218 if( total >= filePara.samplesToRecord) 187 if( total >= filePara.samplesToRecord)
219 break; 188 break;
220 } 189 }
221 } else { 190 } else {
222 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 191 // qDebug("start recording WAVE_FORMAT_PCM");
223 qDebug("start recording WAVE_FORMAT_PCM");
224 short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; 192 short inbuffer[BUFSIZE], outbuffer[BUFSIZE];
225 memset( inbuffer,0,BUFSIZE); 193 memset( inbuffer,0,BUFSIZE);
226 memset( outbuffer,0,BUFSIZE); 194 memset( outbuffer,0,BUFSIZE);
227 for(;;) { 195 for(;;) {
228 if (stopped) { 196 if (stopped) {
229 qDebug("quickRec:: stopped");
230 break; // stop if playing was set to false 197 break; // stop if playing was set to false
231 return;
232 } 198 }
233 199
234 number=::read( filePara.sd, inbuffer, BUFSIZE); 200 number=::read( filePara.sd, inbuffer, BUFSIZE);
235
236 if(number <= 0) { 201 if(number <= 0) {
237 perror("recording error "); 202 perror("recording error ");
238 qDebug( filePara.fileName);
239 recording=stopped=false; 203 recording=stopped=false;
240 // errorStop(); 204 // errorStop();
241// QMessageBox::message("Note","error recording to file\n%s",filePara.fileName);
242 return;// false; 205 return;// false;
243 } 206 }
244/* for (int i=0;i< number;i++) { //2*i is left channel 207/* for (int i=0;i< number;i++) { //2*i is left channel
245
246outbuffer[i]=inbuffer[i]>>1; // no clippy, please 208outbuffer[i]=inbuffer[i]>>1; // no clippy, please
247}*/ 209}*/
248 bytesWritten = ::write( filePara.fd , inbuffer, number); 210 bytesWritten = ::write( filePara.fd , inbuffer, number);
249//------------->>>> out to file 211//------------->>>> out to file
250 if(bytesWritten < 0) { 212 if(bytesWritten < 0) {
251 // errorStop(); 213 // errorStop();
252 perror("File writing error "); 214 perror("File writing error ");
253 return;// false; 215 return;// false;
254 } 216 }
255 217
256 // if(filePara.channels==1) 218 // if(filePara.channels==1)
257 // total += bytesWritten/2; //mono 219 // total += bytesWritten/2; //mono
258 // else 220 // else
259 total += bytesWritten; 221 total += bytesWritten;
260 long peak; 222 long peak;
261 for (int i = 0; i < number; i++) 223 for (int i = 0; i < number; i++)
262 { //since Z is mono do normally 224 { //since Z is mono do normally
263 peak = findPeak((long)inbuffer[i]); 225 peak = findPeak((long)inbuffer[i]);
264 printf("peak %ld\r",peak); 226 printf("peak %ld\r",peak);
265 fflush(stdout); 227 fflush(stdout);
266 } 228 }
267
268
269 filePara.numberSamples = total; 229 filePara.numberSamples = total;
270 if(filePara.SecondsToRecord !=0) 230 if(filePara.SecondsToRecord !=0)
271 timeSlider->setValue( total); 231 timeSlider->setValue( total);
272// 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);
273// fflush(stdout); 233// fflush(stdout);
274 234
275 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); 235 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info);
276// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2); 236// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2);
277 237
278 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 238 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
279
280 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 239 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
281 timeLabel->setText( timeString + " seconds"); 240 timeLabel->setText( timeString + " seconds");
282
283 qApp->processEvents(); 241 qApp->processEvents();
284 if( total >= filePara.samplesToRecord) 242 if( total >= filePara.samplesToRecord)
285 break; 243 break;
286 } 244 }
287 } //end main loop 245 } //end main loop
288 246
289 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 247 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
290 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; 248 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE];
291 memset( unsigned_inbuffer, 0, BUFSIZE); 249 memset( unsigned_inbuffer, 0, BUFSIZE);
292 memset( unsigned_outbuffer, 0, BUFSIZE); 250 memset( unsigned_outbuffer, 0, BUFSIZE);
293 251
294 for(;;) { 252 for(;;) {
295 if (stopped) { 253 if (stopped) {
296 qDebug("quickRec:: stopped"); 254 // qDebug("quickRec:: stopped");
297 break; // stop if playing was set to false 255 break; // stop if playing was set to false
298 } 256 }
299 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 257 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
300//-------------<<<< in from device 258//-------------<<<< in from device
301// val = (data ^ 0x80) << 8; 259// val = (data ^ 0x80) << 8;
302 260
303//unsigned_outbuffer = (unsigned_inbuffer ^ 0x80) << 8; 261//unsigned_outbuffer = (unsigned_inbuffer ^ 0x80) << 8;
304 262
305// if(number <= 0) { 263// if(number <= 0) {
306// perror("recording error "); 264// perror("recording error ");
307// qDebug(filePara.fileName); 265// qDebug(filePara.fileName);
308// // errorStop(); 266// // errorStop();
309// QMessageBox::message("Note","error recording"); 267// QMessageBox::message("Note","error recording");
310// return;// false; 268// return;// false;
311// } 269// }
312// for (int i=0;i< number;i++) { //2*i is left channel 270// for (int i=0;i< number;i++) { //2*i is left channel
313// unsigned_outbuffer[i]=unsigned_inbuffer[i]>>1; // no clippy, please 271// unsigned_outbuffer[i]=unsigned_inbuffer[i]>>1; // no clippy, please
314// } 272// }
315 273
316 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 274 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
317 275
318//------------->>>> out to file 276//------------->>>> out to file
319 if(bytesWritten < 0) { 277 if(bytesWritten < 0) {
320 recording=stopped=false; 278 recording=stopped=false;
321 // errorStop(); 279 // errorStop();
322 QMessageBox::message("Note","There was a problem\nwriting to the file"); 280 QMessageBox::message("Note","There was a problem\nwriting to the file");
323 perror("File writing error "); 281 perror("File writing error ");
324 return;// false; 282 return;// false;
325 } 283 }
326 total += bytesWritten; 284 total += bytesWritten;
327 filePara.numberSamples = total; 285 filePara.numberSamples = total;
328 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); 286 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total);
329 // fflush(stdout); 287 // fflush(stdout);
330 if(filePara.SecondsToRecord !=0) 288 if(filePara.SecondsToRecord !=0)
331 timeSlider->setValue( total); 289 timeSlider->setValue( total);
332 290
333 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 291 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
334 292
335 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 293 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
336 timeLabel->setText( timeString + " seconds"); 294 timeLabel->setText( timeString + " seconds");
337 295
338 qApp->processEvents(); 296 qApp->processEvents();
339 if( total >= filePara.samplesToRecord) 297 if( total >= filePara.samplesToRecord)
340 break; 298 break;
341 } //end main loop 299 } //end main loop
342 } 300 }
343// qDebug("Final %d, %d", filePara.samplesToRecord , filePara.numberOfRecordedSeconds); 301// qDebug("Final %d, %d", filePara.samplesToRecord , filePara.numberOfRecordedSeconds);
344} /// END quickRec() 302} /// END quickRec()
345 303
346// threaded play 304// threaded play
347void playIt() { 305void playIt() {
348 306
349} 307}
350 308
351
352
353/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> 309/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
354/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
355
356QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 310QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
357 : QWidget( parent, name, fl ) { 311 : QWidget( parent, name, fl ) {
358 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device 312 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
359 // autoMute=TRUE; 313 // autoMute=TRUE;
360// QPEApplication::grabKeyboard(); 314// QPEApplication::grabKeyboard();
361 315
362// signal(SIGPIPE, SIG_IGN);
363
364 if ( !name ) 316 if ( !name )
365 setName( "OpieRec" ); 317 setName( "OpieRec" );
366 init(); 318 init();
367 initConfig(); 319 initConfig();
368 initConnections(); 320 initConnections();
369 renameBox = 0; 321 renameBox = 0;
370 322
371// open sound device to get volumes 323// open sound device to get volumes
372 soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false); 324 soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXEROUT, false);
373 325
374// soundDevice->setDeviceFormat(AFMT_S16_LE); 326// soundDevice->setDeviceFormat(AFMT_S16_LE);
375// soundDevice->setDeviceChannels(1); 327// soundDevice->setDeviceChannels(1);
376// soundDevice->setDeviceRate( 22050); 328// soundDevice->setDeviceRate( 22050);
377 329
378 getInVol(); 330 getInVol();
379 getOutVol(); 331 getOutVol();
380 332
381 soundDevice->closeDevice( true); 333 soundDevice->closeDevice( true);
382 soundDevice->sd=-1; 334 soundDevice->sd=-1;
383 soundDevice=0; 335 soundDevice=0;
384 wavFile=0; 336 wavFile=0;
385 337
386 if(soundDevice) delete soundDevice; 338 if(soundDevice) delete soundDevice;
387 339
388 initIconView(); 340 initIconView();
389 341
390 if(autoMute) 342 if(autoMute)
391 doMute(true); 343 doMute(true);
392 ListView1->setFocus(); 344 ListView1->setFocus();
393 playing=false; 345 playing=false;
394} 346}
395 347
396QtRec::~QtRec() { 348QtRec::~QtRec() {
397 349
398} 350}
399 351
400void QtRec::cleanUp() { 352void QtRec::cleanUp() {
401 353
402 if(!stopped) { 354 if(!stopped) {
403 stopped=true; 355 stopped=true;
404 endRecording(); 356 endRecording();
405 } 357 }
406 358
407 ListView1->clear(); 359 ListView1->clear();
408 360
409 if(autoMute) 361 if(autoMute)
410 doMute(false); 362 doMute(false);
411 363
412 if(wavFile) delete wavFile; 364 if(wavFile) delete wavFile;
413// if(soundDevice) delete soundDevice; 365// if(soundDevice) delete soundDevice;
414
415// QPEApplication::grabKeyboard(); 366// QPEApplication::grabKeyboard();
416// QPEApplication::ungrabKeyboard(); 367// QPEApplication::ungrabKeyboard();
417} 368}
418 369
419void QtRec::init() { 370void QtRec::init() {
420 371
421 needsStereoOut=false; 372 needsStereoOut=false;
422 QPixmap image3( ( const char** ) image3_data ); 373 QPixmap image3( ( const char** ) image3_data );
423 QPixmap image4( ( const char** ) image4_data ); 374 QPixmap image4( ( const char** ) image4_data );
424 QPixmap image6( ( const char** ) image6_data ); 375 QPixmap image6( ( const char** ) image6_data );
425 376
426 stopped=true; 377 stopped=true;
427 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 378 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
428 QGridLayout *layout = new QGridLayout( this ); 379 QGridLayout *layout = new QGridLayout( this );
429 layout->setSpacing( 2); 380 layout->setSpacing( 2);
430 layout->setMargin( 2); 381 layout->setMargin( 2);
431 382
432 TabWidget = new QTabWidget( this, "TabWidget" ); 383 TabWidget = new QTabWidget( this, "TabWidget" );
433 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); 384 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7);
434 // TabWidget->setTabShape(QTabWidget::Triangular); 385 // TabWidget->setTabShape(QTabWidget::Triangular);
435 386
436 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 387 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
437 tab = new QWidget( TabWidget, "tab" ); 388 tab = new QWidget( TabWidget, "tab" );
438 389
439 QGridLayout *layout1 = new QGridLayout( tab); 390 QGridLayout *layout1 = new QGridLayout( tab);
440 layout1->setSpacing( 2); 391 layout1->setSpacing( 2);
441 layout1->setMargin( 2); 392 layout1->setMargin( 2);
442 393
443 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 394 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
444 // timeSlider->setFixedWidth(150); 395 // timeSlider->setFixedWidth(150);
445 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 396 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
446// timeSlider->setTickmarks(QSlider::Above); 397// timeSlider->setTickmarks(QSlider::Above);
@@ -725,67 +676,68 @@ void QtRec::init() {
725// help->hide(); 676// help->hide();
726// //help->showMaximized(); 677// //help->showMaximized();
727// QLabel *helpLabel; 678// QLabel *helpLabel;
728// helpLabel = new QLabel( tab_4, "TimeLabel" ); 679// helpLabel = new QLabel( tab_4, "TimeLabel" );
729// layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 ); 680// layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 );
730// helpLabel->setText( "<B>OpieRec</B><br>" 681// helpLabel->setText( "<B>OpieRec</B><br>"
731// "Records files in standard wav format<br>" 682// "Records files in standard wav format<br>"
732// "or a compressed version<br>" 683// "or a compressed version<br>"
733// "For help, please email the author<br>" 684// "For help, please email the author<br>"
734// "<B>OpieRec</B> is copyright&copy; 2002 by" 685// "<B>OpieRec</B> is copyright&copy; 2002 by"
735// " L.J. Potter<br>llornkcor@handhelds.org<BR>" 686// " L.J. Potter<br>llornkcor@handhelds.org<BR>"
736// "and is licensed under the <B>QPL</B>"); 687// "and is licensed under the <B>QPL</B>");
737// } 688// }
738 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 689 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
739 690
740} 691}
741 692
742void QtRec::initIconView() { 693void QtRec::initIconView() {
743 694
744 ListView1->clear(); 695 ListView1->clear();
745 Config cfg("OpieRec"); 696 Config cfg("OpieRec");
746 cfg.setGroup("Sounds"); 697 cfg.setGroup("Sounds");
747 QString temp; 698 QString temp;
748 QPixmap image0( ( const char** ) image0_data ); 699 QPixmap image0( ( const char** ) image0_data );
749 700
750 701
751 int nFiles = cfg.readNumEntry("NumberofFiles",0); 702 int nFiles = cfg.readNumEntry("NumberofFiles",0);
752 for(int i=1;i<= nFiles;i++) { 703 for(int i=1;i<= nFiles;i++) {
753 704
754 QListViewItem * item; 705 QListViewItem * item;
755 QString fileS, mediaLocation, fileDate, filePath; 706 QString fileS, mediaLocation, fileDate, filePath;
756 707
757// temp.sprintf("%d",i); 708 temp.sprintf("%d",i);
758 temp=cfg.readEntry(temp,""); //reads currentFile 709 temp=cfg.readEntry(temp,""); //reads currentFile
759 filePath = cfg.readEntry(temp,""); //currentFileName 710 filePath = cfg.readEntry(temp,""); //currentFileName
711 // qDebug(filePath);
760 712
761 QFileInfo info(filePath); 713 QFileInfo info(filePath);
762 fileDate = info.lastModified().toString(); 714 fileDate = info.lastModified().toString();
763 715
764 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 716 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
765 mediaLocation=getStorage( filePath); 717 mediaLocation=getStorage( filePath);
766 if(info.exists()) { 718 if(info.exists()) {
767 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); 719 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate);
768 item->setPixmap( 0, image0); 720 item->setPixmap( 0, image0);
769 if(currentFileName == filePath) 721 if(currentFileName == filePath)
770 ListView1->setSelected( item, true); 722 ListView1->setSelected( item, true);
771 } 723 }
772 } 724 }
773} 725}
774 726
775void QtRec::initConnections() { 727void QtRec::initConnections() {
776 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 728 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
777 729
778 connect( toBeginningButton, SIGNAL( pressed()), this, SLOT( rewindPressed() )); 730 connect( toBeginningButton, SIGNAL( pressed()), this, SLOT( rewindPressed() ));
779 connect( toBeginningButton, SIGNAL( released()), this, SLOT( rewindReleased() )); 731 connect( toBeginningButton, SIGNAL( released()), this, SLOT( rewindReleased() ));
780 connect( toEndButton, SIGNAL( pressed()), this, SLOT( FastforwardPressed() )); 732 connect( toEndButton, SIGNAL( pressed()), this, SLOT( FastforwardPressed() ));
781 connect( toEndButton, SIGNAL( released()), this, SLOT( FastforwardReleased() )); 733 connect( toEndButton, SIGNAL( released()), this, SLOT( FastforwardReleased() ));
782 connect( deleteSoundButton, SIGNAL(released()), this, SLOT( deleteSound() )); 734 connect( deleteSoundButton, SIGNAL(released()), this, SLOT( deleteSound() ));
783 connect( Stop_PushButton, SIGNAL(released()), this, SLOT( doPlayBtn() )); 735 connect( Stop_PushButton, SIGNAL(released()), this, SLOT( doPlayBtn() ));
784 connect( Rec_PushButton, SIGNAL(released()), this, SLOT( newSound() ) ); 736 connect( Rec_PushButton, SIGNAL(released()), this, SLOT( newSound() ) );
785 connect( TabWidget, SIGNAL( currentChanged( QWidget*)),this, SLOT(thisTab(QWidget*) )); 737 connect( TabWidget, SIGNAL( currentChanged( QWidget*)),this, SLOT(thisTab(QWidget*) ));
786 connect( OutputSlider, SIGNAL(sliderReleased()), this, SLOT( changedOutVolume()) ); 738 connect( OutputSlider, SIGNAL(sliderReleased()), this, SLOT( changedOutVolume()) );
787 connect( InputSlider, SIGNAL(sliderReleased()), this, SLOT( changedInVolume()) ); 739 connect( InputSlider, SIGNAL(sliderReleased()), this, SLOT( changedInVolume()) );
788 740
789 // connect( OutputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedOutVolume(int)) ); 741 // connect( OutputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedOutVolume(int)) );
790 // connect( InputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedInVolume(int)) ); 742 // connect( InputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedInVolume(int)) );
791 743
@@ -830,395 +782,360 @@ void QtRec::initConfig() {
830 782
831 i=cfg.readNumEntry("sizeLimit", 5 ); 783 i=cfg.readNumEntry("sizeLimit", 5 );
832 QString temp; 784 QString temp;
833// for(int i=1;i<13; i++) { 785// for(int i=1;i<13; i++) {
834// temp = sizeLimitCombo->text(i); 786// temp = sizeLimitCombo->text(i);
835 787
836// sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs")); 788// sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs"));
837// } 789// }
838 sizeLimitCombo->setCurrentItem((i/5)); 790 sizeLimitCombo->setCurrentItem((i/5));
839 791
840 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 792 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
841 if( compressionCheckBox->isChecked()) { 793 if( compressionCheckBox->isChecked()) {
842 bitRateComboBox->setEnabled(false); 794 bitRateComboBox->setEnabled(false);
843 bitRateComboBox->setCurrentItem(0); 795 bitRateComboBox->setCurrentItem(0);
844 filePara.resolution=16; 796 filePara.resolution=16;
845 } 797 }
846 798
847 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 799 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
848 if( autoMuteCheckBox->isChecked()) 800 if( autoMuteCheckBox->isChecked())
849 slotAutoMute(true); 801 slotAutoMute(true);
850 else 802 else
851 slotAutoMute(false); 803 slotAutoMute(false);
852 804
853 Config cofg( "qpe"); 805 Config cofg( "qpe");
854 cofg.setGroup( "Volume"); 806 cofg.setGroup( "Volume");
855 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 807 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
856 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 808 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
857} 809}
858 810
859//================ 811//================
860 812
861void QtRec::stop() { 813void QtRec::stop() {
862 qDebug("<<<<<<<<<stop()"); 814 // qDebug("<<<<<<<<<stop()");
863 setRecordButton(false); 815 setRecordButton(false);
864 monitoring=false; 816 monitoring=false;
865 stopped=true; 817 stopped=true;
866 818
867 if( !recording) 819 if( !recording)
868 endPlaying(); 820 endPlaying();
869 else 821 else
870 endRecording(); 822 endRecording();
871 timeSlider->setValue(0); 823 timeSlider->setValue(0);
872 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device 824 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
873} 825}
874 826
875void QtRec::doPlayBtn() { 827void QtRec::doPlayBtn() {
876 828
877 if(!stopped) { 829 if(!stopped) {
878 playLabel2->setText(tr("Play")); 830 playLabel2->setText(tr("Play"));
879 stop(); 831 stop();
880 } else { 832 } else {
881 if(ListView1->currentItem() == 0) return; 833 if(ListView1->currentItem() == 0) return;
882 playLabel2->setText(tr("Stop")); 834 playLabel2->setText(tr("Stop"));
883 currentFile = ListView1->currentItem()->text(0); 835 currentFile = ListView1->currentItem()->text(0);
884 start(); 836 start();
885 } 837 }
886} 838}
887 839
888void QtRec::start() { //play 840void QtRec::start() { //play
889 if(stopped) { 841 if(stopped) {
890 qDebug("start::");
891 QPixmap image3( ( const char** ) image3_data ); 842 QPixmap image3( ( const char** ) image3_data );
892 Stop_PushButton->setPixmap( image3 ); 843 Stop_PushButton->setPixmap( image3 );
893 Stop_PushButton->setDown(true); 844 Stop_PushButton->setDown(true);
894 stopped=false; 845 stopped=false;
895 paused=false; 846 paused=false;
896 secCount=1; 847 secCount=1;
897 848
898 if( openPlayFile()) 849 if( openPlayFile())
899 if( setupAudio( false)) //recording is false 850 if( setupAudio( false)) //recording is false
900 doPlay(); 851 doPlay();
901 } 852 }
902} 853}
903 854
904bool QtRec::rec() { //record 855bool QtRec::rec() { //record
905 qDebug("rec()");
906 if(!stopped) { 856 if(!stopped) {
907 qDebug("rec:: !stopped");
908 monitoring=true; 857 monitoring=true;
909 return false; 858 return false;
910 } else { 859 } else {
911 qDebug("go ahead and record");
912 secCount=1; 860 secCount=1;
913 playLabel2->setText(tr("Stop")); 861 playLabel2->setText(tr("Stop"));
914 monitoring=false; 862 monitoring=false;
915 setRecordButton(true); 863 setRecordButton(true);
916 stopped=false; 864 stopped=false;
917 865
918 if( setupAudio( true)) 866 if( setupAudio( true))
919 if(setUpFile()) { 867 if(setUpFile()) {
920 qDebug("Ok to start recording");
921 int fileSize=0; 868 int fileSize=0;
922 Config cfg("OpieRec"); 869 Config cfg("OpieRec");
923 cfg.setGroup("Settings"); 870 cfg.setGroup("Settings");
924 qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d",
925 soundDevice->getDeviceBits(),
926 soundDevice->getDeviceRate(),
927 soundDevice->getDeviceChannels());
928
929 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 871 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
930 qDebug("sample rate is %d", filePara.sampleRate); 872 // qDebug("sample rate is %d", filePara.sampleRate);
931 filePara.SecondsToRecord = getCurrentSizeLimit(); 873 filePara.SecondsToRecord = getCurrentSizeLimit();
932 874
933 qDebug("size limit %d sec", filePara.SecondsToRecord);
934 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 875 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
935 876
936 if( filePara.SecondsToRecord == 0) { 877 if( filePara.SecondsToRecord == 0) {
937 fileSize = diskSize; 878 fileSize = diskSize;
938 } else if( filePara.format==WAVE_FORMAT_PCM) { 879 } else if( filePara.format==WAVE_FORMAT_PCM) {
939 qDebug("WAVE_FORMAT_PCM");
940 fileSize = (filePara.SecondsToRecord ) * filePara.channels 880 fileSize = (filePara.SecondsToRecord ) * filePara.channels
941 * filePara.sampleRate *(filePara.resolution/8)+1000; 881 * filePara.sampleRate *(filePara.resolution/8)+1000;
942 } else { 882 } else {
943 qDebug("WAVE_FORMAT_DVI_ADPCM");
944 fileSize = ((filePara.SecondsToRecord) * filePara.channels 883 fileSize = ((filePara.SecondsToRecord) * filePara.channels
945 * filePara.sampleRate *(filePara.resolution/8) )/4+250; 884 * filePara.sampleRate *(filePara.resolution/8) )/4+250;
946 } 885 }
947 886
948 filePara.samplesToRecord = fileSize; 887 filePara.samplesToRecord = fileSize;
949 qDebug("filesize should be %d, bits %d, rate %d",
950 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
951 if(paused) { 888 if(paused) {
952 paused = false; 889 paused = false;
953 } 890 }
954 // else {
955 qDebug("Setting timeslider %d", filePara.samplesToRecord);
956 // if(fileSize != 0)
957 timeSlider->setRange(0, filePara.samplesToRecord); 891 timeSlider->setRange(0, filePara.samplesToRecord);
958 // }
959 892
960 if( diskSize < fileSize/1024) { 893 if( diskSize < fileSize/1024) {
961 QMessageBox::warning(this, 894 QMessageBox::warning(this,
962 tr("Low Disk Space"), 895 tr("Low Disk Space"),
963 tr("You are running low of\nrecording space\n" 896 tr("You are running low of\nrecording space\n"
964 "or a card isn't being recognized")); 897 "or a card isn't being recognized"));
965 stopped = true; //we need to be stopped 898 stopped = true; //we need to be stopped
966 stop(); 899 stop();
967 } else { 900 } else {
968 QString msg; 901 QString msg;
969 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 902 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
970#ifdef DEV_VERSION 903#ifdef DEV_VERSION
971 setCaption( msg); 904 setCaption( msg);
972#endif 905#endif
973 filePara.fileName=currentFile.latin1(); 906 filePara.fileName=currentFile.latin1();
974 qDebug("Start recording thread");
975 907
976 pthread_t thread1; 908 pthread_t thread1;
977 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 909 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
978// quickRec();
979 toBeginningButton->setEnabled(false); 910 toBeginningButton->setEnabled(false);
980 toEndButton->setEnabled(false); 911 toEndButton->setEnabled(false);
981 912
982 startTimer(1000); 913 startTimer(1000);
983 } 914 }
984 } //end setUpFile 915 } //end setUpFile
985 } //end setupAudio 916 } //end setupAudio
986 // _exit( 0); 917 // _exit( 0);
987 918
988 // ///* default: 919 // ///* default:
989// // /* pid greater than zero is parent getting the child's pid */ 920// // /* pid greater than zero is parent getting the child's pid */
990// /* printf("Child's pid is %d\n",pid); 921// /* printf("Child's pid is %d\n",pid);
991// waitpid( pid, &status, 0); 922// waitpid( pid, &status, 0);
992// printf("Child[%d] exited with status %d\n", pid, status);*/ 923// printf("Child[%d] exited with status %d\n", pid, status);*/
993 // while (wait(NULL) != pid) 924 // while (wait(NULL) != pid)
994// ; 925// ;
995// printf("child %ld terminated normally, return status is zero\n", (long) pid); 926// printf("child %ld terminated normally, return status is zero\n", (long) pid);
996 // endRecording(); 927 // endRecording();
997/* else { //device was not opened 928/* else { //device was not opened
998 qDebug("Audio device open failed"); 929 qDebug("Audio device open failed");
999 return false; 930 return false;
1000 } 931 }
1001 }*/ 932 }*/
1002// } //end fork 933// } //end fork
1003// } 934// }
1004// } 935// }
1005 return true; 936 return true;
1006} 937}
1007/* 938/*
1008 This happens when a tab is selected*/ 939 This happens when a tab is selected*/
1009void QtRec::thisTab(QWidget* widg) { 940void QtRec::thisTab(QWidget* widg) {
1010 if(widg != NULL) { 941 if(widg != NULL) {
1011 int index=TabWidget->currentPageIndex(); 942 int index=TabWidget->currentPageIndex();
1012 943
1013 if(index==0) { //file page 944// if(index==0) { //file page
1014 } 945// }
1015 946
1016 if(index ==1) { //control page 947 if(index ==1) { //control page
1017 fillDirectoryCombo(); 948 fillDirectoryCombo();
1018// soundDevice->getOutVol(); 949// soundDevice->getOutVol();
1019// soundDevice->getInVol(); 950// soundDevice->getInVol();
1020 } 951 }
1021 952
1022 if(index==2) { //help page 953// if(index==2) { //help page
1023 } 954// }
1024 qApp->processEvents(); 955 qApp->processEvents();
1025 update(); 956 update();
1026 } 957 }
1027} 958}
1028 959
1029void QtRec::getOutVol( ) { 960void QtRec::getOutVol( ) {
1030 filePara.outVol = soundDevice->getOutVolume(); 961 filePara.outVol = soundDevice->getOutVolume();
1031 qDebug("out vol %d", filePara.outVol);
1032 OutputSlider->setValue( -filePara.outVol); 962 OutputSlider->setValue( -filePara.outVol);
1033} 963}
1034 964
1035void QtRec::getInVol() { 965void QtRec::getInVol() {
1036 filePara.inVol = soundDevice->getInVolume(); 966 filePara.inVol = soundDevice->getInVolume();
1037 qDebug("in vol %d", filePara.inVol);
1038 InputSlider->setValue( -filePara.inVol); 967 InputSlider->setValue( -filePara.inVol);
1039} 968}
1040 969
1041void QtRec::changedOutVolume() { 970void QtRec::changedOutVolume() {
1042 soundDevice->changedOutVolume(-OutputSlider->value()); 971 soundDevice->changedOutVolume(-OutputSlider->value());
1043} 972}
1044 973
1045void QtRec::changedInVolume( ) { 974void QtRec::changedInVolume( ) {
1046 soundDevice->changedInVolume( -InputSlider->value()); 975 soundDevice->changedInVolume( -InputSlider->value());
1047} 976}
1048 977
1049 978
1050bool QtRec::setupAudio( bool b) { 979bool QtRec::setupAudio( bool b) {
1051 bool ok; 980 bool ok;
1052 int sampleformat, stereo, flags; 981 int sampleformat, stereo, flags;
1053 char * dspString, *mixerString; 982 char * dspString, *mixerString;
1054 983
1055 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 984 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
1056 985
1057 if( !b){ // we want to play 986 if( !b){ // we want to play
1058 qDebug("setting up DSP for playing");
1059 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 987 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1060 sampleformat = AFMT_S16_LE; 988 sampleformat = AFMT_S16_LE;
1061 filePara.resolution = 16; 989 filePara.resolution = 16;
1062 } else { 990 } else {
1063 sampleformat = AFMT_U8; 991 sampleformat = AFMT_U8;
1064 filePara.resolution=8; 992 filePara.resolution=8;
1065 } 993 }
1066 994
1067 stereo = filePara.channels = 1; 995 stereo = filePara.channels = 1;
1068 flags= O_WRONLY; 996 flags= O_WRONLY;
1069 dspString = DSPSTROUT; 997 dspString = DSPSTROUT;
1070 mixerString = DSPSTRMIXEROUT; 998 mixerString = DSPSTRMIXEROUT;
1071 } else { // we want to record 999 } else { // we want to record
1072 qDebug("setting up DSP for recording");
1073 1000
1074 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1001 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1075 sampleformat = AFMT_S16_LE; 1002 sampleformat = AFMT_S16_LE;
1076 else 1003 else
1077 sampleformat = AFMT_U8; 1004 sampleformat = AFMT_U8;
1078 1005
1079 if( !compressionCheckBox->isChecked()) { 1006 if( !compressionCheckBox->isChecked()) {
1080 filePara.format=WAVE_FORMAT_PCM; 1007 filePara.format=WAVE_FORMAT_PCM;
1081 qDebug("WAVE_FORMAT_PCM");
1082 } else { 1008 } else {
1083 filePara.format=WAVE_FORMAT_DVI_ADPCM; 1009 filePara.format=WAVE_FORMAT_DVI_ADPCM;
1084 sampleformat=AFMT_S16_LE; 1010 sampleformat=AFMT_S16_LE;
1085 qDebug("WAVE_FORMAT_DVI_ADPCM");
1086 } 1011 }
1087 1012
1088 stereo = filePara.channels = 1; 1013 stereo = filePara.channels = 1;
1089// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1090 flags= O_RDWR; 1014 flags= O_RDWR;
1091// flags= O_RDONLY;
1092 dspString = DSPSTRIN; 1015 dspString = DSPSTRIN;
1093 mixerString = DSPSTRMIXEROUT; 1016 mixerString = DSPSTRMIXEROUT;
1094 } 1017 }
1095 1018
1096 // if(soundDevice) delete soundDevice; 1019 // if(soundDevice) delete soundDevice;
1097 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat);
1098 soundDevice = new Device( this, dspString, mixerString, b); 1020 soundDevice = new Device( this, dspString, mixerString, b);
1099// soundDevice->openDsp(); 1021// soundDevice->openDsp();
1100 soundDevice->reset(); 1022 soundDevice->reset();
1101 1023
1102 qDebug("device has been made %d", soundDevice->sd);
1103
1104 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1105 soundDevice->setDeviceFormat( sampleformat); 1024 soundDevice->setDeviceFormat( sampleformat);
1106 soundDevice->setDeviceChannels( filePara.channels); 1025 soundDevice->setDeviceChannels( filePara.channels);
1107 soundDevice->setDeviceRate( filePara.sampleRate); 1026 soundDevice->setDeviceRate( filePara.sampleRate);
1108 soundDevice->getDeviceFragSize(); 1027 soundDevice->getDeviceFragSize();
1109#ifdef QT_QWS_EBX 1028#ifdef QT_QWS_EBX
1110 int frag = FRAGSIZE; 1029 int frag = FRAGSIZE;
1111 soundDevice->setFragSize( frag); 1030 soundDevice->setFragSize( frag);
1112 soundDevice->getDeviceFragSize(); 1031 soundDevice->getDeviceFragSize();
1113#endif 1032#endif
1114 ///////////////// 1033
1115 filePara.sd = soundDevice->sd; 1034 filePara.sd = soundDevice->sd;
1116 1035
1117 if ( filePara.sd == -1) { 1036 if ( filePara.sd == -1) {
1118
1119 monitoring=false; 1037 monitoring=false;
1120 stopped=true; 1038 stopped=true;
1121 update(); 1039 update();
1122 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1040 setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ );
1123 stopped=true; 1041 stopped=true;
1124 return false; 1042 return false;
1125 } 1043 }
1126 if(autoMute) 1044 if(autoMute)
1127 doMute(false); 1045 doMute(false);
1128 1046
1129 return true; 1047 return true;
1130} 1048}
1131 1049
1132 1050
1133bool QtRec::setUpFile() { //setup file for recording 1051bool QtRec::setUpFile() { //setup file for recording
1134 qDebug("Setting up wavfile"); 1052 // qDebug("Setting up wavfile");
1135// if(wavFile) delete wavFile; 1053// if(wavFile) delete wavFile;
1136 wavFile = new WavFile( this, (const QString &)"", 1054 wavFile = new WavFile( this, (const QString &)"",
1137 true, 1055 true,
1138 filePara.sampleRate, 1056 filePara.sampleRate,
1139 filePara.channels, 1057 filePara.channels,
1140 filePara.resolution, 1058 filePara.resolution,
1141 filePara.format); 1059 filePara.format);
1142 1060
1143 filePara.fd = wavFile->wavHandle(); 1061 filePara.fd = wavFile->wavHandle();
1144 if(filePara.fd == -1) { 1062 if(filePara.fd == -1) {
1145 return false; 1063 return false;
1146 } else { 1064 } else {
1147 filePara.channels=1; 1065 filePara.channels=1;
1148 } 1066 }
1149 return true; 1067 return true;
1150} 1068}
1151 1069
1152/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1070/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1153bool QtRec::doPlay() { 1071bool QtRec::doPlay() {
1154 1072
1155// pthread_t thread2; 1073// pthread_t thread2;
1156// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1074// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1157 1075
1158 // qDebug("doPlay file %d", filePara.fd); 1076 // qDebug("doPlay file %d", filePara.fd);
1159 int bytesWritten, number; 1077 int bytesWritten, number;
1160 recording = false; 1078 recording = false;
1161// int number=0; 1079// int number=0;
1162 if( !paused) { 1080 if( !paused) {
1163 qDebug("new"); 1081 // qDebug("new");
1164 total=0; 1082 total=0;
1165 bytesWritten=0; 1083 bytesWritten=0;
1166 filePara.numberOfRecordedSeconds = 0; 1084 filePara.numberOfRecordedSeconds = 0;
1167 } else { 1085 } else {
1168 paused = false; 1086 paused = false;
1169 secCount = (int)filePara.numberOfRecordedSeconds; 1087 secCount = (int)filePara.numberOfRecordedSeconds;
1170 } 1088 }
1171 playing=true; 1089 playing=true;
1172 number=0; 1090 number=0;
1173 1091
1174 QString num; 1092 QString num;
1175// block=BUFSIZE; 1093// block=BUFSIZE;
1176 qDebug("Play number of samples %d", filePara.numberSamples);
1177 timeSlider->setRange(0, filePara.numberSamples); 1094 timeSlider->setRange(0, filePara.numberSamples);
1178 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1095 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1179 timeLabel->setText( timeString+ tr(" seconds")); 1096 timeLabel->setText( timeString+ tr(" seconds"));
1180 1097
1181 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 1098// if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
1182 qDebug("WAVE_FORMAT_DVI_ADPCM"); 1099// // qDebug("WAVE_FORMAT_DVI_ADPCM");
1183 } else { 1100// } else {
1184 qDebug("WAVE_FORMAT_PCM"); 1101// // qDebug("WAVE_FORMAT_PCM");
1185 } 1102// }
1186 QString msg; 1103 QString msg;
1187 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1104 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1188#ifdef DEV_VERSION 1105#ifdef DEV_VERSION
1189 setCaption( msg); 1106 setCaption( msg);
1190#endif 1107#endif
1191 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 1108 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
1192 qDebug("16 bit"); 1109 // qDebug("16 bit");
1193 1110
1194 startTimer(1000); 1111 startTimer(1000);
1195 1112
1196 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 1113 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
1197 char abuf[BUFSIZE/2]; 1114 char abuf[BUFSIZE/2];
1198 short sbuf[BUFSIZE]; 1115 short sbuf[BUFSIZE];
1199 short sbuf2[BUFSIZE*2]; 1116 short sbuf2[BUFSIZE*2];
1200 memset( abuf, 0, BUFSIZE / 2); 1117 memset( abuf, 0, BUFSIZE / 2);
1201 memset( sbuf, 0, BUFSIZE); 1118 memset( sbuf, 0, BUFSIZE);
1202 memset( sbuf2, 0, BUFSIZE * 2); 1119 memset( sbuf2, 0, BUFSIZE * 2);
1203// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 1120// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
1204 for(;;) { // play loop 1121 for(;;) { // play loop
1205 if (stopped) 1122 if (stopped)
1206 break; // stop if playing was set to false 1123 break; // stop if playing was set to false
1207 1124
1208 1125
1209 number=::read( filePara.fd, abuf, BUFSIZE/2); 1126 number=::read( filePara.fd, abuf, BUFSIZE/2);
1210 adpcm_decoder( abuf, sbuf, number*2, &decoder_state); 1127 adpcm_decoder( abuf, sbuf, number*2, &decoder_state);
1211 1128
1212// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 1129// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
1213// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 1130// sbuf2[i+1]=sbuf2[i]=sbuf[i];
1214// } 1131// }
1215 1132
1216 bytesWritten = write ( filePara.sd, sbuf, number*4); 1133 bytesWritten = write ( filePara.sd, sbuf, number*4);
1217 // if(filePara.channels==1) 1134 // if(filePara.channels==1)
1218 // total += bytesWritten/2; //mono 1135 // total += bytesWritten/2; //mono
1219 // else 1136 // else
1220 total += bytesWritten; 1137 total += bytesWritten;
1221 timeSlider->setValue( total / 4); 1138 timeSlider->setValue( total / 4);
1222 1139
1223 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 1140 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
1224 1141
@@ -1248,65 +1165,65 @@ bool QtRec::doPlay() {
1248 break; // stop if playing was set to false 1165 break; // stop if playing was set to false
1249 number=::read( filePara.fd, inbuffer, BUFSIZE); 1166 number=::read( filePara.fd, inbuffer, BUFSIZE);
1250// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 1167// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
1251// // for (int i=0;i< number ; i++) { //2*i is left channel 1168// // for (int i=0;i< number ; i++) { //2*i is left channel
1252// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 1169// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
1253// } 1170// }
1254 1171
1255 bytesWritten = ::write( filePara.sd, inbuffer, number); 1172 bytesWritten = ::write( filePara.sd, inbuffer, number);
1256 //-------------->>>> out to device 1173 //-------------->>>> out to device
1257 // total+=bytesWritten; 1174 // total+=bytesWritten;
1258 // if(filePara.channels==1) 1175 // if(filePara.channels==1)
1259 // total += bytesWritten/2; //mono 1176 // total += bytesWritten/2; //mono
1260 // else 1177 // else
1261 total += bytesWritten; 1178 total += bytesWritten;
1262 1179
1263 timeSlider->setValue( total); 1180 timeSlider->setValue( total);
1264 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 1181 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
1265 1182
1266 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 1183 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
1267 timeLabel->setText( timeString + tr(" seconds")); 1184 timeLabel->setText( timeString + tr(" seconds"));
1268 1185
1269 qApp->processEvents(); 1186 qApp->processEvents();
1270 1187
1271 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) { 1188 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) {
1272 stopped = true; 1189 stopped = true;
1273 endPlaying(); 1190 endPlaying();
1274 } 1191 }
1275 } 1192 }
1276// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 1193// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
1277// fflush(stdout); 1194// fflush(stdout);
1278 } //end loop 1195 } //end loop
1279 } else { /////////////////////////////// format = AFMT_U8; 1196 } else { /////////////////////////////// format = AFMT_U8;
1280 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; 1197 unsigned char unsigned_inbuffer[BUFSIZE];//, unsigned_outbuffer[BUFSIZE];
1281 memset( unsigned_inbuffer,0,BUFSIZE); 1198 memset( unsigned_inbuffer,0,BUFSIZE);
1282 for(;;) { // main loop 1199 for(;;) { // main loop
1283 if (stopped) 1200 if (stopped)
1284 break; // stop if playing was set to false 1201 break; // stop if playing was set to false
1285 number=::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 1202 number=::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
1286//data = (val >> 8) ^ 0x80; 1203//data = (val >> 8) ^ 0x80;
1287 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 1204 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
1288 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 1205 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
1289 total+=bytesWritten; 1206 total+=bytesWritten;
1290 1207
1291 timeSlider->setValue( total); 1208 timeSlider->setValue( total);
1292 1209
1293 filePara.numberOfRecordedSeconds=(float)total/(float)filePara.sampleRate; 1210 filePara.numberOfRecordedSeconds=(float)total/(float)filePara.sampleRate;
1294 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 1211 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
1295 timeLabel->setText( timeString + tr(" seconds")); 1212 timeLabel->setText( timeString + tr(" seconds"));
1296 qApp->processEvents(); 1213 qApp->processEvents();
1297 1214
1298 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) { 1215 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) {
1299 stopped = true; 1216 stopped = true;
1300 endPlaying(); 1217 endPlaying();
1301 } 1218 }
1302 // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 1219 // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
1303 // fflush(stdout); 1220 // fflush(stdout);
1304 } 1221 }
1305 } 1222 }
1306 1223
1307// qDebug("\nstopped or paused %d", total/4); 1224// qDebug("\nstopped or paused %d", total/4);
1308 if(!paused && !stopped) { 1225 if(!paused && !stopped) {
1309 stopped = true; 1226 stopped = true;
1310// endPlaying(); 1227// endPlaying();
1311 endPlaying(); 1228 endPlaying();
1312 } 1229 }
@@ -1314,104 +1231,104 @@ bool QtRec::doPlay() {
1314} 1231}
1315 1232
1316 1233
1317void QtRec::changebitrateCombo(int i) { 1234void QtRec::changebitrateCombo(int i) {
1318 Config cfg("OpieRec"); 1235 Config cfg("OpieRec");
1319 cfg.setGroup("Settings"); 1236 cfg.setGroup("Settings");
1320 int bits=0; 1237 int bits=0;
1321 if(i==0) { bits=16; } 1238 if(i==0) { bits=16; }
1322 else { bits=8; } 1239 else { bits=8; }
1323 cfg.writeEntry("bitrate", bits); 1240 cfg.writeEntry("bitrate", bits);
1324 filePara.resolution=bits; 1241 filePara.resolution=bits;
1325 cfg.write(); 1242 cfg.write();
1326} 1243}
1327 1244
1328void QtRec::changesamplerateCombo(int i) { 1245void QtRec::changesamplerateCombo(int i) {
1329 Config cfg("OpieRec"); 1246 Config cfg("OpieRec");
1330 cfg.setGroup("Settings"); 1247 cfg.setGroup("Settings");
1331 int rate=0; 1248 int rate=0;
1332 bool ok; 1249 bool ok;
1333 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1250 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1334 cfg.writeEntry("samplerate",rate); 1251 cfg.writeEntry("samplerate",rate);
1335 filePara.sampleRate=rate; 1252 filePara.sampleRate=rate;
1336/* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false); 1253/* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false);
1337 soundDevice->openDsp();*/ 1254 soundDevice->openDsp();*/
1338// 1255//
1339// soundDevice->setDeviceFormat(AFMT_S16_LE); 1256// soundDevice->setDeviceFormat(AFMT_S16_LE);
1340// soundDevice->setDeviceChannels(filePara.channels); 1257// soundDevice->setDeviceChannels(filePara.channels);
1341// soundDevice->setDeviceRate(filePara.sampleRate); 1258// soundDevice->setDeviceRate(filePara.sampleRate);
1342// 1259//
1343// soundDevice->closeDevice( true); 1260// soundDevice->closeDevice( true);
1344// soundDevice=0; 1261// soundDevice=0;
1345// delete soundDevice; 1262// delete soundDevice;
1346 qDebug("Change sample rate %d", rate); 1263 // qDebug("Change sample rate %d", rate);
1347 cfg.write(); 1264 cfg.write();
1348 1265
1349} 1266}
1350 1267
1351 1268
1352void QtRec::changeDirCombo(int index) { 1269void QtRec::changeDirCombo(int index) {
1353 Config cfg("OpieRec"); 1270 Config cfg("OpieRec");
1354 cfg.setGroup("Settings"); 1271 cfg.setGroup("Settings");
1355 QString sName = directoryComboBox->text(index); 1272 QString sName = directoryComboBox->text(index);
1356 1273
1357 StorageInfo storageInfo; 1274 StorageInfo storageInfo;
1358 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1275 const QList<FileSystem> &fs = storageInfo.fileSystems();
1359 QListIterator<FileSystem> it ( fs ); 1276 QListIterator<FileSystem> it ( fs );
1360 QString storage; 1277 QString storage;
1361 for( ; it.current(); ++it ){ 1278 for( ; it.current(); ++it ){
1362 if( sName == (*it)->name()+" "+ (*it)->path() || 1279 if( sName == (*it)->name()+" "+ (*it)->path() ||
1363 (*it)->name() == sName ) { 1280 (*it)->name() == sName ) {
1364 const QString path = (*it)->path(); 1281 const QString path = (*it)->path();
1365 recDir = path; 1282 recDir = path;
1366 cfg.writeEntry("directory", recDir); 1283 cfg.writeEntry("directory", recDir);
1367 qDebug("new rec dir "+recDir); 1284 // qDebug("new rec dir "+recDir);
1368 } 1285 }
1369 } 1286 }
1370 cfg.write(); 1287 cfg.write();
1371} 1288}
1372 1289
1373 1290
1374void QtRec::changeSizeLimitCombo(int) { 1291void QtRec::changeSizeLimitCombo(int) {
1375 Config cfg("OpieRec"); 1292 Config cfg("OpieRec");
1376 cfg.setGroup("Settings"); 1293 cfg.setGroup("Settings");
1377 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1294 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1378 cfg.write(); 1295 cfg.write();
1379} 1296}
1380 1297
1381void QtRec::newSound() { 1298void QtRec::newSound() {
1382 qDebug("<<<<<<<<<new sound"); 1299 // qDebug("<<<<<<<<<new sound");
1383 1300
1384 if( !rec()) { 1301 if( !rec()) {
1385 qDebug("rec() failed"); 1302 // qDebug("rec() failed");
1386 endRecording(); 1303 endRecording();
1387 deleteSound(); 1304 deleteSound();
1388 } 1305 }
1389 1306
1390} 1307}
1391 1308
1392void QtRec::itClick(QListViewItem *item) { 1309void QtRec::itClick(QListViewItem *item) {
1393 currentFile=item->text(0); 1310 currentFile=item->text(0);
1394 setCaption("OpieRecord "+currentFile); 1311 setCaption("OpieRecord "+currentFile);
1395} 1312}
1396 1313
1397void QtRec::deleteSound() { 1314void QtRec::deleteSound() {
1398 Config cfg("OpieRec"); 1315 Config cfg("OpieRec");
1399 cfg.setGroup("Sounds"); 1316 cfg.setGroup("Sounds");
1400 if( ListView1->currentItem() == NULL) 1317 if( ListView1->currentItem() == NULL)
1401 return; 1318 return;
1402#ifndef DEV_VERSION 1319#ifndef DEV_VERSION
1403 switch ( QMessageBox::warning(this,tr("Delete"), 1320 switch ( QMessageBox::warning(this,tr("Delete"),
1404 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), 1321 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"),
1405 tr("Yes"),tr("No"),0,1,1) ) { 1322 tr("Yes"),tr("No"),0,1,1) ) {
1406 case 0: 1323 case 0:
1407#endif 1324#endif
1408 { 1325 {
1409 QString file = ListView1->currentItem()->text(0); 1326 QString file = ListView1->currentItem()->text(0);
1410 // qDebug("Filename to find is "+file); 1327 // qDebug("Filename to find is "+file);
1411 QString fileName; 1328 QString fileName;
1412 fileName = cfg.readEntry( file, ""); 1329 fileName = cfg.readEntry( file, "");
1413 QFile f(fileName); 1330 QFile f(fileName);
1414 // qDebug("fileName is "+fileName); 1331 // qDebug("fileName is "+fileName);
1415 if(f.exists()) 1332 if(f.exists())
1416 if( !f.remove()) 1333 if( !f.remove())
1417 QMessageBox::message(tr("Error"),tr("Could not remove file.")); 1334 QMessageBox::message(tr("Error"),tr("Could not remove file."));
@@ -1419,327 +1336,327 @@ void QtRec::deleteSound() {
1419 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1336 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1420 bool found=false; 1337 bool found=false;
1421 for(int i=0;i<nFiles+1;i++) { 1338 for(int i=0;i<nFiles+1;i++) {
1422 // qDebug(cfg.readEntry(QString::number(i))); 1339 // qDebug(cfg.readEntry(QString::number(i)));
1423 1340
1424 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1341 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1425 found = true; 1342 found = true;
1426// qDebug( cfg.readEntry(QString::number(i))+"\n" +cfg.readEntry(QString::number(i+1)) ); 1343// qDebug( cfg.readEntry(QString::number(i))+"\n" +cfg.readEntry(QString::number(i+1)) );
1427 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1344 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1428 } 1345 }
1429 if(found) 1346 if(found)
1430 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1347 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1431 } 1348 }
1432 1349
1433 cfg.removeEntry(cfg.readEntry(file)); 1350 cfg.removeEntry(cfg.readEntry(file));
1434 cfg.removeEntry( file); 1351 cfg.removeEntry( file);
1435 // cfg.removeEntry( QString::number(nFiles)); 1352 // cfg.removeEntry( QString::number(nFiles));
1436 cfg.writeEntry("NumberofFiles", nFiles-1); 1353 cfg.writeEntry("NumberofFiles", nFiles-1);
1437 cfg.write(); 1354 cfg.write();
1438 1355
1439 ListView1->takeItem( ListView1->currentItem() ); 1356 ListView1->takeItem( ListView1->currentItem() );
1440 // ListView1->takeItem( ListView1->itemAt(nFiles) ); 1357 // ListView1->takeItem( ListView1->itemAt(nFiles) );
1441 delete ListView1->currentItem(); 1358 delete ListView1->currentItem();
1442 1359
1443 ListView1->clear(); 1360 ListView1->clear();
1444 ListView1->setSelected(ListView1->firstChild(), true); 1361 ListView1->setSelected(ListView1->firstChild(), true);
1445 initIconView(); 1362 initIconView();
1446 update(); 1363 update();
1447 } 1364 }
1448#ifndef DEV_VERSION 1365#ifndef DEV_VERSION
1449 }; 1366 };
1450#endif 1367#endif
1451 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1368 setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ );
1452 1369
1453} 1370}
1454 1371
1455void QtRec::keyPressEvent( QKeyEvent *e) { 1372void QtRec::keyPressEvent( QKeyEvent *e) {
1456 1373
1457 switch ( e->key() ) { 1374 switch ( e->key() ) {
1458 /* 1375 /*
1459 vercel keys-> 1376 vercel keys->
1460 right side 1377 right side
1461 0 1378 0
1462 1 0x1030 Key_F1 1379 1 0x1030 Key_F1
1463 2 0x1031 Key_F2 1380 2 0x1031 Key_F2
1464 3 0x1032 Key_F3 1381 3 0x1032 Key_F3
1465 4 0x1016 Key_PageUp 1382 4 0x1016 Key_PageUp
1466 5 0x1017 Key_PageDown 1383 5 0x1017 Key_PageDown
1467 6 1384 6
1468 --------------- 1385 ---------------
1469 left side 1386 left side
1470 Up 0x1013 Key_Up 1387 Up 0x1013 Key_Up
1471 Down 0x1015 Key_Down 1388 Down 0x1015 Key_Down
1472 Left 0x1012 Key_Left 1389 Left 0x1012 Key_Left
1473 Right 0x1014 Key_Right 1390 Right 0x1014 Key_Right
1474 0x1010 Key_Home 1391 0x1010 Key_Home
1475 1392
1476 */ 1393 */
1477 // case Key_F1: 1394 // case Key_F1:
1478 // if(stopped && !recording) 1395 // if(stopped && !recording)
1479 // newSound(); 1396 // newSound();
1480 // else 1397 // else
1481 // stop(); 1398 // stop();
1482 // break; 1399 // break;
1483 // case Key_F2: { 1400 // case Key_F2: {
1484 // if( !e->isAutoRepeat()) 1401 // if( !e->isAutoRepeat())
1485 // rewindPressed(); 1402 // rewindPressed();
1486 // } 1403 // }
1487 // break; 1404 // break;
1488 // case Key_F3: { 1405 // case Key_F3: {
1489 // if( !e->isAutoRepeat()) 1406 // if( !e->isAutoRepeat())
1490 // FastforwardPressed(); 1407 // FastforwardPressed();
1491 // } 1408 // }
1492 // break; 1409 // break;
1493 1410
1494 ////////////////////////////// Zaurus keys 1411 ////////////////////////////// Zaurus keys
1495 case Key_F9: //activity 1412 case Key_F9: //activity
1496 break; 1413 break;
1497 case Key_F10: //contacts 1414 case Key_F10: //contacts
1498 break; 1415 break;
1499 case Key_F11: //menu 1416 case Key_F11: //menu
1500 break; 1417 break;
1501 case Key_F12: //home 1418 case Key_F12: //home
1502 break; 1419 break;
1503 case Key_F13: //mail 1420 case Key_F13: //mail
1504 break; 1421 break;
1505 case Key_Space: 1422 case Key_Space:
1506 break; 1423 break;
1507 case Key_Delete: 1424 case Key_Delete:
1508 break; 1425 break;
1509 case Key_Up: 1426 case Key_Up:
1510 // stop(); 1427 // stop();
1511 break; 1428 break;
1512 case Key_Down: 1429 case Key_Down:
1513 // newSound(); 1430 // newSound();
1514 break; 1431 break;
1515 case Key_Left: { 1432 case Key_Left: {
1516 qDebug("rewinding"); 1433 // qDebug("rewinding");
1517 if( !e->isAutoRepeat()) 1434 if( !e->isAutoRepeat())
1518 rewindPressed(); 1435 rewindPressed();
1519 } 1436 }
1520 break; 1437 break;
1521 case Key_Right: { 1438 case Key_Right: {
1522 if( !e->isAutoRepeat()) 1439 if( !e->isAutoRepeat())
1523 FastforwardPressed(); 1440 FastforwardPressed();
1524 } 1441 }
1525 break; 1442 break;
1526 } 1443 }
1527} 1444}
1528 1445
1529void QtRec::keyReleaseEvent( QKeyEvent *e) { 1446void QtRec::keyReleaseEvent( QKeyEvent *e) {
1530 switch ( e->key() ) { 1447 switch ( e->key() ) {
1531 // case Key_F1: 1448 // case Key_F1:
1532 // if(stopped && !recording) 1449 // if(stopped && !recording)
1533 // newSound(); 1450 // newSound();
1534 // else 1451 // else
1535 // stop(); 1452 // stop();
1536 // break; 1453 // break;
1537 // case Key_F2: 1454 // case Key_F2:
1538 // rewindReleased(); 1455 // rewindReleased();
1539 // break; 1456 // break;
1540 // case Key_F3: 1457 // case Key_F3:
1541 // FastforwardReleased(); 1458 // FastforwardReleased();
1542 // break; 1459 // break;
1543 1460
1544 ////////////////////////////// Zaurus keys 1461 ////////////////////////////// Zaurus keys
1545 case Key_F9: //activity 1462 case Key_F9: //activity
1546 break; 1463 break;
1547 case Key_F10: //contacts 1464 case Key_F10: //contacts
1548 break; 1465 break;
1549 case Key_F11: //menu 1466 case Key_F11: //menu
1550 break; 1467 break;
1551 case Key_F12: //home 1468 case Key_F12: //home
1552 if(stopped) 1469 if(stopped)
1553 doPlayBtn(); 1470 doPlayBtn();
1554 else 1471 else
1555 stop(); 1472 stop();
1556 break; 1473 break;
1557 case Key_F13: //mail 1474 case Key_F13: //mail
1558 break; 1475 break;
1559 case Key_Space: 1476 case Key_Space:
1560 if(stopped && !recording) 1477 if(stopped && !recording)
1561 newSound(); 1478 newSound();
1562 else 1479 else
1563 stop(); 1480 stop();
1564 break; 1481 break;
1565 case Key_Delete: 1482 case Key_Delete:
1566 deleteSound(); 1483 deleteSound();
1567 break; 1484 break;
1568 case Key_Up: 1485 case Key_Up:
1569 // stop(); 1486 // stop();
1570 qDebug("Up"); 1487 // qDebug("Up");
1571 break; 1488 break;
1572 case Key_Down: 1489 case Key_Down:
1573 // start(); 1490 // start();
1574 // qDebug("Down"); 1491 // qDebug("Down");
1575 // newSound(); 1492 // newSound();
1576 break; 1493 break;
1577 case Key_Left: 1494 case Key_Left:
1578 qDebug("Left"); 1495 // qDebug("Left");
1579 rewindReleased(); 1496 rewindReleased();
1580 break; 1497 break;
1581 case Key_Right: 1498 case Key_Right:
1582 qDebug("Right"); 1499 // qDebug("Right");
1583 FastforwardReleased(); 1500 FastforwardReleased();
1584 break; 1501 break;
1585 } 1502 }
1586} 1503}
1587 1504
1588void QtRec::endRecording() { 1505void QtRec::endRecording() {
1589 qDebug("endRecording"); 1506 // qDebug("endRecording");
1590 setRecordButton(false); 1507 setRecordButton(false);
1591 timeSlider->setValue(0); 1508 timeSlider->setValue(0);
1592 toBeginningButton->setEnabled(true); 1509 toBeginningButton->setEnabled(true);
1593 toEndButton->setEnabled(true); 1510 toEndButton->setEnabled(true);
1594 1511
1595 monitoring=false; 1512 monitoring=false;
1596 1513
1597 killTimers(); 1514 killTimers();
1598 1515
1599 if(autoMute) 1516 if(autoMute)
1600 doMute(true); 1517 doMute(true);
1601 1518
1602 soundDevice->closeDevice( true); 1519 soundDevice->closeDevice( true);
1603 1520
1604 recording = false; 1521 recording = false;
1605 stopped=true; 1522 stopped=true;
1606 t->stop(); 1523 t->stop();
1607 1524
1608 if( wavFile->track.isOpen()) { 1525 if( wavFile->track.isOpen()) {
1609 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1526 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1610 // soundDevice->sd=-1; 1527 // soundDevice->sd=-1;
1611 filePara.numberSamples=0; 1528 filePara.numberSamples=0;
1612 // filePara.sd=-1; 1529 // filePara.sd=-1;
1613 wavFile->closeFile(); 1530 wavFile->closeFile();
1614 filePara.fd=0; 1531 filePara.fd=0;
1615 1532
1616 if(wavFile->isTempFile()) { 1533 if(wavFile->isTempFile()) {
1617// move tmp file to regular file 1534// move tmp file to regular file
1618 QString cmd; 1535 QString cmd;
1619 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1536 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1620 qDebug("moving tmp file to "+currentFileName); 1537 // qDebug("moving tmp file to "+currentFileName);
1621 system(cmd.latin1()); 1538 system(cmd.latin1());
1622 } 1539 }
1623 1540
1624 qDebug("Just moved "+wavFile->currentFileName); 1541 // qDebug("Just moved "+wavFile->currentFileName);
1625 Config cfg("OpieRec"); 1542 Config cfg("OpieRec");
1626 cfg.setGroup("Sounds"); 1543 cfg.setGroup("Sounds");
1627 1544
1628 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1545 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1629 1546
1630 currentFile = QFileInfo(wavFile->currentFileName).fileName(); 1547 currentFile = QFileInfo(wavFile->currentFileName).fileName();
1631 currentFile=currentFile.left(currentFile.length()-4); 1548 currentFile=currentFile.left(currentFile.length()-4);
1632 1549
1633 cfg.writeEntry( "NumberofFiles",nFiles+1); 1550 cfg.writeEntry( "NumberofFiles",nFiles+1);
1634 cfg.writeEntry( QString::number( nFiles+1), currentFile); 1551 cfg.writeEntry( QString::number( nFiles+1), currentFile);
1635 cfg.writeEntry( currentFile, wavFile->currentFileName); 1552 cfg.writeEntry( currentFile, wavFile->currentFileName);
1636 1553
1637 QString time; 1554 QString time;
1638 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1555 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1639 cfg.writeEntry( wavFile->currentFileName, time ); 1556 cfg.writeEntry( wavFile->currentFileName, time );
1640 qDebug("writing config numberOfRecordedSeconds "+time); 1557 // qDebug("writing config numberOfRecordedSeconds "+time);
1641 1558
1642 cfg.write(); 1559 cfg.write();
1643 qDebug("finished recording"); 1560 // qDebug("finished recording");
1644 timeLabel->setText(""); 1561 timeLabel->setText("");
1645 } 1562 }
1646 1563
1647 if(soundDevice) delete soundDevice; 1564 if(soundDevice) delete soundDevice;
1648 1565
1649 initIconView(); 1566 initIconView();
1650 selectItemByName(currentFile); 1567 selectItemByName(currentFile);
1651} 1568}
1652 1569
1653void QtRec::endPlaying() { 1570void QtRec::endPlaying() {
1654 1571
1655 qDebug("end playing"); 1572 // qDebug("end playing");
1656 setRecordButton(false); 1573 setRecordButton(false);
1657 1574
1658 toBeginningButton->setEnabled(true); 1575 toBeginningButton->setEnabled(true);
1659 toEndButton->setEnabled(true); 1576 toEndButton->setEnabled(true);
1660 1577
1661 if(autoMute) 1578 if(autoMute)
1662 doMute(true); 1579 doMute(true);
1663 1580
1664 soundDevice->closeDevice( false); 1581 soundDevice->closeDevice( false);
1665 soundDevice->sd=-1; 1582 soundDevice->sd=-1;
1666 // if(soundDevice) delete soundDevice; 1583 // if(soundDevice) delete soundDevice;
1667 qDebug("file and sound device closed"); 1584 // qDebug("file and sound device closed");
1668 stopped=true; 1585 stopped=true;
1669 recording=false; 1586 recording=false;
1670 playing=false; 1587 playing=false;
1671 timeLabel->setText(""); 1588 timeLabel->setText("");
1672 monitoring=false; 1589 monitoring=false;
1673 total = 0; 1590 total = 0;
1674 filePara.numberSamples=0; 1591 filePara.numberSamples=0;
1675 filePara.sd=-1; 1592 filePara.sd=-1;
1676 wavFile->closeFile(); 1593 wavFile->closeFile();
1677 filePara.fd=0; 1594 filePara.fd=0;
1678// if(wavFile) delete wavFile; //this crashes 1595// if(wavFile) delete wavFile; //this crashes
1679 1596
1680 qDebug("track closed"); 1597 // qDebug("track closed");
1681 timeSlider->setValue(0); 1598 timeSlider->setValue(0);
1682 1599
1683 if(soundDevice) delete soundDevice; 1600 if(soundDevice) delete soundDevice;
1684 1601
1685} 1602}
1686 1603
1687bool QtRec::openPlayFile() { 1604bool QtRec::openPlayFile() {
1688 1605
1689 qApp->processEvents(); 1606 qApp->processEvents();
1690 if( currentFile.isEmpty()) { 1607 if( currentFile.isEmpty()) {
1691 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1608 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1692 endPlaying(); 1609 endPlaying();
1693 return false; 1610 return false;
1694 } 1611 }
1695 QString currentFileName; 1612 QString currentFileName;
1696 Config cfg("OpieRec"); 1613 Config cfg("OpieRec");
1697 cfg.setGroup("Sounds"); 1614 cfg.setGroup("Sounds");
1698 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1615 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1699 for(int i=0;i<nFiles+1;i++) { //look for file 1616 for(int i=0;i<nFiles+1;i++) { //look for file
1700 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1617 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1701 currentFileName=cfg.readEntry( currentFile, "" ); 1618 currentFileName=cfg.readEntry( currentFile, "" );
1702 qDebug("opening for play: "+currentFileName); 1619 // qDebug("opening for play: "+currentFileName);
1703 } 1620 }
1704 } 1621 }
1705 wavFile = new WavFile(this, 1622 wavFile = new WavFile(this,
1706 currentFileName, 1623 currentFileName,
1707 false); 1624 false);
1708 filePara.fd = wavFile->wavHandle(); 1625 filePara.fd = wavFile->wavHandle();
1709 if(filePara.fd == -1) { 1626 if(filePara.fd == -1) {
1710 // if(!track.open(IO_ReadOnly)) { 1627 // if(!track.open(IO_ReadOnly)) {
1711 QString errorMsg=(QString)strerror(errno); 1628 QString errorMsg=(QString)strerror(errno);
1712 monitoring=false; 1629 monitoring=false;
1713 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1630 setCaption( tr( "OpieRecord " )/* + QString::number(VERSION)*/ );
1714 QMessageBox::message(tr("Note"),tr("Could not open audio file.\n") 1631 QMessageBox::message(tr("Note"),tr("Could not open audio file.\n")
1715 +errorMsg+"\n"+currentFile); 1632 +errorMsg+"\n"+currentFile);
1716 return false; 1633 return false;
1717 } else { 1634 } else {
1718 filePara.numberSamples=wavFile->getNumberSamples(); 1635 filePara.numberSamples=wavFile->getNumberSamples();
1719 filePara.format = wavFile->getFormat(); 1636 filePara.format = wavFile->getFormat();
1720 // qDebug("file %d, samples %f", filePara.fd, filePara.numberSamples); 1637 // qDebug("file %d, samples %f", filePara.fd, filePara.numberSamples);
1721 filePara.sampleRate= wavFile->getSampleRate(); 1638 filePara.sampleRate= wavFile->getSampleRate();
1722 filePara.resolution=wavFile->getResolution(); 1639 filePara.resolution=wavFile->getResolution();
1723 timeSlider->setPageStep(1); 1640 timeSlider->setPageStep(1);
1724 monitoring=true; 1641 monitoring=true;
1725 timeSlider->setRange(0, filePara.numberSamples ); 1642 timeSlider->setRange(0, filePara.numberSamples );
1726 filePara.numberOfRecordedSeconds=(float) filePara.numberSamples / (float)filePara.sampleRate * (float)2; 1643 filePara.numberOfRecordedSeconds=(float) filePara.numberSamples / (float)filePara.sampleRate * (float)2;
1727 } 1644 }
1728 1645
1729 return true; 1646 return true;
1730} 1647}
1731 1648
1732void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1649void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1733 if(item == NULL ) 1650 if(item == NULL )
1734 return; 1651 return;
1735 switch (mouse) { 1652 switch (mouse) {
1736 case 1: { 1653 case 1: {
1737 if( renameBox !=0 ) //tricky 1654 if( renameBox !=0 ) //tricky
1738 cancelRename(); 1655 cancelRename();
1739 1656
1740 currentFile=item->text(0); 1657 currentFile=item->text(0);
1741 setCaption( "OpieRecord "+currentFile); 1658 setCaption( "OpieRecord "+currentFile);
1742 } 1659 }
1743 break; 1660 break;
1744 case 2: 1661 case 2:
1745 showListMenu(item); 1662 showListMenu(item);
@@ -1792,138 +1709,138 @@ void QtRec::doBeam() {
1792 } 1709 }
1793 } 1710 }
1794} 1711}
1795 1712
1796void QtRec::doMenuPlay() { 1713void QtRec::doMenuPlay() {
1797 qApp->processEvents(); 1714 qApp->processEvents();
1798 currentFile = ListView1->currentItem()->text(0); 1715 currentFile = ListView1->currentItem()->text(0);
1799} 1716}
1800 1717
1801void QtRec::doRename() { 1718void QtRec::doRename() {
1802 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1719 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1803 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1720 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1804 r.setX( ListView1->contentsX() ); 1721 r.setX( ListView1->contentsX() );
1805 if ( r.width() > ListView1->visibleWidth() ) 1722 if ( r.width() > ListView1->visibleWidth() )
1806 r.setWidth( ListView1->visibleWidth() ); 1723 r.setWidth( ListView1->visibleWidth() );
1807 1724
1808 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1725 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1809 renameBox->setFrame(true); 1726 renameBox->setFrame(true);
1810 1727
1811 renameBox->setText( ListView1->currentItem()->text(0) ); 1728 renameBox->setText( ListView1->currentItem()->text(0) );
1812 1729
1813 renameBox->selectAll(); 1730 renameBox->selectAll();
1814 renameBox->installEventFilter( this ); 1731 renameBox->installEventFilter( this );
1815 ListView1->addChild( renameBox, r.x(), r.y() ); 1732 ListView1->addChild( renameBox, r.x(), r.y() );
1816 renameBox->resize( r.size() ); 1733 renameBox->resize( r.size() );
1817 ListView1->viewport()->setFocusProxy( renameBox ); 1734 ListView1->viewport()->setFocusProxy( renameBox );
1818 renameBox->setFocus(); 1735 renameBox->setFocus();
1819 renameBox->show(); 1736 renameBox->show();
1820 1737
1821} 1738}
1822 1739
1823void QtRec::okRename() { 1740void QtRec::okRename() {
1824 qDebug("okRename"); 1741 // qDebug("okRename");
1825 qDebug(renameBox->text()); 1742 // qDebug(renameBox->text());
1826 QString filename = renameBox->text(); 1743 QString filename = renameBox->text();
1827 cancelRename(); 1744 cancelRename();
1828 1745
1829 if( ListView1->currentItem() == NULL) 1746 if( ListView1->currentItem() == NULL)
1830 return; 1747 return;
1831 1748
1832 Config cfg("OpieRec"); 1749 Config cfg("OpieRec");
1833 cfg.setGroup("Sounds"); 1750 cfg.setGroup("Sounds");
1834 1751
1835 QString file = ListView1->currentItem()->text(0); 1752 QString file = ListView1->currentItem()->text(0);
1836 1753
1837 qDebug("filename is " + filename); 1754 // qDebug("filename is " + filename);
1838 1755
1839 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1756 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1840 1757
1841 for(int i=0;i<nFiles+1;i++) { //look for file 1758 for(int i=0;i<nFiles+1;i++) { //look for file
1842 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1759 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1843 1760
1844 QString filePath = cfg.readEntry(file,""); 1761 QString filePath = cfg.readEntry(file,"");
1845 1762
1846 cfg.writeEntry( QString::number(i), filename ); 1763 cfg.writeEntry( QString::number(i), filename );
1847 cfg.writeEntry( filename, filePath ); 1764 cfg.writeEntry( filename, filePath );
1848 cfg.removeEntry(file); 1765 cfg.removeEntry(file);
1849 cfg.write(); 1766 cfg.write();
1850 } 1767 }
1851 } 1768 }
1852 1769
1853 ListView1->takeItem( ListView1->currentItem() ); 1770 ListView1->takeItem( ListView1->currentItem() );
1854 delete ListView1->currentItem(); 1771 delete ListView1->currentItem();
1855 ListView1->clear(); 1772 ListView1->clear();
1856 initIconView(); 1773 initIconView();
1857 update(); 1774 update();
1858} 1775}
1859 1776
1860void QtRec::cancelRename() { 1777void QtRec::cancelRename() {
1861 qDebug("cancel rename"); 1778 // qDebug("cancel rename");
1862 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1779 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1863 delete renameBox; 1780 delete renameBox;
1864 renameBox = 0; 1781 renameBox = 0;
1865 if ( resetFocus ) { 1782 if ( resetFocus ) {
1866 ListView1->viewport()->setFocusProxy( ListView1 ); 1783 ListView1->viewport()->setFocusProxy( ListView1 );
1867 ListView1->setFocus(); 1784 ListView1->setFocus();
1868 } 1785 }
1869} 1786}
1870 1787
1871bool QtRec::eventFilter( QObject * o, QEvent * e ) { 1788bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1872 if ( o->inherits( "QLineEdit" ) ) { 1789 if ( o->inherits( "QLineEdit" ) ) {
1873 if ( e->type() == QEvent::KeyPress ) { 1790 if ( e->type() == QEvent::KeyPress ) {
1874 QKeyEvent *ke = (QKeyEvent*)e; 1791 QKeyEvent *ke = (QKeyEvent*)e;
1875 if ( ke->key() == Key_Return || 1792 if ( ke->key() == Key_Return ||
1876 ke->key() == Key_Enter ) { 1793 ke->key() == Key_Enter ) {
1877 okRename(); 1794 okRename();
1878 return true; 1795 return true;
1879 } else if ( ke->key() == Key_Escape ) { 1796 } else if ( ke->key() == Key_Escape ) {
1880 cancelRename(); 1797 cancelRename();
1881 return true; 1798 return true;
1882 } 1799 }
1883 } else if ( e->type() == QEvent::FocusOut ) { 1800 } else if ( e->type() == QEvent::FocusOut ) {
1884 cancelRename(); 1801 cancelRename();
1885 return true; 1802 return true;
1886 } 1803 }
1887 } 1804 }
1888 return QWidget::eventFilter( o, e ); 1805 return QWidget::eventFilter( o, e );
1889} 1806}
1890 1807
1891 1808
1892int QtRec::getCurrentSizeLimit() { 1809int QtRec::getCurrentSizeLimit() {
1893 return sizeLimitCombo->currentItem() * 5; 1810 return sizeLimitCombo->currentItem() * 5;
1894} 1811}
1895 1812
1896void QtRec::timerBreak() { 1813void QtRec::timerBreak() {
1897 qDebug("timer break"); 1814 // qDebug("timer break");
1898 stop(); 1815 stop();
1899} 1816}
1900 1817
1901void QtRec::doVolMuting(bool b) { 1818void QtRec::doVolMuting(bool b) {
1902 Config cfg( "qpe" ); 1819 Config cfg( "qpe" );
1903 cfg. setGroup( "Volume" ); 1820 cfg. setGroup( "Volume" );
1904 cfg.writeEntry( "Mute",b); 1821 cfg.writeEntry( "Mute",b);
1905 cfg.write(); 1822 cfg.write();
1906 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1823 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1907} 1824}
1908 1825
1909void QtRec::doMicMuting(bool b) { 1826void QtRec::doMicMuting(bool b) {
1910 // qDebug("mic mute"); 1827 // qDebug("mic mute");
1911 Config cfg( "qpe" ); 1828 Config cfg( "qpe" );
1912 cfg. setGroup( "Volume" ); 1829 cfg. setGroup( "Volume" );
1913 cfg.writeEntry( "MicMute",b); 1830 cfg.writeEntry( "MicMute",b);
1914 cfg.write(); 1831 cfg.write();
1915 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1832 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1916} 1833}
1917 1834
1918void QtRec::compressionSelected(bool b) { 1835void QtRec::compressionSelected(bool b) {
1919 Config cfg("OpieRec"); 1836 Config cfg("OpieRec");
1920 cfg.setGroup("Settings"); 1837 cfg.setGroup("Settings");
1921 cfg.writeEntry("wavCompression", b); 1838 cfg.writeEntry("wavCompression", b);
1922 cfg.writeEntry("bitrate",16); filePara.resolution=16; 1839 cfg.writeEntry("bitrate",16); filePara.resolution=16;
1923 cfg.write(); 1840 cfg.write();
1924 1841
1925 if(b) { 1842 if(b) {
1926 bitRateComboBox->setEnabled(false); 1843 bitRateComboBox->setEnabled(false);
1927 bitRateComboBox->setCurrentItem(0); 1844 bitRateComboBox->setCurrentItem(0);
1928 filePara.resolution=16; 1845 filePara.resolution=16;
1929 } else{ 1846 } else{
@@ -1932,66 +1849,66 @@ void QtRec::compressionSelected(bool b) {
1932} 1849}
1933 1850
1934long QtRec::checkDiskSpace(const QString &path) { 1851long QtRec::checkDiskSpace(const QString &path) {
1935 1852
1936 struct statfs fs; 1853 struct statfs fs;
1937 1854
1938 if ( !statfs( path.latin1(), &fs ) ) { 1855 if ( !statfs( path.latin1(), &fs ) ) {
1939 1856
1940 int blkSize = fs.f_bsize; 1857 int blkSize = fs.f_bsize;
1941 int availBlks = fs.f_bavail; 1858 int availBlks = fs.f_bavail;
1942 1859
1943 long mult = blkSize / 1024; 1860 long mult = blkSize / 1024;
1944 long div = 1024 / blkSize; 1861 long div = 1024 / blkSize;
1945 1862
1946 if ( !mult ) mult = 1; 1863 if ( !mult ) mult = 1;
1947 if ( !div ) div = 1; 1864 if ( !div ) div = 1;
1948 1865
1949 return availBlks * mult / div; 1866 return availBlks * mult / div;
1950 } 1867 }
1951 return -1; 1868 return -1;
1952} 1869}
1953 1870
1954// short f_fstyp; /* File system type */ 1871// short f_fstyp; /* File system type */
1955// long f_bsize; /* Block size */ 1872// long f_bsize; /* Block size */
1956// long f_frsize; /* Fragment size */ 1873// long f_frsize; /* Fragment size */
1957// long f_blocks; /* Total number of blocks*/ 1874// long f_blocks; /* Total number of blocks*/
1958// long f_bfree; /* Count of free blocks */ 1875// long f_bfree; /* Count of free blocks */
1959// long f_files; /* Total number of file nodes */ 1876// long f_files; /* Total number of file nodes */
1960// long f_ffree; /* Count of free file nodes */ 1877// long f_ffree; /* Count of free file nodes */
1961// char f_fname[6]; /* Volumename */ 1878// char f_fname[6]; /* Volumename */
1962// char f_fpack[6]; /* Pack name */ 1879// char f_fpack[6]; /* Pack name */
1963 1880
1964void QtRec::receive( const QCString &msg, const QByteArray & ) { 1881void QtRec::receive( const QCString &/* msg*/, const QByteArray & ) {
1965 qDebug("Voicerecord received message "+msg); 1882 // qDebug("Voicerecord received message "+msg);
1966 1883
1967} 1884}
1968 1885
1969 1886
1970///////////////////////////// timerEvent 1887///////////////////////////// timerEvent
1971void QtRec::timerEvent( QTimerEvent *e ) { 1888void QtRec::timerEvent( QTimerEvent *e ) {
1972// qDebug( "%d", secCount ); 1889// qDebug( "%d", secCount );
1973#ifdef DEV_VERSION 1890#ifdef DEV_VERSION
1974 QString msg; 1891 QString msg;
1975 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1892 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1976 setCaption( msg +" :: "+QString::number(secCount)); 1893 setCaption( msg +" :: "+QString::number(secCount));
1977#endif 1894#endif
1978 1895
1979 if( !playing ) { 1896 if( !playing ) {
1980 if(!recording ){ 1897 if(!recording ){
1981 killTimer(e->timerId()); 1898 killTimer(e->timerId());
1982///* stopped=true; 1899///* stopped=true;
1983// recording=false; 1900// recording=false;
1984///*/ 1901///*/
1985// _exit( 0); 1902// _exit( 0);
1986 } 1903 }
1987 if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) { 1904 if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) {
1988 killTimer(e->timerId()); 1905 killTimer(e->timerId());
1989 stop(); 1906 stop();
1990 } 1907 }
1991 } 1908 }
1992// if( stopped && !paused) { 1909// if( stopped && !paused) {
1993// if( filePara.numberOfRecordedSeconds < secCount) { 1910// if( filePara.numberOfRecordedSeconds < secCount) {
1994// stopped = true; 1911// stopped = true;
1995// // playing=false; 1912// // playing=false;
1996// killTimer(e->timerId()); 1913// killTimer(e->timerId());
1997// endPlaying(); 1914// endPlaying();
@@ -2198,57 +2115,54 @@ void QtRec::fillDirectoryCombo() {
2198void QtRec::errorStop() { 2115void QtRec::errorStop() {
2199 stopped = true; 2116 stopped = true;
2200 wavFile->closeFile(); 2117 wavFile->closeFile();
2201 killTimers(); 2118 killTimers();
2202} 2119}
2203 2120
2204void QtRec::doMute(bool b) { 2121void QtRec::doMute(bool b) {
2205 doVolMuting( b); 2122 doVolMuting( b);
2206 doMicMuting( b); 2123 doMicMuting( b);
2207} 2124}
2208 2125
2209void QtRec::slotAutoMute(bool b) { 2126void QtRec::slotAutoMute(bool b) {
2210 autoMute=b; 2127 autoMute=b;
2211 Config cfg("OpieRec"); 2128 Config cfg("OpieRec");
2212 cfg.setGroup("Settings"); 2129 cfg.setGroup("Settings");
2213 cfg.writeEntry("useAutoMute",b); 2130 cfg.writeEntry("useAutoMute",b);
2214 doMute(b); 2131 doMute(b);
2215 outMuteCheckBox->setChecked( b); 2132 outMuteCheckBox->setChecked( b);
2216 inMuteCheckBox->setChecked( b); 2133 inMuteCheckBox->setChecked( b);
2217} 2134}
2218 2135
2219void QtRec::selectItemByName(const QString & name) { 2136void QtRec::selectItemByName(const QString & name) {
2220 QListViewItemIterator it( ListView1 ); 2137 QListViewItemIterator it( ListView1 );
2221 for ( ; it.current(); ++it ) 2138 for ( ; it.current(); ++it )
2222 if(name == it.current()->text(0)) 2139 if(name == it.current()->text(0))
2223 ListView1->setCurrentItem(it.current()); 2140 ListView1->setCurrentItem(it.current());
2224} 2141}
2225 2142
2226 2143
2227long findPeak(long input ) { 2144long findPeak(long input ) {
2228 2145
2229// halfLife = time in seconds for output to decay to half value after an impulse 2146// halfLife = time in seconds for output to decay to half value after an impulse
2230 static float output = 0.0; 2147 float output = 0.0;
2231 int halfLife = .25; 2148 float halfLife = .25;
2232 float vsf = .0025; 2149 float vsf = .0025;
2233 float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2150 float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2234 if( input < 0.0 ) 2151 if( input < 0.0 )
2235 input = -input; // Absolute value. 2152 input = -input; // Absolute value.
2236 if ( input >= output ) 2153 if ( input >= output) {
2237 {
2238 // When we hit a peak, ride the peak to the top. 2154 // When we hit a peak, ride the peak to the top.
2239 output = input; 2155 output = input;
2240 } 2156 } else {
2241 else
2242 {
2243// Exponential decay of output when signal is low. 2157// Exponential decay of output when signal is low.
2244 output = output * scalar; 2158 output = output * scalar;
2245// 2159//
2246// When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2160// When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2247// which can cause a severe performance degradation due to a flood 2161// which can cause a severe performance degradation due to a flood
2248// of interrupts. 2162// of interrupts.
2249// 2163//
2250 if( output < vsf ) output = 0.0; 2164 if( output < vsf ) output = 0.0;
2251 } 2165 }
2252 2166
2253 return output; 2167 return (long)output;
2254} 2168}
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h
index bcf5504..7965c74 100644
--- a/noncore/multimedia/opierec/qtrec.h
+++ b/noncore/multimedia/opierec/qtrec.h
@@ -1,39 +1,39 @@
1/**************************************************************************** 1/****************************************************************************
2 ** Created: Thu Jan 17 11:19:45 2002 2 ** Created: Thu Jan 17 11:19:45 2002
3copyright 2002 by L.J. Potter ljp@llornkcor.com 3copyright 2002 by L.J. Potter ljp@llornkcor.com
4****************************************************************************/ 4****************************************************************************/
5#ifndef QTREC_H 5#ifndef QTREC_H
6#define QTREC_H 6#define QTREC_H
7#define VERSION 20021202 7#define VERSION 1.0
8 8
9#include <qpe/ir.h> 9#include <qpe/ir.h>
10 10
11#include <iostream.h> 11#include <iostream.h>
12#include <qfile.h> 12#include <qfile.h>
13#include <qimage.h> 13#include <qimage.h>
14#include <qlineedit.h> 14#include <qlineedit.h>
15#include <qpixmap.h> 15#include <qpixmap.h>
16#include <qvariant.h> 16#include <qvariant.h>
17#include <qwidget.h> 17#include <qwidget.h>
18#include <stdio.h> 18#include <stdio.h>
19#include <stdlib.h> 19#include <stdlib.h>
20 20
21#include "device.h" 21#include "device.h"
22#include "wavFile.h" 22#include "wavFile.h"
23 23
24class QButtonGroup; 24class QButtonGroup;
25class QCheckBox; 25class QCheckBox;
26class QComboBox; 26class QComboBox;
27class QGridLayout; 27class QGridLayout;
28class QGroupBox; 28class QGroupBox;
29class QHBoxLayout; 29class QHBoxLayout;
30class QIconView; 30class QIconView;
31class QIconViewItem; 31class QIconViewItem;
32class QLabel; 32class QLabel;
33class QLabel; 33class QLabel;
34class QListView; 34class QListView;
35class QListViewItem; 35class QListViewItem;
36class QPushButton; 36class QPushButton;
37class QSlider; 37class QSlider;
38class QTabWidget; 38class QTabWidget;
39class QTimer; 39class QTimer;