summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-08-10 23:03:39 (UTC)
committer llornkcor <llornkcor>2003-08-10 23:03:39 (UTC)
commit892aac84512b257c72362702a98462289589faec (patch) (unidiff)
treed514fbd450129f2a1b2a897ef06c93e27cde4b30
parent44bb1f23dcd0bea4775ba4b48fb370ad651290cc (diff)
downloadopie-892aac84512b257c72362702a98462289589faec.zip
opie-892aac84512b257c72362702a98462289589faec.tar.gz
opie-892aac84512b257c72362702a98462289589faec.tar.bz2
forgot what I changed, but I changed something I need to commit
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
@@ -1,542 +1,493 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6 6
7#define DEV_VERSION 7#define DEV_VERSION
8 8
9#include "pixmaps.h" 9#include "pixmaps.h"
10#include "qtrec.h" 10#include "qtrec.h"
11 11
12#include <pthread.h> 12#include <pthread.h>
13 13
14extern "C" { 14extern "C" {
15#include "adpcm.h" 15#include "adpcm.h"
16} 16}
17 17
18#include <sys/soundcard.h> 18#include <sys/soundcard.h>
19 19
20// #if defined (QTOPIA_INTERNAL_FSLP) 20// #if defined (QTOPIA_INTERNAL_FSLP)
21// #include <qpe/lnkproperties.h> 21// #include <qpe/lnkproperties.h>
22// #endif 22// #endif
23 23
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/resource.h> 27#include <qpe/resource.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29 29
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32//#include <qdatetime.h> 32//#include <qdatetime.h>
33#include <qdir.h> 33#include <qdir.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qtabwidget.h> 42#include <qtabwidget.h>
43#include <qtimer.h> 43#include <qtimer.h>
44 44
45#include <errno.h> 45#include <errno.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <mntent.h> 48#include <mntent.h>
49#include <stdio.h> 49#include <stdio.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <sys/ioctl.h> 51#include <sys/ioctl.h>
52#include <sys/soundcard.h> 52#include <sys/soundcard.h>
53#include <sys/stat.h> 53#include <sys/stat.h>
54#include <sys/time.h> 54#include <sys/time.h>
55#include <sys/types.h> 55#include <sys/types.h>
56#include <sys/vfs.h> 56#include <sys/vfs.h>
57#include <unistd.h> 57#include <unistd.h>
58#include<sys/wait.h> 58#include<sys/wait.h>
59#include <sys/signal.h> 59#include <sys/signal.h>
60 60
61//#define ZAURUS 0 61//#define ZAURUS 0
62struct adpcm_state encoder_state; 62struct adpcm_state encoder_state;
63struct adpcm_state decoder_state; 63struct adpcm_state decoder_state;
64 64
65long findPeak(long input ); 65long findPeak(long input );
66//char deviceRates[]; 66//char deviceRates[];
67 67
68typedef struct { 68typedef struct {
69 int sampleRate; 69 int sampleRate;
70 /* int fragSize; */ 70 /* int fragSize; */
71 /* int blockSize; */ 71 /* int blockSize; */
72 int resolution; //bitrate 72 int resolution; //bitrate
73 int channels; //number of channels 73 int channels; //number of channels
74 int fd; //file descriptor 74 int fd; //file descriptor
75 int sd; //sound device descriptor 75 int sd; //sound device descriptor
76 int numberSamples; //total number of samples 76 int numberSamples; //total number of samples
77 int SecondsToRecord; // number of seconds that should be recorded 77 int SecondsToRecord; // number of seconds that should be recorded
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);
447 398
448 timeLabel = new QLabel( tab, "TimeLabel" ); 399 timeLabel = new QLabel( tab, "TimeLabel" );
449 layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 400 layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
450 401
451 playLabel2 = new QLabel(tab, "PlayLabel2" ); 402 playLabel2 = new QLabel(tab, "PlayLabel2" );
452 playLabel2->setText(tr("Play") ); 403 playLabel2->setText(tr("Play") );
453 playLabel2->setFixedHeight(18); 404 playLabel2->setFixedHeight(18);
454 layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 405 layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
455 406
456 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 407 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
457 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 408 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
458 Stop_PushButton->setFixedSize(22,22); 409 Stop_PushButton->setFixedSize(22,22);
459 Stop_PushButton->setPixmap( image4 ); 410 Stop_PushButton->setPixmap( image4 );
460 411
461 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 412 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
462 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 413 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
463 toBeginningButton->setFixedSize(22,22); 414 toBeginningButton->setFixedSize(22,22);
464 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 415 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") );
465 416
466 toEndButton = new QPushButton( tab, "End_PushButton" ); 417 toEndButton = new QPushButton( tab, "End_PushButton" );
467 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 418 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
468 toEndButton->setFixedSize(22,22); 419 toEndButton->setFixedSize(22,22);
469 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 420 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) );
470 421
471 QLabel *recLabel2; 422 QLabel *recLabel2;
472 recLabel2 = new QLabel( tab, "recLabel2" ); 423 recLabel2 = new QLabel( tab, "recLabel2" );
473 recLabel2->setText(tr("Rec")); 424 recLabel2->setText(tr("Rec"));
474 recLabel2->setFixedHeight(18); 425 recLabel2->setFixedHeight(18);
475 layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 426 layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
476 427
477 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 428 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
478 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 429 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
479 Rec_PushButton->setFixedSize(22,22); 430 Rec_PushButton->setFixedSize(22,22);
480 Rec_PushButton->setPixmap( image6 ); 431 Rec_PushButton->setPixmap( image6 );
481 432
482 t = new QTimer( this ); 433 t = new QTimer( this );
483 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 434 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
484 435
485 rewindTimer = new QTimer( this ); 436 rewindTimer = new QTimer( this );
486 connect( rewindTimer, SIGNAL( timeout() ), SLOT( rewindTimerTimeout() ) ); 437 connect( rewindTimer, SIGNAL( timeout() ), SLOT( rewindTimerTimeout() ) );
487 438
488 forwardTimer = new QTimer( this ); 439 forwardTimer = new QTimer( this );
489 connect( forwardTimer, SIGNAL( timeout() ), SLOT( forwardTimerTimeout() ) ); 440 connect( forwardTimer, SIGNAL( timeout() ), SLOT( forwardTimerTimeout() ) );
490 441
491 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 442 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
492 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 443 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
493 deleteSoundButton->setText( tr( "Delete" ) ); 444 deleteSoundButton->setText( tr( "Delete" ) );
494 445
495 ListView1 = new QListView( tab, "IconView1" ); 446 ListView1 = new QListView( tab, "IconView1" );
496 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 447 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
497 448
498 ListView1->addColumn( tr( "Name" ) ); 449 ListView1->addColumn( tr( "Name" ) );
499 ListView1->setColumnWidth(0,140); 450 ListView1->setColumnWidth(0,140);
500 ListView1->setSorting( 1, false); 451 ListView1->setSorting( 1, false);
501 ListView1->addColumn( tr( "Time" ) ); //in seconds 452 ListView1->addColumn( tr( "Time" ) ); //in seconds
502 ListView1->setColumnWidth(1,50); 453 ListView1->setColumnWidth(1,50);
503 ListView1->addColumn( tr("Location") ); 454 ListView1->addColumn( tr("Location") );
504 ListView1->setColumnWidth(2,50); 455 ListView1->setColumnWidth(2,50);
505 ListView1->addColumn( tr("Date") ); 456 ListView1->addColumn( tr("Date") );
506 ListView1->setColumnWidth(3,63); 457 ListView1->setColumnWidth(3,63);
507 458
508 ListView1->setColumnWidthMode(0,QListView::Manual); 459 ListView1->setColumnWidthMode(0,QListView::Manual);
509 ListView1->setColumnAlignment(1,QListView::AlignCenter); 460 ListView1->setColumnAlignment(1,QListView::AlignCenter);
510 ListView1->setColumnAlignment(2,QListView::AlignRight); 461 ListView1->setColumnAlignment(2,QListView::AlignRight);
511 ListView1->setColumnAlignment(3,QListView::AlignLeft); 462 ListView1->setColumnAlignment(3,QListView::AlignLeft);
512 ListView1->setAllColumnsShowFocus( true ); 463 ListView1->setAllColumnsShowFocus( true );
513 QPEApplication::setStylusOperation( ListView1->viewport(),QPEApplication::RightOnHold); 464 QPEApplication::setStylusOperation( ListView1->viewport(),QPEApplication::RightOnHold);
514 465
515 TabWidget->insertTab( tab, tr( "Files" ) ); 466 TabWidget->insertTab( tab, tr( "Files" ) );
516 467
517 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 468 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
518 tab_3 = new QWidget( TabWidget, "tab_3" ); 469 tab_3 = new QWidget( TabWidget, "tab_3" );
519 //////////////////////////////////// 470 ////////////////////////////////////
520 471
521 Layout19 = new QHBoxLayout( tab_3); 472 Layout19 = new QHBoxLayout( tab_3);
522 Layout19->setSpacing( 2 ); 473 Layout19->setSpacing( 2 );
523 Layout19->setMargin( 0 ); 474 Layout19->setMargin( 0 );
524 475
525 Layout18 = new QVBoxLayout(this); 476 Layout18 = new QVBoxLayout(this);
526 Layout18->setSpacing( 2 ); 477 Layout18->setSpacing( 2 );
527 Layout18->setMargin( 0 ); 478 Layout18->setMargin( 0 );
528 479
529 Layout17 = new QHBoxLayout(this); 480 Layout17 = new QHBoxLayout(this);
530 Layout17->setSpacing( 2 ); 481 Layout17->setSpacing( 2 );
531 Layout17->setMargin( 0 ); 482 Layout17->setMargin( 0 );
532 483
533 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 484 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
534 sampleGroup->setTitle( tr( "Sample Rate" ) ); 485 sampleGroup->setTitle( tr( "Sample Rate" ) );
535 sampleGroup->setFixedSize( 95,50); 486 sampleGroup->setFixedSize( 95,50);
536 487
537 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 488 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
538 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 489 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
539//#ifndef QT_QWS_EBX 490//#ifndef QT_QWS_EBX
540 sampleRateComboBox->insertItem( tr( "44100")); 491 sampleRateComboBox->insertItem( tr( "44100"));
541 sampleRateComboBox->insertItem( tr( "32000")); 492 sampleRateComboBox->insertItem( tr( "32000"));
542//#endif 493//#endif
@@ -629,1465 +580,1431 @@ void QtRec::init() {
629 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 580 TextLabel2 = new QLabel( tab_5, "InputLabel" );
630 TextLabel2->setText( tr( "In")); 581 TextLabel2->setText( tr( "In"));
631 TextLabel2->setFixedWidth(35); 582 TextLabel2->setFixedWidth(35);
632 Layout15->addWidget( TextLabel2 ); 583 Layout15->addWidget( TextLabel2 );
633 584
634 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 585 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
635 TextLabel3->setText( tr( "Out" ) ); 586 TextLabel3->setText( tr( "Out" ) );
636 Layout15b->addWidget( TextLabel3 ); 587 Layout15b->addWidget( TextLabel3 );
637 588
638 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 589 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
639 InputSlider->setTickmarks(QSlider::Both); 590 InputSlider->setTickmarks(QSlider::Both);
640 Layout15->addWidget( InputSlider); 591 Layout15->addWidget( InputSlider);
641 592
642 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 593 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
643 OutputSlider->setTickmarks(QSlider::Both); 594 OutputSlider->setTickmarks(QSlider::Both);
644 595
645 Layout15b->addWidget( OutputSlider ); 596 Layout15b->addWidget( OutputSlider );
646 597
647 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 598 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
648 Layout15->addWidget( outMuteCheckBox ); 599 Layout15->addWidget( outMuteCheckBox );
649 600
650 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 601 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
651 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 602 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
652 Layout15b->addWidget( inMuteCheckBox ); 603 Layout15b->addWidget( inMuteCheckBox );
653 604
654 605
655 Layout19a->addLayout( Layout15 ); 606 Layout19a->addLayout( Layout15 );
656 Layout19a->addLayout( Layout15b ); 607 Layout19a->addLayout( Layout15b );
657 608
658 fillDirectoryCombo(); 609 fillDirectoryCombo();
659 610
660 TabWidget->insertTab( tab_3, tr( "Options" ) ); 611 TabWidget->insertTab( tab_3, tr( "Options" ) );
661 612
662 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 613 TabWidget->insertTab( tab_5, tr( "Volume" ) );
663 614
664 } else {// landscape 615 } else {// landscape
665 616
666 // Layout16->addWidget( dirGroup ); 617 // Layout16->addWidget( dirGroup );
667 // Layout18->addLayout( Layout16 ); 618 // Layout18->addLayout( Layout16 );
668 Layout15 = new QVBoxLayout(this); 619 Layout15 = new QVBoxLayout(this);
669 Layout15->setSpacing( 2 ); 620 Layout15->setSpacing( 2 );
670 Layout15->setMargin( 0 ); 621 Layout15->setMargin( 0 );
671 622
672 Layout15b = new QVBoxLayout(this); 623 Layout15b = new QVBoxLayout(this);
673 Layout15b->setSpacing( 2 ); 624 Layout15b->setSpacing( 2 );
674 Layout15b->setMargin( 0 ); 625 Layout15b->setMargin( 0 );
675 626
676 TextLabel2 = new QLabel( tab_3, "InputLabel" ); 627 TextLabel2 = new QLabel( tab_3, "InputLabel" );
677 TextLabel2->setText( tr( "In")); 628 TextLabel2->setText( tr( "In"));
678 TextLabel2->setFixedWidth(35); 629 TextLabel2->setFixedWidth(35);
679 Layout15->addWidget( TextLabel2 ); 630 Layout15->addWidget( TextLabel2 );
680 631
681 TextLabel3 = new QLabel( tab_3, "OutputLabel" ); 632 TextLabel3 = new QLabel( tab_3, "OutputLabel" );
682 TextLabel3->setText( tr( "Out" ) ); 633 TextLabel3->setText( tr( "Out" ) );
683 Layout15b->addWidget( TextLabel3 ); 634 Layout15b->addWidget( TextLabel3 );
684 635
685 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" ); 636 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" );
686 // InputSlider->setTickmarks(QSlider::Both); 637 // InputSlider->setTickmarks(QSlider::Both);
687 Layout15->addWidget( InputSlider); 638 Layout15->addWidget( InputSlider);
688 639
689 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" ); 640 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" );
690 // OutputSlider->setTickmarks(QSlider::Both); 641 // OutputSlider->setTickmarks(QSlider::Both);
691 642
692 Layout15b->addWidget( OutputSlider ); 643 Layout15b->addWidget( OutputSlider );
693 644
694 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 ); 645 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
695 Layout15->addWidget( outMuteCheckBox ); 646 Layout15->addWidget( outMuteCheckBox );
696 647
697 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 ); 648 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_3 );
698 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 649 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
699 Layout15b->addWidget( inMuteCheckBox ); 650 Layout15b->addWidget( inMuteCheckBox );
700 651
701 652
702 Layout19->addLayout( Layout15 ); 653 Layout19->addLayout( Layout15 );
703 Layout19->addLayout( Layout15b ); 654 Layout19->addLayout( Layout15b );
704 655
705 fillDirectoryCombo(); 656 fillDirectoryCombo();
706 657
707 TabWidget->insertTab( tab_3, tr( "Options" ) ); 658 TabWidget->insertTab( tab_3, tr( "Options" ) );
708 659
709 } 660 }
710 661
711 662
712 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 663 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
713 664
714// tab_4 = new QWidget( TabWidget, "tab_4" ); 665// tab_4 = new QWidget( TabWidget, "tab_4" );
715// QGridLayout *layout4 = new QGridLayout( tab_4); 666// QGridLayout *layout4 = new QGridLayout( tab_4);
716// layout4->setSpacing( 2); 667// layout4->setSpacing( 2);
717// layout4->setMargin( 2); 668// layout4->setMargin( 2);
718// TabWidget->insertTab( tab_4, tr( "Help")); 669// TabWidget->insertTab( tab_4, tr( "Help"));
719 670
720// ///////////////////////////////////////////// FIXME change to a real helpfile path 671// ///////////////////////////////////////////// FIXME change to a real helpfile path
721// QString url="/index.html"; 672// QString url="/index.html";
722// HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help"); 673// HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help");
723// layout4->addMultiCellWidget( help, 0, 1, 0, 1); 674// layout4->addMultiCellWidget( help, 0, 1, 0, 1);
724// if( !QFile(url).exists()) { 675// if( !QFile(url).exists()) {
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
792 connect( sampleRateComboBox, SIGNAL(activated( int)), this, SLOT( changesamplerateCombo(int)) ); 744 connect( sampleRateComboBox, SIGNAL(activated( int)), this, SLOT( changesamplerateCombo(int)) );
793 connect( bitRateComboBox, SIGNAL(activated( int)), this, SLOT( changebitrateCombo(int)) ); 745 connect( bitRateComboBox, SIGNAL(activated( int)), this, SLOT( changebitrateCombo(int)) );
794 connect( directoryComboBox, SIGNAL(activated( int)), this, SLOT( changeDirCombo(int)) ); 746 connect( directoryComboBox, SIGNAL(activated( int)), this, SLOT( changeDirCombo(int)) );
795 connect( sizeLimitCombo, SIGNAL(activated( int)), this, SLOT( changeSizeLimitCombo(int)) ); 747 connect( sizeLimitCombo, SIGNAL(activated( int)), this, SLOT( changeSizeLimitCombo(int)) );
796 connect( outMuteCheckBox, SIGNAL(toggled( bool)), this, SLOT( doVolMuting(bool)) ); 748 connect( outMuteCheckBox, SIGNAL(toggled( bool)), this, SLOT( doVolMuting(bool)) );
797 connect( inMuteCheckBox , SIGNAL(toggled( bool)), this, SLOT( doMicMuting(bool)) ); 749 connect( inMuteCheckBox , SIGNAL(toggled( bool)), this, SLOT( doMicMuting(bool)) );
798 connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)),this,SLOT( itClick(QListViewItem*))); 750 connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)),this,SLOT( itClick(QListViewItem*)));
799 connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 751 connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
800 this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); 752 this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) );
801 connect( timeSlider, SIGNAL( sliderMoved( int)), this, SLOT( changeTimeSlider(int) )); 753 connect( timeSlider, SIGNAL( sliderMoved( int)), this, SLOT( changeTimeSlider(int) ));
802 connect( timeSlider, SIGNAL( sliderPressed( )), this, SLOT( timeSliderPressed() )); 754 connect( timeSlider, SIGNAL( sliderPressed( )), this, SLOT( timeSliderPressed() ));
803 connect( timeSlider, SIGNAL( sliderReleased( )), this, SLOT( timeSliderReleased() )); 755 connect( timeSlider, SIGNAL( sliderReleased( )), this, SLOT( timeSliderReleased() ));
804 connect( compressionCheckBox, SIGNAL( toggled(bool)),this, SLOT( compressionSelected(bool))); 756 connect( compressionCheckBox, SIGNAL( toggled(bool)),this, SLOT( compressionSelected(bool)));
805 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),this, SLOT( slotAutoMute(bool))); 757 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),this, SLOT( slotAutoMute(bool)));
806} 758}
807 759
808void QtRec::initConfig() { 760void QtRec::initConfig() {
809 int index, fred, i; 761 int index, fred, i;
810 Config cfg("OpieRec"); 762 Config cfg("OpieRec");
811 cfg.setGroup("Settings"); 763 cfg.setGroup("Settings");
812 764
813 index = cfg.readNumEntry("samplerate",22050); 765 index = cfg.readNumEntry("samplerate",22050);
814 bool ok; 766 bool ok;
815 767
816 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 768 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
817 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 769 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
818 if(index == fred) { 770 if(index == fred) {
819 filePara.sampleRate = fred; 771 filePara.sampleRate = fred;
820 sampleRateComboBox->setCurrentItem(ws); 772 sampleRateComboBox->setCurrentItem(ws);
821 } 773 }
822 } 774 }
823 775
824 i=cfg.readNumEntry("bitrate",16); 776 i=cfg.readNumEntry("bitrate",16);
825 if(i == 16) 777 if(i == 16)
826 bitRateComboBox->setCurrentItem( 0); 778 bitRateComboBox->setCurrentItem( 0);
827 else 779 else
828 bitRateComboBox->setCurrentItem( 1); 780 bitRateComboBox->setCurrentItem( 1);
829 filePara.resolution = i; 781 filePara.resolution = i;
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
1225 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1142 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1226// if(filePara.numberOfRecordedSeconds>1) 1143// if(filePara.numberOfRecordedSeconds>1)
1227 timeLabel->setText( timeString+ tr(" seconds")); 1144 timeLabel->setText( timeString+ tr(" seconds"));
1228// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 1145// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
1229// printf("playing number %d, bytes %d, total %d totalsamples %d number recorded seconds %.2f\r", 1146// printf("playing number %d, bytes %d, total %d totalsamples %d number recorded seconds %.2f\r",
1230// number, bytesWritten, total/4, filePara.numberSamples, filePara.numberOfRecordedSeconds); 1147// number, bytesWritten, total/4, filePara.numberSamples, filePara.numberOfRecordedSeconds);
1231// fflush(stdout); 1148// fflush(stdout);
1232 1149
1233 qApp->processEvents(); 1150 qApp->processEvents();
1234 1151
1235 if( bytesWritten <= 0 ){//|| secCount > filePara.numberOfRecordedSeconds ) { 1152 if( bytesWritten <= 0 ){//|| secCount > filePara.numberOfRecordedSeconds ) {
1236 stopped = true; 1153 stopped = true;
1237 endPlaying(); 1154 endPlaying();
1238 } 1155 }
1239 } 1156 }
1240 } else { 1157 } else {
1241 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 1158 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
1242 short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; 1159 short inbuffer[BUFSIZE], outbuffer[BUFSIZE];
1243 memset( inbuffer, 0, BUFSIZE); 1160 memset( inbuffer, 0, BUFSIZE);
1244 memset( outbuffer, 0, BUFSIZE); 1161 memset( outbuffer, 0, BUFSIZE);
1245 1162
1246 for(;;) { // play loop 1163 for(;;) { // play loop
1247 if (stopped) 1164 if (stopped)
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 }
1313 return true; 1230 return true;
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."));
1418 1335
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);
1746 ListView1->clearSelection(); 1663 ListView1->clearSelection();
1747 break; 1664 break;
1748 }; 1665 };
1749} 1666}
1750 1667
1751void QtRec::showListMenu(QListViewItem * item) { 1668void QtRec::showListMenu(QListViewItem * item) {
1752 if(item == NULL) 1669 if(item == NULL)
1753 return; 1670 return;
1754 QPopupMenu *m = new QPopupMenu(this); 1671 QPopupMenu *m = new QPopupMenu(this);
1755 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); 1672 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() ));
1756 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); 1673 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() ));
1757 m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); 1674 m->insertItem( tr( "Rename" ), this, SLOT( doRename() ));
1758 // #if defined (QTOPIA_INTERNAL_FSLP) 1675 // #if defined (QTOPIA_INTERNAL_FSLP)
1759 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1676 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1760 // #endif 1677 // #endif
1761 m->insertSeparator(); 1678 m->insertSeparator();
1762 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); 1679 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) );
1763 m->exec( QCursor::pos() ); 1680 m->exec( QCursor::pos() );
1764 qApp->processEvents(); 1681 qApp->processEvents();
1765} 1682}
1766 1683
1767void QtRec::fileBeamFinished( Ir *ir) { 1684void QtRec::fileBeamFinished( Ir *ir) {
1768 if(ir) 1685 if(ir)
1769 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); 1686 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") );
1770 1687
1771} 1688}
1772 1689
1773void QtRec::doBeam() { 1690void QtRec::doBeam() {
1774 qApp->processEvents(); 1691 qApp->processEvents();
1775 if( ListView1->currentItem() == NULL) 1692 if( ListView1->currentItem() == NULL)
1776 return; 1693 return;
1777 Ir ir; 1694 Ir ir;
1778 if( ir.supported()) { 1695 if( ir.supported()) {
1779 QString file = ListView1->currentItem()->text(0); 1696 QString file = ListView1->currentItem()->text(0);
1780 Config cfg("OpieRec"); 1697 Config cfg("OpieRec");
1781 cfg.setGroup("Sounds"); 1698 cfg.setGroup("Sounds");
1782 1699
1783 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1700 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1784 1701
1785 for(int i=0;i<nFiles+1;i++) { 1702 for(int i=0;i<nFiles+1;i++) {
1786 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1703 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1787 QString filePath = cfg.readEntry(file,""); 1704 QString filePath = cfg.readEntry(file,"");
1788 Ir *file = new Ir(this, "IR"); 1705 Ir *file = new Ir(this, "IR");
1789 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1706 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
1790 file->send( filePath, "OPieRec audio file\n"+filePath ); 1707 file->send( filePath, "OPieRec audio file\n"+filePath );
1791 } 1708 }
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{
1930 bitRateComboBox->setEnabled(true); 1847 bitRateComboBox->setEnabled(true);
1931 } 1848 }
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();
1998// } 1915// }
1999// } 1916// }
2000// qApp->processEvents(); 1917// qApp->processEvents();
2001 secCount++; 1918 secCount++;
2002} 1919}
2003 1920
2004void QtRec::changeTimeSlider(int index) { 1921void QtRec::changeTimeSlider(int index) {
2005 if(ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1922 if(ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
2006 // qDebug("Slider moved to %d",index); 1923 // qDebug("Slider moved to %d",index);
2007 paused = true; 1924 paused = true;
2008 stopped = true; 1925 stopped = true;
2009 1926
2010 sliderPos=index; 1927 sliderPos=index;
2011 1928
2012 QString timeString; 1929 QString timeString;
2013 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 1930 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2;
2014 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1931 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2015 secCount = (int)filePara.numberOfRecordedSeconds; 1932 secCount = (int)filePara.numberOfRecordedSeconds;
2016 timeLabel->setText( timeString+ tr(" seconds")); 1933 timeLabel->setText( timeString+ tr(" seconds"));
2017} 1934}
2018 1935
2019void QtRec::timeSliderPressed() { 1936void QtRec::timeSliderPressed() {
2020 if(ListView1->currentItem() == 0) return; 1937 if(ListView1->currentItem() == 0) return;
2021 // qDebug("slider pressed"); 1938 // qDebug("slider pressed");
2022 paused = true; 1939 paused = true;
2023 stopped = true; 1940 stopped = true;
2024} 1941}
2025 1942
2026void QtRec::timeSliderReleased() { 1943void QtRec::timeSliderReleased() {
2027 if(ListView1->currentItem() == 0) return; 1944 if(ListView1->currentItem() == 0) return;
2028 sliderPos=timeSlider->value(); 1945 sliderPos=timeSlider->value();
2029 1946
2030 // qDebug("slider released %d", sliderPos); 1947 // qDebug("slider released %d", sliderPos);
2031 stopped = false; 1948 stopped = false;
2032 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1949 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2033 total = newPos*4; 1950 total = newPos*4;
2034 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 1951 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2;
2035 1952
2036 doPlay(); 1953 doPlay();
2037} 1954}
2038 1955
2039void QtRec::rewindPressed() { 1956void QtRec::rewindPressed() {
2040 if(ListView1->currentItem() == 0) return; 1957 if(ListView1->currentItem() == 0) return;
2041 if( !wavFile->track.isOpen()) { 1958 if( !wavFile->track.isOpen()) {
2042 if( !openPlayFile() ) 1959 if( !openPlayFile() )
2043 return; 1960 return;
2044 else 1961 else
2045 if( !setupAudio( false)) 1962 if( !setupAudio( false))
2046 return; 1963 return;
2047 } else { 1964 } else {
2048 killTimers(); 1965 killTimers();
2049 paused = true; 1966 paused = true;
2050 stopped = true; 1967 stopped = true;
2051 rewindTimer->start(50, false); 1968 rewindTimer->start(50, false);
2052 } 1969 }
2053} 1970}
2054 1971
2055void QtRec::rewindTimerTimeout() { 1972void QtRec::rewindTimerTimeout() {
2056 int sliderValue = timeSlider->value(); 1973 int sliderValue = timeSlider->value();
2057 sliderValue = sliderValue-(filePara.numberSamples/100); 1974 sliderValue = sliderValue-(filePara.numberSamples/100);
2058 // if(toBeginningButton->isDown()) 1975 // if(toBeginningButton->isDown())
2059 timeSlider->setValue( sliderValue ) ; 1976 timeSlider->setValue( sliderValue ) ;
2060 // qDebug("%d", sliderValue); 1977 // qDebug("%d", sliderValue);
2061 QString timeString; 1978 QString timeString;
2062 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2; 1979 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2;
2063 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1980 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2064 timeLabel->setText( timeString+ tr(" seconds")); 1981 timeLabel->setText( timeString+ tr(" seconds"));
2065} 1982}
2066 1983
2067void QtRec::rewindReleased() { 1984void QtRec::rewindReleased() {
2068 rewindTimer->stop(); 1985 rewindTimer->stop();
2069 if( wavFile->track.isOpen()) { 1986 if( wavFile->track.isOpen()) {
2070 sliderPos=timeSlider->value(); 1987 sliderPos=timeSlider->value();
2071 stopped = false; 1988 stopped = false;
2072 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1989 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2073 total = newPos*4; 1990 total = newPos*4;
2074 // qDebug("rewind released %d", total); 1991 // qDebug("rewind released %d", total);
2075 startTimer(1000); 1992 startTimer(1000);
2076 doPlay(); 1993 doPlay();
2077 } 1994 }
2078} 1995}
2079 1996
2080void QtRec::FastforwardPressed() { 1997void QtRec::FastforwardPressed() {
2081 if(ListView1->currentItem() == 0) return; 1998 if(ListView1->currentItem() == 0) return;
2082 if( !wavFile->track.isOpen()) 1999 if( !wavFile->track.isOpen())
2083 if( !openPlayFile() ) 2000 if( !openPlayFile() )
2084 return; 2001 return;
2085 else 2002 else
2086 if( !setupAudio( false)) 2003 if( !setupAudio( false))
2087 return; 2004 return;
2088 killTimers(); 2005 killTimers();
2089 2006
2090 paused = true; 2007 paused = true;
2091 stopped = true; 2008 stopped = true;
2092 forwardTimer->start(50, false); 2009 forwardTimer->start(50, false);
2093} 2010}
@@ -2102,153 +2019,150 @@ void QtRec::forwardTimerTimeout() {
2102 2019
2103 QString timeString; 2020 QString timeString;
2104 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2; 2021 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2;
2105 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 2022 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2106 timeLabel->setText( timeString+ tr(" seconds")); 2023 timeLabel->setText( timeString+ tr(" seconds"));
2107} 2024}
2108 2025
2109void QtRec::FastforwardReleased() { 2026void QtRec::FastforwardReleased() {
2110 forwardTimer->stop(); 2027 forwardTimer->stop();
2111 if( wavFile->track.isOpen()) { 2028 if( wavFile->track.isOpen()) {
2112 sliderPos=timeSlider->value(); 2029 sliderPos=timeSlider->value();
2113 stopped = false; 2030 stopped = false;
2114 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 2031 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2115 total = newPos*4; 2032 total = newPos*4;
2116 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 2033 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2;
2117 startTimer(1000); 2034 startTimer(1000);
2118 doPlay(); 2035 doPlay();
2119 } 2036 }
2120} 2037}
2121 2038
2122 2039
2123QString QtRec::getStorage(const QString &fileName) { 2040QString QtRec::getStorage(const QString &fileName) {
2124 2041
2125 StorageInfo storageInfo; 2042 StorageInfo storageInfo;
2126 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2043 const QList<FileSystem> &fs = storageInfo.fileSystems();
2127 QListIterator<FileSystem> it ( fs ); 2044 QListIterator<FileSystem> it ( fs );
2128 QString storage; 2045 QString storage;
2129 for( ; it.current(); ++it ){ 2046 for( ; it.current(); ++it ){
2130 const QString name = (*it)->name(); 2047 const QString name = (*it)->name();
2131 const QString path = (*it)->path(); 2048 const QString path = (*it)->path();
2132 const QString disk = (*it)->disk(); 2049 const QString disk = (*it)->disk();
2133 if( fileName.find(path,0,true) != -1) 2050 if( fileName.find(path,0,true) != -1)
2134 storage=name; 2051 storage=name;
2135 // const QString options = (*it)->options(); 2052 // const QString options = (*it)->options();
2136 // if( name.find( tr("Internal"),0,true) == -1) { 2053 // if( name.find( tr("Internal"),0,true) == -1) {
2137 // storageComboBox->insertItem( name +" -> "+disk); 2054 // storageComboBox->insertItem( name +" -> "+disk);
2138 // qDebug(name); 2055 // qDebug(name);
2139 } 2056 }
2140 return storage; 2057 return storage;
2141 // struct mntent *me; 2058 // struct mntent *me;
2142 // // if(fileName == "/etc/mtab") { 2059 // // if(fileName == "/etc/mtab") {
2143 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 2060 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
2144 // if ( mntfp ) { 2061 // if ( mntfp ) {
2145 // while ( (me = getmntent( mntfp )) != 0 ) { 2062 // while ( (me = getmntent( mntfp )) != 0 ) {
2146 // QString filesystemType = me->mnt_type; 2063 // QString filesystemType = me->mnt_type;
2147 2064
2148 // } 2065 // }
2149 // } 2066 // }
2150 // endmntent( mntfp ); 2067 // endmntent( mntfp );
2151} 2068}
2152 2069
2153void QtRec::setRecordButton(bool b) { 2070void QtRec::setRecordButton(bool b) {
2154 2071
2155 if(b) { //about to record or play 2072 if(b) { //about to record or play
2156 2073
2157 Rec_PushButton->setDown(true); 2074 Rec_PushButton->setDown(true);
2158 QPixmap image3( ( const char** ) image3_data ); 2075 QPixmap image3( ( const char** ) image3_data );
2159 Stop_PushButton->setPixmap( image3 ); 2076 Stop_PushButton->setPixmap( image3 );
2160 if(Stop_PushButton->isDown()) 2077 if(Stop_PushButton->isDown())
2161 Stop_PushButton->setDown(true); 2078 Stop_PushButton->setDown(true);
2162 playLabel2->setText(tr("Stop") ); 2079 playLabel2->setText(tr("Stop") );
2163 2080
2164 } else { //about to stop 2081 } else { //about to stop
2165 2082
2166 QPixmap image4( ( const char** ) image4_data ); 2083 QPixmap image4( ( const char** ) image4_data );
2167 Stop_PushButton->setPixmap( image4); 2084 Stop_PushButton->setPixmap( image4);
2168 if(Stop_PushButton->isDown()) 2085 if(Stop_PushButton->isDown())
2169 Stop_PushButton->setDown(false); 2086 Stop_PushButton->setDown(false);
2170 playLabel2->setText(tr("Play") ); 2087 playLabel2->setText(tr("Play") );
2171 if(Rec_PushButton->isDown()) 2088 if(Rec_PushButton->isDown())
2172 Rec_PushButton->setDown( false); 2089 Rec_PushButton->setDown( false);
2173 } 2090 }
2174} 2091}
2175 2092
2176void QtRec::fillDirectoryCombo() { 2093void QtRec::fillDirectoryCombo() {
2177 if( directoryComboBox->count() > 0) 2094 if( directoryComboBox->count() > 0)
2178 directoryComboBox->clear(); 2095 directoryComboBox->clear();
2179 int index=0; 2096 int index=0;
2180 Config cfg("OpieRec"); 2097 Config cfg("OpieRec");
2181 cfg.setGroup("Settings"); 2098 cfg.setGroup("Settings");
2182 QString dir= cfg.readEntry("directory", "/"); 2099 QString dir= cfg.readEntry("directory", "/");
2183 StorageInfo storageInfo; 2100 StorageInfo storageInfo;
2184 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2101 const QList<FileSystem> &fs = storageInfo.fileSystems();
2185 QListIterator<FileSystem> it ( fs ); 2102 QListIterator<FileSystem> it ( fs );
2186 QString storage; 2103 QString storage;
2187 for( ; it.current(); ++it ){ 2104 for( ; it.current(); ++it ){
2188 const QString name = (*it)->name(); 2105 const QString name = (*it)->name();
2189 const QString path = (*it)->path(); 2106 const QString path = (*it)->path();
2190 // directoryComboBox->insertItem(name+" "+path); 2107 // directoryComboBox->insertItem(name+" "+path);
2191 directoryComboBox->insertItem(name); 2108 directoryComboBox->insertItem(name);
2192 if(path==dir) 2109 if(path==dir)
2193 directoryComboBox->setCurrentItem(index); 2110 directoryComboBox->setCurrentItem(index);
2194 index++; 2111 index++;
2195 } 2112 }
2196} 2113}
2197 2114
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,135 +1,135 @@
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;
40class QVBoxLayout; 40class QVBoxLayout;
41class QLineEdit; 41class QLineEdit;
42 42
43#define MAX_TRACKS 2 43#define MAX_TRACKS 2
44//#define BUFSIZE 4096 44//#define BUFSIZE 4096
45// #define BUFSIZE 8182 //Z default buffer size 45// #define BUFSIZE 8182 //Z default buffer size
46#define BUFSIZE 1024 46#define BUFSIZE 1024
47//#define BUFSIZE 2048 47//#define BUFSIZE 2048
48#define FRAGSIZE 0x7fff000A; 48#define FRAGSIZE 0x7fff000A;
49 49
50#define WAVE_FORMAT_DVI_ADPCM (0x0011) 50#define WAVE_FORMAT_DVI_ADPCM (0x0011)
51#define WAVE_FORMAT_PCM (0x0001) 51#define WAVE_FORMAT_PCM (0x0001)
52//AFMT_IMA_ADPCM 52//AFMT_IMA_ADPCM
53 53
54class QtRec : public QWidget 54class QtRec : public QWidget
55{ 55{
56 Q_OBJECT 56 Q_OBJECT
57 57
58public: 58public:
59 QtRec( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 59 QtRec( QWidget* parent=0, const char* name=0, WFlags fl=0 );
60 ~QtRec(); 60 ~QtRec();
61 QSlider *OutputSlider,*InputSlider; 61 QSlider *OutputSlider,*InputSlider;
62 62
63public slots: 63public slots:
64private: 64private:
65// int fragment; 65// int fragment;
66 int fd1; 66 int fd1;
67 int secCount; 67 int secCount;
68 QString timeString; 68 QString timeString;
69 69
70 QLineEdit *renameBox; 70 QLineEdit *renameBox;
71 QGroupBox* GroupBox1; 71 QGroupBox* GroupBox1;
72 QString currentFile; 72 QString currentFile;
73 QString date, currentFileName, tmpFileName; 73 QString date, currentFileName, tmpFileName;
74 QTimer *t_timer; 74 QTimer *t_timer;
75 bool needsStereoOut, paused, playing; 75 bool needsStereoOut, paused, playing;
76 bool useTmpFile, autoMute; 76 bool useTmpFile, autoMute;
77 77
78 bool eventFilter( QObject * , QEvent * ); 78 bool eventFilter( QObject * , QEvent * );
79 void okRename(); 79 void okRename();
80 void cancelRename(); 80 void cancelRename();
81 QString getStorage(const QString &); 81 QString getStorage(const QString &);
82 bool rec(); 82 bool rec();
83 int getCurrentSizeLimit(); 83 int getCurrentSizeLimit();
84 long checkDiskSpace(const QString &); 84 long checkDiskSpace(const QString &);
85 void doMute(bool); 85 void doMute(bool);
86 void errorStop(); 86 void errorStop();
87 void fillDirectoryCombo(); 87 void fillDirectoryCombo();
88 void getInVol(); 88 void getInVol();
89 void getOutVol(); 89 void getOutVol();
90 void init(); 90 void init();
91 void initConfig(); 91 void initConfig();
92 void initConnections(); 92 void initConnections();
93 void selectItemByName(const QString &); 93 void selectItemByName(const QString &);
94 void setRecordButton(bool); 94 void setRecordButton(bool);
95 void start(); 95 void start();
96 void stop(); 96 void stop();
97 void timerEvent( QTimerEvent *e ); 97 void timerEvent( QTimerEvent *e );
98 98
99private slots: 99private slots:
100 100
101 101
102 void FastforwardPressed(); 102 void FastforwardPressed();
103 void FastforwardReleased(); 103 void FastforwardReleased();
104 void changeDirCombo(int); 104 void changeDirCombo(int);
105 void changeSizeLimitCombo(int); 105 void changeSizeLimitCombo(int);
106 void changeTimeSlider(int); 106 void changeTimeSlider(int);
107 void changebitrateCombo(int); 107 void changebitrateCombo(int);
108 void changedInVolume(); 108 void changedInVolume();
109 void changedOutVolume(); 109 void changedOutVolume();
110 void changesamplerateCombo(int); 110 void changesamplerateCombo(int);
111 void cleanUp(); 111 void cleanUp();
112 void compressionSelected(bool); 112 void compressionSelected(bool);
113 void deleteSound(); 113 void deleteSound();
114 void doBeam(); 114 void doBeam();
115 void doMenuPlay(); 115 void doMenuPlay();
116 void doMicMuting(bool); 116 void doMicMuting(bool);
117 void doPlayBtn(); 117 void doPlayBtn();
118 void doRename(); 118 void doRename();
119 void doVolMuting(bool); 119 void doVolMuting(bool);
120 void forwardTimerTimeout(); 120 void forwardTimerTimeout();
121 void itClick(QListViewItem *item); 121 void itClick(QListViewItem *item);
122 void listPressed(int, QListViewItem *, const QPoint&, int); 122 void listPressed(int, QListViewItem *, const QPoint&, int);
123 void newSound(); 123 void newSound();
124 void rewindPressed(); 124 void rewindPressed();
125 void rewindReleased(); 125 void rewindReleased();
126 void rewindTimerTimeout(); 126 void rewindTimerTimeout();
127 void slotAutoMute(bool); 127 void slotAutoMute(bool);
128 void thisTab(QWidget*); 128 void thisTab(QWidget*);
129 void timeSliderPressed(); 129 void timeSliderPressed();
130 void timeSliderReleased(); 130 void timeSliderReleased();
131 void timerBreak(); 131 void timerBreak();
132/* void changedOutVolume(int); */ 132/* void changedOutVolume(int); */
133/* void changedInVolume(int); */ 133/* void changedInVolume(int); */
134 134
135protected: 135protected: