summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index e3385cd..1141faa 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,2138 +1,2144 @@
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#define DEV_VERSION 6#define DEV_VERSION
7 7
8#include "pixmaps.h" 8#include "pixmaps.h"
9#include "qtrec.h" 9#include "qtrec.h"
10#include "waveform.h" 10#include "waveform.h"
11extern "C" { 11extern "C" {
12#include "adpcm.h" 12#include "adpcm.h"
13} 13}
14 14
15/* OPIE */ 15/* OPIE */
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/qcopenvelope_qws.h> 18#include <qpe/qcopenvelope_qws.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/storage.h> 21#include <qpe/storage.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT */ 24/* QT */
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qtimer.h> 37#include <qtimer.h>
38 38
39/* STD */ 39/* STD */
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <math.h> 42#include <math.h>
43#include <mntent.h> 43#include <mntent.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <sys/ioctl.h> 46#include <sys/ioctl.h>
47#include <sys/soundcard.h> 47#include <sys/soundcard.h>
48#include <sys/stat.h> 48#include <sys/stat.h>
49#include <sys/time.h> 49#include <sys/time.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/vfs.h> 51#include <sys/vfs.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <sys/wait.h> 53#include <sys/wait.h>
54#include <sys/signal.h> 54#include <sys/signal.h>
55#include <pthread.h> 55#include <pthread.h>
56 56
57#ifdef PDAUDIO //ALSA 57#ifdef PDAUDIO //ALSA
58#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
60static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
61#else //OSS 61#else //OSS
62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
63static int deviceBitRates[] = { 8, 16, -1 }; 63static int deviceBitRates[] = { 8, 16, -1 };
64#endif 64#endif
65 65
66#if defined(QT_QWS_SL5XXX) 66#if defined(QT_QWS_SL5XXX)
67///#if defined(QT_QWS_EBX) 67///#if defined(QT_QWS_EBX)
68 68
69#define DSPSTROUT "/dev/dsp" 69#define DSPSTROUT "/dev/dsp"
70#define DSPSTRIN "/dev/dsp1"
71#define DSPSTRMIXEROUT "/dev/mixer" 70#define DSPSTRMIXEROUT "/dev/mixer"
71
72#ifdef SHARP
73#define DSPSTRIN "/dev/dsp1"
72#define DSPSTRMIXERIN "/dev/mixer1" 74#define DSPSTRMIXERIN "/dev/mixer1"
75#else
76#define DSPSTRIN "/dev/dsp"
77#define DSPSTRMIXERIN "/dev/mixer"
78#endif
73 79
74#else 80#else
75 81
76#define DSPSTROUT "/dev/dsp" 82#define DSPSTROUT "/dev/dsp"
77#define DSPSTRIN "/dev/dsp" 83#define DSPSTRIN "/dev/dsp"
78#define DSPSTRMIXERIN "/dev/mixer" 84#define DSPSTRMIXERIN "/dev/mixer"
79#define DSPSTRMIXEROUT "/dev/mixer" 85#define DSPSTRMIXEROUT "/dev/mixer"
80 86
81#endif 87#endif
82 88
83//#define ZAURUS 0 89//#define ZAURUS 0
84struct adpcm_state encoder_state; 90struct adpcm_state encoder_state;
85struct adpcm_state decoder_state; 91struct adpcm_state decoder_state;
86 92
87typedef struct { 93typedef struct {
88 int sampleRate; 94 int sampleRate;
89 /* int fragSize; */ 95 /* int fragSize; */
90 /* int blockSize; */ 96 /* int blockSize; */
91 int resolution; //bitrate 97 int resolution; //bitrate
92 int channels; //number of channels 98 int channels; //number of channels
93 int fd; //file descriptor 99 int fd; //file descriptor
94 int sd; //sound device descriptor 100 int sd; //sound device descriptor
95 int numberSamples; //total number of samples 101 int numberSamples; //total number of samples
96 int SecondsToRecord; // number of seconds that should be recorded 102 int SecondsToRecord; // number of seconds that should be recorded
97 float numberOfRecordedSeconds; //total number of samples recorded 103 float numberOfRecordedSeconds; //total number of samples recorded
98 int samplesToRecord; //number of samples to be recorded 104 int samplesToRecord; //number of samples to be recorded
99 int inVol; //input volume 105 int inVol; //input volume
100 int outVol; //output volume 106 int outVol; //output volume
101 int format; //wavfile format PCM.. ADPCM 107 int format; //wavfile format PCM.. ADPCM
102 const char *fileName; //name of fiel to be played/recorded 108 const char *fileName; //name of fiel to be played/recorded
103} fileParameters; 109} fileParameters;
104 110
105fileParameters filePara; 111fileParameters filePara;
106 112
107bool monitoring, recording, playing; 113bool monitoring, recording, playing;
108bool stopped; 114bool stopped;
109QLabel *timeLabel; 115QLabel *timeLabel;
110QSlider *timeSlider; 116QSlider *timeSlider;
111int sd; 117int sd;
112 118
113Waveform* waveform; 119Waveform* waveform;
114Device *soundDevice; 120Device *soundDevice;
115 121
116 122
117#ifdef THREADED 123#ifdef THREADED
118void quickRec() 124void quickRec()
119#else 125#else
120 void QtRec::quickRec() 126 void QtRec::quickRec()
121#endif 127#endif
122{ 128{
123 129
124 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl; 130 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl;
125 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate 131 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate
126 << ", channels " << filePara.channels << oendl; 132 << ", channels " << filePara.channels << oendl;
127 133
128 int total = 0; // Total number of bytes read in so far. 134 int total = 0; // Total number of bytes read in so far.
129 int bytesWritten, number; 135 int bytesWritten, number;
130 136
131 bytesWritten = 0; 137 bytesWritten = 0;
132 number = 0; 138 number = 0;
133 QString num; 139 QString num;
134 int level = 0; 140 int level = 0;
135 int threshold = 0; 141 int threshold = 0;
136 int bits = filePara.resolution; 142 int bits = filePara.resolution;
137 odebug << "bits " << bits << "" << oendl; 143 odebug << "bits " << bits << "" << oendl;
138 144
139 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 145 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
140 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; 146 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
141 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; 147 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
142 odebug << "" << filePara.sd << "" << oendl; 148 odebug << "" << filePara.sd << "" << oendl;
143 level = 7; 149 level = 7;
144 threshold = 0; 150 threshold = 0;
145 151
146 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 152 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
147 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; 153 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
148// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 154// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
149 char abuf[ BUFSIZE/2 ]; 155 char abuf[ BUFSIZE/2 ];
150 short sbuf[ BUFSIZE ]; 156 short sbuf[ BUFSIZE ];
151 short sbuf2[ BUFSIZE ]; 157 short sbuf2[ BUFSIZE ];
152 memset( abuf, 0, BUFSIZE/2); 158 memset( abuf, 0, BUFSIZE/2);
153 memset( sbuf, 0, BUFSIZE); 159 memset( sbuf, 0, BUFSIZE);
154 memset( sbuf2, 0, BUFSIZE); 160 memset( sbuf2, 0, BUFSIZE);
155 161
156 for(;;) { 162 for(;;) {
157 if ( stopped) { 163 if ( stopped) {
158 odebug << "quickRec:: stopped" << oendl; 164 odebug << "quickRec:: stopped" << oendl;
159 break; 165 break;
160 } 166 }
161 167
162// number=::read( filePara.sd, sbuf, BUFSIZE); 168// number=::read( filePara.sd, sbuf, BUFSIZE);
163 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE); 169 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE);
164 170
165 if(number <= 0) { 171 if(number <= 0) {
166 perror("recording error "); 172 perror("recording error ");
167 odebug << "" << filePara.fileName << " " << number << "" << oendl; 173 odebug << "" << filePara.fileName << " " << number << "" << oendl;
168 stopped = true; 174 stopped = true;
169 return; 175 return;
170 } 176 }
171 //if(stereo == 2) { 177 //if(stereo == 2) {
172// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 178// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
173 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 179 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
174 180
175 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); 181 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
176 182
177 waveform->newSamples( sbuf, number ); 183 waveform->newSamples( sbuf, number );
178 184
179 total += bytesWritten; 185 total += bytesWritten;
180 filePara.numberSamples = total; 186 filePara.numberSamples = total;
181 timeSlider->setValue( total); 187 timeSlider->setValue( total);
182 188
183 printf("%d, bytes %d,total %d\r",number, bytesWritten, total); 189 printf("%d, bytes %d,total %d\r",number, bytesWritten, total);
184 fflush(stdout); 190 fflush(stdout);
185 191
186 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; 192 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels;
187 193
188 qApp->processEvents(); 194 qApp->processEvents();
189 if( total >= filePara.samplesToRecord) { 195 if( total >= filePara.samplesToRecord) {
190 stopped = true; 196 stopped = true;
191 break; 197 break;
192 } 198 }
193 } 199 }
194 } else { 200 } else {
195 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 201 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
196 odebug << "start recording WAVE_FORMAT_PCM" << oendl; 202 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
197 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 203 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
198 memset( inbuffer, 0, BUFSIZE); 204 memset( inbuffer, 0, BUFSIZE);
199 memset( outbuffer, 0, BUFSIZE); 205 memset( outbuffer, 0, BUFSIZE);
200 206
201 for(;;) { 207 for(;;) {
202 if ( stopped) { 208 if ( stopped) {
203 odebug << "quickRec:: stopped" << oendl; 209 odebug << "quickRec:: stopped" << oendl;
204 stopped = true; 210 stopped = true;
205 break; // stop if playing was set to false 211 break; // stop if playing was set to false
206 return; 212 return;
207 } 213 }
208 214
209 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE); 215 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE);
210 216
211 if( number <= 0) { 217 if( number <= 0) {
212 perror( "recording error "); 218 perror( "recording error ");
213 odebug << filePara.fileName << oendl; 219 odebug << filePara.fileName << oendl;
214 stopped = true; 220 stopped = true;
215 return; 221 return;
216 } 222 }
217 223
218 bytesWritten = ::write( filePara.fd , inbuffer, number); 224 bytesWritten = ::write( filePara.fd , inbuffer, number);
219 waveform->newSamples( inbuffer, number ); 225 waveform->newSamples( inbuffer, number );
220 226
221 if( bytesWritten < 0) { 227 if( bytesWritten < 0) {
222 perror("File writing error "); 228 perror("File writing error ");
223 stopped = true; 229 stopped = true;
224 return; 230 return;
225 } 231 }
226 232
227 total += bytesWritten; 233 total += bytesWritten;
228 234
229 filePara.numberSamples = total; 235 filePara.numberSamples = total;
230 236
231 if( filePara.SecondsToRecord != 0) 237 if( filePara.SecondsToRecord != 0)
232 timeSlider->setValue( total); 238 timeSlider->setValue( total);
233 printf("%d, bytes %d,total %d\r",number, bytesWritten , total); 239 printf("%d, bytes %d,total %d\r",number, bytesWritten , total);
234 fflush(stdout); 240 fflush(stdout);
235 241
236 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate 242 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate
237 / (float)2/filePara.channels; 243 / (float)2/filePara.channels;
238 qApp->processEvents(); 244 qApp->processEvents();
239 245
240 if( total >= filePara.samplesToRecord) { 246 if( total >= filePara.samplesToRecord) {
241 stopped = true; 247 stopped = true;
242 break; 248 break;
243 } 249 }
244 } 250 }
245 } //end main loop 251 } //end main loop
246 252
247 } else { 253 } else {
248// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 254// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
249 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 255 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
250 memset( unsigned_inbuffer, 0, BUFSIZE); 256 memset( unsigned_inbuffer, 0, BUFSIZE);
251 memset( unsigned_outbuffer, 0, BUFSIZE); 257 memset( unsigned_outbuffer, 0, BUFSIZE);
252 258
253 for(;;) { 259 for(;;) {
254 if ( stopped) { 260 if ( stopped) {
255 odebug << "quickRec:: stopped" << oendl; 261 odebug << "quickRec:: stopped" << oendl;
256 break; // stop if playing was set to false 262 break; // stop if playing was set to false
257 } 263 }
258 264
259 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE); 265 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE);
260 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 266 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
261 waveform->newSamples( (const short *) unsigned_inbuffer, number ); 267 waveform->newSamples( (const short *) unsigned_inbuffer, number );
262 268
263 if(bytesWritten < 0) { 269 if(bytesWritten < 0) {
264 stopped = true; 270 stopped = true;
265 QMessageBox::message("Note","<p>There was a problem writing to the file</p>"); 271 QMessageBox::message("Note","<p>There was a problem writing to the file</p>");
266 perror("File writing error "); 272 perror("File writing error ");
267 return; 273 return;
268 } 274 }
269 275
270 total += bytesWritten; 276 total += bytesWritten;
271 filePara.numberSamples = total; 277 filePara.numberSamples = total;
272 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total); 278 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total);
273 // fflush(stdout); 279 // fflush(stdout);
274 if( filePara.SecondsToRecord !=0) 280 if( filePara.SecondsToRecord !=0)
275 timeSlider->setValue( total); 281 timeSlider->setValue( total);
276 282
277 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 283 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
278 284
279 qApp->processEvents(); 285 qApp->processEvents();
280 if( total >= filePara.samplesToRecord) { 286 if( total >= filePara.samplesToRecord) {
281 stopped = true; 287 stopped = true;
282 break; 288 break;
283 } 289 }
284 } //end main loop 290 } //end main loop
285 } 291 }
286} /// END quickRec() 292} /// END quickRec()
287 293
288 294
289#ifdef THREADED 295#ifdef THREADED
290void playIt() 296void playIt()
291#else 297#else
292 void QtRec::playIt() 298 void QtRec::playIt()
293#endif 299#endif
294{ 300{
295 int bytesWritten = 0; 301 int bytesWritten = 0;
296 int number = 0; 302 int number = 0;
297 int total = 0; // Total number of bytes read in so far. 303 int total = 0; // Total number of bytes read in so far.
298 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 304 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
299 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 305 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
300 char abuf[ BUFSIZE / 2 ]; 306 char abuf[ BUFSIZE / 2 ];
301 short sbuf[ BUFSIZE ]; 307 short sbuf[ BUFSIZE ];
302 short sbuf2[ BUFSIZE * 2 ]; 308 short sbuf2[ BUFSIZE * 2 ];
303 memset( abuf, 0, BUFSIZE / 2); 309 memset( abuf, 0, BUFSIZE / 2);
304 memset( sbuf, 0, BUFSIZE); 310 memset( sbuf, 0, BUFSIZE);
305 memset( sbuf2, 0, BUFSIZE * 2); 311 memset( sbuf2, 0, BUFSIZE * 2);
306// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 312// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
307 for(;;) { // play loop 313 for(;;) { // play loop
308 if ( stopped) { 314 if ( stopped) {
309 break; 315 break;
310 return; 316 return;
311 }// stop if playing was set to false 317 }// stop if playing was set to false
312 318
313 number = ::read( filePara.fd, abuf, BUFSIZE / 2); 319 number = ::read( filePara.fd, abuf, BUFSIZE / 2);
314 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); 320 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
315 321
316// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 322// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
317// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 323// sbuf2[i+1]=sbuf2[i]=sbuf[i];
318// } 324// }
319 bytesWritten = write ( filePara.sd, sbuf, number * 4); 325 bytesWritten = write ( filePara.sd, sbuf, number * 4);
320 waveform->newSamples( (const short *)sbuf, number *4); 326 waveform->newSamples( (const short *)sbuf, number *4);
321 // if(filePara.channels==1) 327 // if(filePara.channels==1)
322 // total += bytesWritten/2; //mono 328 // total += bytesWritten/2; //mono
323 // else 329 // else
324 total += bytesWritten; 330 total += bytesWritten;
325 filePara.numberSamples = total/4; 331 filePara.numberSamples = total/4;
326 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 332 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
327 333
328 timeSlider->setValue( total/4); 334 timeSlider->setValue( total/4);
329// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 335// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
330// if(filePara.numberOfRecordedSeconds>1) 336// if(filePara.numberOfRecordedSeconds>1)
331// timeLabel->setText( timeString+ tr(" seconds")); 337// timeLabel->setText( timeString+ tr(" seconds"));
332// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 338// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
333// fflush(stdout); 339// fflush(stdout);
334 340
335 qApp->processEvents(); 341 qApp->processEvents();
336 342
337 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 343 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
338// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { 344// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
339 stopped = true; 345 stopped = true;
340 break; 346 break;
341 } 347 }
342 } 348 }
343 } else { 349 } else {
344 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 350 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
345 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 351 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
346 memset( inbuffer, 0, BUFSIZE); 352 memset( inbuffer, 0, BUFSIZE);
347 memset( outbuffer, 0, BUFSIZE); 353 memset( outbuffer, 0, BUFSIZE);
348 354
349 for(;;) { // play loop 355 for(;;) { // play loop
350 if ( stopped) { 356 if ( stopped) {
351 break; 357 break;
352 return; 358 return;
353 } 359 }
354// stop if playing was set to false 360// stop if playing was set to false
355 number = ::read( filePara.fd, inbuffer, BUFSIZE); 361 number = ::read( filePara.fd, inbuffer, BUFSIZE);
356// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 362// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
357// // for (int i=0;i< number ; i++) { //2*i is left channel 363// // for (int i=0;i< number ; i++) { //2*i is left channel
358// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 364// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
359// } 365// }
360 bytesWritten = ::write( filePara.sd, inbuffer, number); 366 bytesWritten = ::write( filePara.sd, inbuffer, number);
361 waveform->newSamples( inbuffer, number); 367 waveform->newSamples( inbuffer, number);
362 //-------------->>>> out to device 368 //-------------->>>> out to device
363 // total+=bytesWritten; 369 // total+=bytesWritten;
364 // if(filePara.channels==1) 370 // if(filePara.channels==1)
365 // total += bytesWritten/2; //mono 371 // total += bytesWritten/2; //mono
366 // else 372 // else
367 total += bytesWritten; 373 total += bytesWritten;
368 timeSlider->setValue( total); 374 timeSlider->setValue( total);
369 375
370 filePara.numberSamples = total; 376 filePara.numberSamples = total;
371 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 377 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
372 378
373// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 379// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
374// timeLabel->setText( timeString + tr(" seconds")); 380// timeLabel->setText( timeString + tr(" seconds"));
375 381
376 qApp->processEvents(); 382 qApp->processEvents();
377 383
378 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 384 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
379 owarn << "Jane! Stop this crazy thing!" << oendl; 385 owarn << "Jane! Stop this crazy thing!" << oendl;
380 stopped = true; 386 stopped = true;
381// playing = false; 387// playing = false;
382 break; 388 break;
383 } 389 }
384 } 390 }
385// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 391// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
386// fflush(stdout); 392// fflush(stdout);
387 } //end loop 393 } //end loop
388 } else { 394 } else {
389/////////////////////////////// format = AFMT_U8; 395/////////////////////////////// format = AFMT_U8;
390 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; 396 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
391 memset( unsigned_inbuffer, 0, BUFSIZE); 397 memset( unsigned_inbuffer, 0, BUFSIZE);
392 for(;;) { 398 for(;;) {
393// main loop 399// main loop
394 if (stopped) { 400 if (stopped) {
395 break; // stop if playing was set to false 401 break; // stop if playing was set to false
396 return; 402 return;
397 } 403 }
398 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 404 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
399//data = (val >> 8) ^ 0x80; 405//data = (val >> 8) ^ 0x80;
400 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 406 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
401 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 407 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
402 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); 408 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
403 total += bytesWritten; 409 total += bytesWritten;
404 410
405 timeSlider->setValue( total); 411 timeSlider->setValue( total);
406 filePara.numberSamples = total; 412 filePara.numberSamples = total;
407 413
408 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 414 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
409// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 415// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
410// timeLabel->setText( timeString + tr(" seconds")); 416// timeLabel->setText( timeString + tr(" seconds"));
411 qApp->processEvents(); 417 qApp->processEvents();
412 418
413 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 419 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
414// if( total >= filePara.numberSamples ) { 420// if( total >= filePara.numberSamples ) {
415 stopped = true; 421 stopped = true;
416 break; 422 break;
417 } 423 }
418// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 424// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
419// fflush(stdout); 425// fflush(stdout);
420 } 426 }
421 } 427 }
422} 428}
423 429
424 430
425QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 431QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
426 : QWidget( parent, name, fl ) 432 : QWidget( parent, name, fl )
427{ 433{
428 if ( !name ) 434 if ( !name )
429 setName( "OpieRec" ); 435 setName( "OpieRec" );
430 init(); 436 init();
431 initConfig(); 437 initConfig();
432 initConnections(); 438 initConnections();
433 renameBox = 0; 439 renameBox = 0;
434 440
435// open sound device to get volumes 441// open sound device to get volumes
436 Config hwcfg("OpieRec"); 442 Config hwcfg("OpieRec");
437 hwcfg.setGroup("Hardware"); 443 hwcfg.setGroup("Hardware");
438 444
439 445
440 soundDevice = new Device( this, 446 soundDevice = new Device( this,
441 hwcfg.readEntry( "Audio",DSPSTROUT), 447 hwcfg.readEntry( "Audio",DSPSTROUT),
442 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); 448 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false);
443// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); 449// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false);
444 450
445// soundDevice->setDeviceFormat(AFMT_S16_LE); 451// soundDevice->setDeviceFormat(AFMT_S16_LE);
446// soundDevice->setDeviceChannels(1); 452// soundDevice->setDeviceChannels(1);
447// soundDevice->setDeviceRate( 22050); 453// soundDevice->setDeviceRate( 22050);
448 454
449 getInVol(); 455 getInVol();
450 getOutVol(); 456 getOutVol();
451 457
452 soundDevice->closeDevice( true); 458 soundDevice->closeDevice( true);
453 soundDevice->sd = -1; 459 soundDevice->sd = -1;
454 soundDevice = 0; 460 soundDevice = 0;
455 wavFile = 0; 461 wavFile = 0;
456 462
457// if( soundDevice) delete soundDevice; 463// if( soundDevice) delete soundDevice;
458 464
459 initIconView(); 465 initIconView();
460 466
461 if( autoMute) 467 if( autoMute)
462 doMute( true); 468 doMute( true);
463 ListView1->setFocus(); 469 ListView1->setFocus();
464 playing = false; 470 playing = false;
465} 471}
466 472
467QtRec::~QtRec() { 473QtRec::~QtRec() {
468// if( soundDevice) delete soundDevice; 474// if( soundDevice) delete soundDevice;
469 475
470} 476}
471 477
472void QtRec::cleanUp() { 478void QtRec::cleanUp() {
473 479
474 if( !stopped) { 480 if( !stopped) {
475 stopped = true; 481 stopped = true;
476 endRecording(); 482 endRecording();
477 } 483 }
478 484
479 ListView1->clear(); 485 ListView1->clear();
480 486
481 if( autoMute) 487 if( autoMute)
482 doMute(false); 488 doMute(false);
483 489
484// if( wavFile) delete wavFile; 490// if( wavFile) delete wavFile;
485// if(soundDevice) delete soundDevice; 491// if(soundDevice) delete soundDevice;
486} 492}
487 493
488void QtRec::init() { 494void QtRec::init() {
489 495
490 needsStereoOut = false; 496 needsStereoOut = false;
491 QPixmap image3( ( const char** ) image3_data ); 497 QPixmap image3( ( const char** ) image3_data );
492 QPixmap image4( ( const char** ) image4_data ); 498 QPixmap image4( ( const char** ) image4_data );
493 QPixmap image6( ( const char** ) image6_data ); 499 QPixmap image6( ( const char** ) image6_data );
494 500
495 stopped = true; 501 stopped = true;
496 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 502 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
497 QGridLayout *layout = new QGridLayout( this ); 503 QGridLayout *layout = new QGridLayout( this );
498 layout->setSpacing( 2); 504 layout->setSpacing( 2);
499 layout->setMargin( 2); 505 layout->setMargin( 2);
500 506
501 TabWidget = new QTabWidget( this, "TabWidget" ); 507 TabWidget = new QTabWidget( this, "TabWidget" );
502 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); 508 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8);
503// TabWidget->setTabShape(QTabWidget::Triangular); 509// TabWidget->setTabShape(QTabWidget::Triangular);
504 510
505 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 511 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
506 tab = new QWidget( TabWidget, "tab" ); 512 tab = new QWidget( TabWidget, "tab" );
507 513
508 QGridLayout *layout1 = new QGridLayout( tab); 514 QGridLayout *layout1 = new QGridLayout( tab);
509 layout1->setSpacing( 2); 515 layout1->setSpacing( 2);
510 layout1->setMargin( 2); 516 layout1->setMargin( 2);
511 517
512 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 518 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
513 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 519 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
514 520
515 // timeLabel = new QLabel( tab, "TimeLabel" ); 521 // timeLabel = new QLabel( tab, "TimeLabel" );
516 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 522 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
517 523
518 // playLabel2 = new QLabel(tab, "PlayLabel2" ); 524 // playLabel2 = new QLabel(tab, "PlayLabel2" );
519 // playLabel2->setText(tr("Play") ); 525 // playLabel2->setText(tr("Play") );
520 // playLabel2->setFixedHeight( 18); 526 // playLabel2->setFixedHeight( 18);
521 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 527 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
522 528
523 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 529 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
524 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 530 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
525 Stop_PushButton->setFixedSize( 22, 22); 531 Stop_PushButton->setFixedSize( 22, 22);
526 Stop_PushButton->setPixmap( image4 ); 532 Stop_PushButton->setPixmap( image4 );
527 533
528 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 534 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
529 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 535 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
530 toBeginningButton->setFixedSize( 22, 22); 536 toBeginningButton->setFixedSize( 22, 22);
531 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 537 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") );
532 538
533 toEndButton = new QPushButton( tab, "End_PushButton" ); 539 toEndButton = new QPushButton( tab, "End_PushButton" );
534 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 540 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
535 toEndButton->setFixedSize( 22, 22); 541 toEndButton->setFixedSize( 22, 22);
536 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 542 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) );
537 543
538 // QLabel *recLabel2; 544 // QLabel *recLabel2;
539 // recLabel2 = new QLabel( tab, "recLabel2" ); 545 // recLabel2 = new QLabel( tab, "recLabel2" );
540 // recLabel2->setText(tr("Rec")); 546 // recLabel2->setText(tr("Rec"));
541 // recLabel2->setFixedHeight( 18); 547 // recLabel2->setFixedHeight( 18);
542 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 548 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
543 549
544 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 550 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
545 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 551 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
546 Rec_PushButton->setFixedSize( 22, 22); 552 Rec_PushButton->setFixedSize( 22, 22);
547 Rec_PushButton->setPixmap( image6 ); 553 Rec_PushButton->setPixmap( image6 );
548 554
549 t = new QTimer( this ); 555 t = new QTimer( this );
550 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 556 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
551 557
552 rewindTimer = new QTimer( this ); 558 rewindTimer = new QTimer( this );
553 connect( rewindTimer, SIGNAL( timeout() ), 559 connect( rewindTimer, SIGNAL( timeout() ),
554 this, SLOT( rewindTimerTimeout() ) ); 560 this, SLOT( rewindTimerTimeout() ) );
555 561
556 forwardTimer = new QTimer( this ); 562 forwardTimer = new QTimer( this );
557 connect( forwardTimer, SIGNAL( timeout() ), 563 connect( forwardTimer, SIGNAL( timeout() ),
558 this, SLOT( forwardTimerTimeout() ) ); 564 this, SLOT( forwardTimerTimeout() ) );
559 565
560 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 566 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
561 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 567 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
562 deleteSoundButton->setText( tr( "Del" ) ); 568 deleteSoundButton->setText( tr( "Del" ) );
563 569
564 ListView1 = new QListView( tab, "IconView1" ); 570 ListView1 = new QListView( tab, "IconView1" );
565 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 571 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
566 572
567 ListView1->addColumn( tr( "Name" ) ); 573 ListView1->addColumn( tr( "Name" ) );
568 // ListView1->setColumnWidth( 0, 140); 574 // ListView1->setColumnWidth( 0, 140);
569 ListView1->setSorting( 1, false); 575 ListView1->setSorting( 1, false);
570 ListView1->addColumn( tr( "Time" ) ); //in seconds 576 ListView1->addColumn( tr( "Time" ) ); //in seconds
571 // ListView1->setColumnWidth( 1, -1); 577 // ListView1->setColumnWidth( 1, -1);
572 // ListView1->addColumn( tr("Location") ); 578 // ListView1->addColumn( tr("Location") );
573 // ListView1->setColumnWidth( 2, -1); 579 // ListView1->setColumnWidth( 2, -1);
574 // ListView1->addColumn( tr("Date") ); 580 // ListView1->addColumn( tr("Date") );
575 // ListView1->setColumnWidth( 3, -1); 581 // ListView1->setColumnWidth( 3, -1);
576 ListView1->setColumnWidthMode(0, QListView::Maximum); 582 ListView1->setColumnWidthMode(0, QListView::Maximum);
577 // ListView1->setColumnWidthMode(1, QListView::Maximum); 583 // ListView1->setColumnWidthMode(1, QListView::Maximum);
578 584
579 // ListView1->setColumnWidthMode( 0, QListView::Manual); 585 // ListView1->setColumnWidthMode( 0, QListView::Manual);
580 ListView1->setColumnAlignment( 1, QListView::AlignCenter); 586 ListView1->setColumnAlignment( 1, QListView::AlignCenter);
581 // ListView1->setColumnAlignment( 2, QListView::AlignRight); 587 // ListView1->setColumnAlignment( 2, QListView::AlignRight);
582 // ListView1->setColumnAlignment( 3, QListView::AlignLeft); 588 // ListView1->setColumnAlignment( 3, QListView::AlignLeft);
583 ListView1->setAllColumnsShowFocus( true ); 589 ListView1->setAllColumnsShowFocus( true );
584 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); 590 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold);
585 591
586 TabWidget->insertTab( tab, tr( "Files" ) ); 592 TabWidget->insertTab( tab, tr( "Files" ) );
587 593
588 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 594 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
589 tab_3 = new QWidget( TabWidget, "tab_3" ); 595 tab_3 = new QWidget( TabWidget, "tab_3" );
590 QGridLayout *glayout3 = new QGridLayout( tab_3 ); 596 QGridLayout *glayout3 = new QGridLayout( tab_3 );
591 glayout3->setSpacing( 2); 597 glayout3->setSpacing( 2);
592 glayout3->setMargin( 2); 598 glayout3->setMargin( 2);
593 //////////////////////////////////// 599 ////////////////////////////////////
594 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 600 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
595 sampleGroup->setTitle( tr( "Sample Rate" ) ); 601 sampleGroup->setTitle( tr( "Sample Rate" ) );
596 sampleGroup->setFixedSize( 95,50); 602 sampleGroup->setFixedSize( 95,50);
597 603
598 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 604 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
599 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 605 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
600//#ifndef QT_QWS_EBX 606//#ifndef QT_QWS_EBX
601 QString s; 607 QString s;
602 int z = 0; 608 int z = 0;
603 while( deviceSampleRates[z] != -1) { 609 while( deviceSampleRates[z] != -1) {
604 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); 610 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
605 z++; 611 z++;
606 } 612 }
607 613
608 614
609 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); 615 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
610 616
611 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 617 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
612 sizeGroup->setTitle( tr( "Limit Size" ) ); 618 sizeGroup->setTitle( tr( "Limit Size" ) );
613 sizeGroup->setFixedSize( 80, 50); 619 sizeGroup->setFixedSize( 80, 50);
614 620
615 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 621 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
616 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 622 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
617 sizeLimitCombo->insertItem(tr("Unlimited")); 623 sizeLimitCombo->insertItem(tr("Unlimited"));
618 624
619 for(int i=1;i<13; i++) { 625 for(int i=1;i<13; i++) {
620 sizeLimitCombo->insertItem( QString::number( i * 5)); 626 sizeLimitCombo->insertItem( QString::number( i * 5));
621 } 627 }
622 628
623 629
624 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); 630 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1);
625 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 631 dirGroup = new QGroupBox( tab_3, "dirGroup" );
626 dirGroup->setTitle( tr( "File Directory" ) ); 632 dirGroup->setTitle( tr( "File Directory" ) );
627 dirGroup->setFixedSize( 130, 50); 633 dirGroup->setFixedSize( 130, 50);
628 634
629 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 635 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
630 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 636 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
631 637
632 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); 638 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
633 639
634 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 640 bitGroup = new QGroupBox( tab_3, "bitGroup" );
635 bitGroup->setTitle( tr( "Bit Depth" ) ); 641 bitGroup->setTitle( tr( "Bit Depth" ) );
636 bitGroup->setFixedSize( 65, 50); 642 bitGroup->setFixedSize( 65, 50);
637 643
638 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 644 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
639 645
640 z = 0; 646 z = 0;
641 while( deviceBitRates[z] != -1) { 647 while( deviceBitRates[z] != -1) {
642 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); 648 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
643 z++; 649 z++;
644 } 650 }
645 651
646 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 652 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
647 653
648 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); 654 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
649 655
650 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); 656 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
651 657
652 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); 658 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
653 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); 659 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 );
654 660
655 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); 661 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
656 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); 662 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
657 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); 663 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
658 664
659 tab_5 = new QWidget( TabWidget, "tab_5" ); 665 tab_5 = new QWidget( TabWidget, "tab_5" );
660 666
661 QHBoxLayout *Layout19a; 667 QHBoxLayout *Layout19a;
662 Layout19a = new QHBoxLayout( tab_5); 668 Layout19a = new QHBoxLayout( tab_5);
663 Layout19a->setSpacing( 2 ); 669 Layout19a->setSpacing( 2 );
664 Layout19a->setMargin( 0 ); 670 Layout19a->setMargin( 0 );
665 671
666 Layout15 = new QVBoxLayout( this); 672 Layout15 = new QVBoxLayout( this);
667 Layout15->setSpacing( 2 ); 673 Layout15->setSpacing( 2 );
668 Layout15->setMargin( 0 ); 674 Layout15->setMargin( 0 );
669 675
670 Layout15b = new QVBoxLayout( this); 676 Layout15b = new QVBoxLayout( this);
671 Layout15b->setSpacing( 2 ); 677 Layout15b->setSpacing( 2 );
672 Layout15b->setMargin( 0 ); 678 Layout15b->setMargin( 0 );
673 679
674 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 680 TextLabel2 = new QLabel( tab_5, "InputLabel" );
675 TextLabel2->setText( tr( "In")); 681 TextLabel2->setText( tr( "In"));
676 TextLabel2->setFixedWidth( 35); 682 TextLabel2->setFixedWidth( 35);
677 Layout15->addWidget( TextLabel2 ); 683 Layout15->addWidget( TextLabel2 );
678 684
679 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 685 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
680 TextLabel3->setText( tr( "Out" ) ); 686 TextLabel3->setText( tr( "Out" ) );
681 Layout15b->addWidget( TextLabel3 ); 687 Layout15b->addWidget( TextLabel3 );
682 688
683 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 689 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
684 InputSlider->setTickmarks( QSlider::Both); 690 InputSlider->setTickmarks( QSlider::Both);
685 Layout15->addWidget( InputSlider); 691 Layout15->addWidget( InputSlider);
686 692
687 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 693 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
688 OutputSlider->setTickmarks( QSlider::Both); 694 OutputSlider->setTickmarks( QSlider::Both);
689 695
690 Layout15b->addWidget( OutputSlider ); 696 Layout15b->addWidget( OutputSlider );
691 697
692 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 698 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
693 Layout15->addWidget( outMuteCheckBox ); 699 Layout15->addWidget( outMuteCheckBox );
694 700
695 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 701 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
696 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 702 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
697 Layout15b->addWidget( inMuteCheckBox ); 703 Layout15b->addWidget( inMuteCheckBox );
698 704
699 705
700 Layout19a->addLayout( Layout15 ); 706 Layout19a->addLayout( Layout15 );
701 Layout19a->addLayout( Layout15b ); 707 Layout19a->addLayout( Layout15b );
702 708
703 fillDirectoryCombo(); 709 fillDirectoryCombo();
704 710
705 TabWidget->insertTab( tab_3, tr( "Options" ) ); 711 TabWidget->insertTab( tab_3, tr( "Options" ) );
706 712
707 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 713 TabWidget->insertTab( tab_5, tr( "Volume" ) );
708 714
709 715
710 waveform = new Waveform( this, "waveform" ); 716 waveform = new Waveform( this, "waveform" );
711// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); 717// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
712 waveform->setMinimumSize( QSize( 0, 50 ) ); 718 waveform->setMinimumSize( QSize( 0, 50 ) );
713 719
714 layout->addMultiCellWidget( waveform, 8, 8, 0, 8); 720 layout->addMultiCellWidget( waveform, 8, 8, 0, 8);
715 waveform->setBackgroundColor ( black ); 721 waveform->setBackgroundColor ( black );
716} 722}
717 723
718void QtRec::initIconView() { 724void QtRec::initIconView() {
719 725
720 ListView1->clear(); 726 ListView1->clear();
721 Config cfg("OpieRec"); 727 Config cfg("OpieRec");
722 cfg.setGroup("Sounds"); 728 cfg.setGroup("Sounds");
723 QString temp; 729 QString temp;
724 QPixmap image0( ( const char** ) image0_data ); 730 QPixmap image0( ( const char** ) image0_data );
725 731
726 int nFiles = cfg.readNumEntry("NumberofFiles",0); 732 int nFiles = cfg.readNumEntry("NumberofFiles",0);
727// odebug << "init number of files " << nFiles << "" << oendl; 733// odebug << "init number of files " << nFiles << "" << oendl;
728 734
729 for(int i=1;i<= nFiles;i++) { 735 for(int i=1;i<= nFiles;i++) {
730 736
731 QListViewItem * item; 737 QListViewItem * item;
732 QString fileS, mediaLocation, fileDate, filePath; 738 QString fileS, mediaLocation, fileDate, filePath;
733 739
734 temp.sprintf( "%d",i); 740 temp.sprintf( "%d",i);
735 temp = cfg.readEntry( temp,""); //reads currentFile 741 temp = cfg.readEntry( temp,""); //reads currentFile
736 filePath = cfg.readEntry( temp,""); //currentFileName 742 filePath = cfg.readEntry( temp,""); //currentFileName
737 743
738 QFileInfo info(filePath); 744 QFileInfo info(filePath);
739 fileDate = info.lastModified().toString(); 745 fileDate = info.lastModified().toString();
740 746
741 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 747 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
742 mediaLocation = getStorage( filePath); 748 mediaLocation = getStorage( filePath);
743 if( info.exists()) { 749 if( info.exists()) {
744 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); 750 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/);
745 item->setPixmap( 0, image0); 751 item->setPixmap( 0, image0);
746 if( currentFileName == filePath) 752 if( currentFileName == filePath)
747 ListView1->setSelected( item, true); 753 ListView1->setSelected( item, true);
748 } 754 }
749 } 755 }
750} 756}
751 757
752void QtRec::initConnections() { 758void QtRec::initConnections() {
753 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 759 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
754 760
755 connect( toBeginningButton, SIGNAL( pressed()), 761 connect( toBeginningButton, SIGNAL( pressed()),
756 this, SLOT( rewindPressed() )); 762 this, SLOT( rewindPressed() ));
757 connect( toBeginningButton, SIGNAL( released()), 763 connect( toBeginningButton, SIGNAL( released()),
758 this, SLOT( rewindReleased() )); 764 this, SLOT( rewindReleased() ));
759 connect( toEndButton, SIGNAL( pressed()), 765 connect( toEndButton, SIGNAL( pressed()),
760 this, SLOT( FastforwardPressed() )); 766 this, SLOT( FastforwardPressed() ));
761 connect( toEndButton, SIGNAL( released()), 767 connect( toEndButton, SIGNAL( released()),
762 this, SLOT( FastforwardReleased() )); 768 this, SLOT( FastforwardReleased() ));
763 connect( deleteSoundButton, SIGNAL(released()), 769 connect( deleteSoundButton, SIGNAL(released()),
764 this, SLOT( deleteSound() )); 770 this, SLOT( deleteSound() ));
765 connect( Stop_PushButton, SIGNAL(released()), 771 connect( Stop_PushButton, SIGNAL(released()),
766 this, SLOT( doPlayBtn() )); 772 this, SLOT( doPlayBtn() ));
767 connect( Rec_PushButton, SIGNAL(released()), 773 connect( Rec_PushButton, SIGNAL(released()),
768 this, SLOT( newSound() ) ); 774 this, SLOT( newSound() ) );
769 connect( TabWidget, SIGNAL( currentChanged(QWidget*)), 775 connect( TabWidget, SIGNAL( currentChanged(QWidget*)),
770 this, SLOT(thisTab(QWidget*) )); 776 this, SLOT(thisTab(QWidget*) ));
771 connect( OutputSlider, SIGNAL(sliderReleased()), 777 connect( OutputSlider, SIGNAL(sliderReleased()),
772 this, SLOT( changedOutVolume()) ); 778 this, SLOT( changedOutVolume()) );
773 connect( InputSlider, SIGNAL(sliderReleased()), 779 connect( InputSlider, SIGNAL(sliderReleased()),
774 this, SLOT( changedInVolume()) ); 780 this, SLOT( changedInVolume()) );
775 781
776 connect( sampleRateComboBox, SIGNAL(activated(int)), 782 connect( sampleRateComboBox, SIGNAL(activated(int)),
777 this, SLOT( changesamplerateCombo(int)) ); 783 this, SLOT( changesamplerateCombo(int)) );
778 connect( bitRateComboBox, SIGNAL(activated(int)), 784 connect( bitRateComboBox, SIGNAL(activated(int)),
779 this, SLOT( changebitrateCombo(int)) ); 785 this, SLOT( changebitrateCombo(int)) );
780 786
781 connect( directoryComboBox, SIGNAL(activated(int)), 787 connect( directoryComboBox, SIGNAL(activated(int)),
782 this, SLOT( changeDirCombo(int)) ); 788 this, SLOT( changeDirCombo(int)) );
783 connect( sizeLimitCombo, SIGNAL(activated(int)), 789 connect( sizeLimitCombo, SIGNAL(activated(int)),
784 this, SLOT( changeSizeLimitCombo(int)) ); 790 this, SLOT( changeSizeLimitCombo(int)) );
785 791
786 connect( stereoCheckBox, SIGNAL(toggled(bool)), 792 connect( stereoCheckBox, SIGNAL(toggled(bool)),
787 this, SLOT( changeStereoCheck(bool)) ); 793 this, SLOT( changeStereoCheck(bool)) );
788 794
789 connect( outMuteCheckBox, SIGNAL(toggled(bool)), 795 connect( outMuteCheckBox, SIGNAL(toggled(bool)),
790 this, SLOT( doVolMuting(bool)) ); 796 this, SLOT( doVolMuting(bool)) );
791 connect( inMuteCheckBox , SIGNAL(toggled(bool)), 797 connect( inMuteCheckBox , SIGNAL(toggled(bool)),
792 this, SLOT( doMicMuting(bool)) ); 798 this, SLOT( doMicMuting(bool)) );
793 799
794 connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), 800 connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)),
795 this,SLOT( itClick(QListViewItem*))); 801 this,SLOT( itClick(QListViewItem*)));
796 connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 802 connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
797 this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); 803 this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) );
798 connect( timeSlider, SIGNAL( sliderMoved(int)), 804 connect( timeSlider, SIGNAL( sliderMoved(int)),
799 this, SLOT( changeTimeSlider(int) )); 805 this, SLOT( changeTimeSlider(int) ));
800 connect( timeSlider, SIGNAL( sliderPressed()), 806 connect( timeSlider, SIGNAL( sliderPressed()),
801 this, SLOT( timeSliderPressed() )); 807 this, SLOT( timeSliderPressed() ));
802 connect( timeSlider, SIGNAL( sliderReleased()), 808 connect( timeSlider, SIGNAL( sliderReleased()),
803 this, SLOT( timeSliderReleased() )); 809 this, SLOT( timeSliderReleased() ));
804 connect( compressionCheckBox, SIGNAL( toggled(bool)), 810 connect( compressionCheckBox, SIGNAL( toggled(bool)),
805 this, SLOT( compressionSelected(bool))); 811 this, SLOT( compressionSelected(bool)));
806 connect( autoMuteCheckBox, SIGNAL( toggled(bool)), 812 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),
807 this, SLOT( slotAutoMute(bool))); 813 this, SLOT( slotAutoMute(bool)));
808} 814}
809 815
810void QtRec::initConfig() { 816void QtRec::initConfig() {
811 int index, fred, i; 817 int index, fred, i;
812 Config cfg("OpieRec"); 818 Config cfg("OpieRec");
813 cfg.setGroup("Settings"); 819 cfg.setGroup("Settings");
814 820
815 index = cfg.readNumEntry("samplerate",22050); 821 index = cfg.readNumEntry("samplerate",22050);
816 bool ok; 822 bool ok;
817 823
818 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 824 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
819 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 825 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
820 if( index == fred) { 826 if( index == fred) {
821 filePara.sampleRate = fred; 827 filePara.sampleRate = fred;
822 sampleRateComboBox->setCurrentItem(ws); 828 sampleRateComboBox->setCurrentItem(ws);
823 } 829 }
824 } 830 }
825 831
826 i = cfg.readNumEntry("bitrate",16); 832 i = cfg.readNumEntry("bitrate",16);
827 if(i == 16) 833 if(i == 16)
828 bitRateComboBox->setCurrentItem( 1); 834 bitRateComboBox->setCurrentItem( 1);
829 else if(i == 24) 835 else if(i == 24)
830 bitRateComboBox->setCurrentItem( 2); 836 bitRateComboBox->setCurrentItem( 2);
831 else if(i == 32) 837 else if(i == 32)
832 bitRateComboBox->setCurrentItem( 3); 838 bitRateComboBox->setCurrentItem( 3);
833 else 839 else
834 bitRateComboBox->setCurrentItem( 0); 840 bitRateComboBox->setCurrentItem( 0);
835 841
836 filePara.resolution = i; 842 filePara.resolution = i;
837 843
838 i = cfg.readNumEntry("sizeLimit", 5 ); 844 i = cfg.readNumEntry("sizeLimit", 5 );
839 QString temp; 845 QString temp;
840 sizeLimitCombo->setCurrentItem((i/5)); 846 sizeLimitCombo->setCurrentItem((i/5));
841 847
842 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); 848 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1));
843 if( stereoCheckBox->isChecked()) { 849 if( stereoCheckBox->isChecked()) {
844 filePara.channels = 2; 850 filePara.channels = 2;
845 } else { 851 } else {
846 filePara.channels = 1; 852 filePara.channels = 1;
847 } 853 }
848 854
849 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 855 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
850 if( compressionCheckBox->isChecked()) { 856 if( compressionCheckBox->isChecked()) {
851 bitRateComboBox->setEnabled(false); 857 bitRateComboBox->setEnabled(false);
852 bitRateComboBox->setCurrentItem(0); 858 bitRateComboBox->setCurrentItem(0);
853 filePara.resolution=16; 859 filePara.resolution=16;
854 } 860 }
855 861
856 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 862 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
857 if( autoMuteCheckBox->isChecked()) 863 if( autoMuteCheckBox->isChecked())
858 slotAutoMute(true); 864 slotAutoMute(true);
859 else 865 else
860 slotAutoMute(false); 866 slotAutoMute(false);
861 867
862 Config cofg( "qpe"); 868 Config cofg( "qpe");
863 cofg.setGroup( "Volume"); 869 cofg.setGroup( "Volume");
864 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 870 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
865 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 871 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
866} 872}
867 873
868void QtRec::stop() { 874void QtRec::stop() {
869 owarn << "STOP" << oendl; 875 owarn << "STOP" << oendl;
870 setRecordButton(false); 876 setRecordButton(false);
871 877
872 if( !recording) 878 if( !recording)
873 endPlaying(); 879 endPlaying();
874 else 880 else
875 endRecording(); 881 endRecording();
876 timeSlider->setValue(0); 882 timeSlider->setValue(0);
877} 883}
878 884
879void QtRec::doPlayBtn() { 885void QtRec::doPlayBtn() {
880 886
881 if(!stopped) { 887 if(!stopped) {
882 // playLabel2->setText(tr("Play")); 888 // playLabel2->setText(tr("Play"));
883 stop(); 889 stop();
884 } else { 890 } else {
885 if(ListView1->currentItem() == 0) return; 891 if(ListView1->currentItem() == 0) return;
886 // playLabel2->setText(tr("Stop")); 892 // playLabel2->setText(tr("Stop"));
887 currentFile = ListView1->currentItem()->text(0); 893 currentFile = ListView1->currentItem()->text(0);
888 start(); 894 start();
889 } 895 }
890} 896}
891 897
892void QtRec::start() { //play 898void QtRec::start() { //play
893 if( stopped) { 899 if( stopped) {
894 QPixmap image3( ( const char** ) image3_data ); 900 QPixmap image3( ( const char** ) image3_data );
895 Stop_PushButton->setPixmap( image3 ); 901 Stop_PushButton->setPixmap( image3 );
896 Stop_PushButton->setDown( true); 902 Stop_PushButton->setDown( true);
897 stopped = false; 903 stopped = false;
898 paused = false; 904 paused = false;
899 secCount = 1; 905 secCount = 1;
900 906
901 if( openPlayFile()) 907 if( openPlayFile())
902 if( setupAudio( false)) //recording is false 908 if( setupAudio( false)) //recording is false
903 doPlay(); 909 doPlay();
904 } 910 }
905} 911}
906 912
907bool QtRec::rec() { //record 913bool QtRec::rec() { //record
908 QString timeString; 914 QString timeString;
909 timeString.sprintf("%.0f", 0.0); 915 timeString.sprintf("%.0f", 0.0);
910 // timeLabel->setText( timeString+ " seconds"); 916 // timeLabel->setText( timeString+ " seconds");
911 if(!stopped) { 917 if(!stopped) {
912 monitoring = true; 918 monitoring = true;
913 return false; 919 return false;
914 } else { 920 } else {
915 secCount = 1; 921 secCount = 1;
916 // playLabel2->setText(tr("Stop")); 922 // playLabel2->setText(tr("Stop"));
917 monitoring = false; 923 monitoring = false;
918 setRecordButton( true); 924 setRecordButton( true);
919 925
920 if( setupAudio( true)) 926 if( setupAudio( true))
921 if(setUpFile()) { 927 if(setUpFile()) {
922 int fileSize = 0; 928 int fileSize = 0;
923 Config cfg("OpieRec"); 929 Config cfg("OpieRec");
924 cfg.setGroup("Settings"); 930 cfg.setGroup("Settings");
925// odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits() 931// odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits()
926// << ", device rate " << soundDevice->getDeviceRate() 932// << ", device rate " << soundDevice->getDeviceRate()
927// << ", device channels " << soundDevice->getDeviceChannels() << oendl; 933// << ", device channels " << soundDevice->getDeviceChannels() << oendl;
928 934
929 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 935 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
930// odebug << "sample rate is " << filePara.sampleRate << "" << oendl; 936// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
931 filePara.SecondsToRecord = getCurrentSizeLimit(); 937 filePara.SecondsToRecord = getCurrentSizeLimit();
932 938
933// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; 939// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
934 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 940 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
935 941
936 if( filePara.SecondsToRecord == 0) { 942 if( filePara.SecondsToRecord == 0) {
937 fileSize = diskSize; 943 fileSize = diskSize;
938 } else if( filePara.format == WAVE_FORMAT_PCM) { 944 } else if( filePara.format == WAVE_FORMAT_PCM) {
939// odebug << "WAVE_FORMAT_PCM" << oendl; 945// odebug << "WAVE_FORMAT_PCM" << oendl;
940 fileSize = (filePara.SecondsToRecord ) * filePara.channels 946 fileSize = (filePara.SecondsToRecord ) * filePara.channels
941 * filePara.sampleRate * ( filePara.resolution / 8) + 1000; 947 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
942 } else { 948 } else {
943// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 949// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
944 fileSize = ((filePara.SecondsToRecord) * filePara.channels 950 fileSize = ((filePara.SecondsToRecord) * filePara.channels
945 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; 951 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
946 } 952 }
947 953
948 filePara.samplesToRecord = fileSize; 954 filePara.samplesToRecord = fileSize;
949 odebug << "filesize should be " << filePara.samplesToRecord 955 odebug << "filesize should be " << filePara.samplesToRecord
950 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate; 956 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate;
951 if( paused) { 957 if( paused) {
952 paused = false; 958 paused = false;
953 } 959 }
954 // else { 960 // else {
955 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; 961 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
956 // if(fileSize != 0) 962 // if(fileSize != 0)
957 timeSlider->setRange(0, filePara.samplesToRecord); 963 timeSlider->setRange(0, filePara.samplesToRecord);
958 // } 964 // }
959 965
960 if( diskSize < fileSize/1024) { 966 if( diskSize < fileSize/1024) {
961 QMessageBox::warning(this, 967 QMessageBox::warning(this,
962 tr("Low Disk Space"), 968 tr("Low Disk Space"),
963 tr("You are running low of\nrecording space\n" 969 tr("You are running low of\nrecording space\n"
964 "or a card isn't being recognized")); 970 "or a card isn't being recognized"));
965 stopped = true; //we need to be stopped 971 stopped = true; //we need to be stopped
966 stop(); 972 stop();
967 } else { 973 } else {
968 QString msg; 974 QString msg;
969 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 975 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
970#ifdef DEV_VERSION 976#ifdef DEV_VERSION
971 setCaption( msg); 977 setCaption( msg);
972#endif 978#endif
973 filePara.fileName=currentFile.latin1(); 979 filePara.fileName=currentFile.latin1();
974 odebug << "Start recording" << oendl; 980 odebug << "Start recording" << oendl;
975 stopped = false; 981 stopped = false;
976 982
977#ifdef THREADED 983#ifdef THREADED
978 odebug << "Start recording thread" << oendl; 984 odebug << "Start recording thread" << oendl;
979 pthread_t thread1; 985 pthread_t thread1;
980 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 986 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
981#endif 987#endif
982 toBeginningButton->setEnabled( false); 988 toBeginningButton->setEnabled( false);
983 toEndButton->setEnabled( false); 989 toEndButton->setEnabled( false);
984 990
985 startTimer(1000); 991 startTimer(1000);
986#ifndef THREADED 992#ifndef THREADED
987 quickRec(); 993 quickRec();
988#endif 994#endif
989 } 995 }
990 } //end setUpFile 996 } //end setUpFile
991 } //end setupAudio 997 } //end setupAudio
992 return true; 998 return true;
993} 999}
994/* 1000/*
995 This happens when a tab is selected*/ 1001 This happens when a tab is selected*/
996void QtRec::thisTab(QWidget* widg) { 1002void QtRec::thisTab(QWidget* widg) {
997 if(widg != NULL) { 1003 if(widg != NULL) {
998 int index = TabWidget->currentPageIndex(); 1004 int index = TabWidget->currentPageIndex();
999 1005
1000 if(index == 0) { //file page 1006 if(index == 0) { //file page
1001 } 1007 }
1002 1008
1003 if(index == 1) { //control page 1009 if(index == 1) { //control page
1004 fillDirectoryCombo(); 1010 fillDirectoryCombo();
1005// soundDevice->getOutVol(); 1011// soundDevice->getOutVol();
1006// soundDevice->getInVol(); 1012// soundDevice->getInVol();
1007 } 1013 }
1008 1014
1009 if( index==2) { //help page 1015 if( index==2) { //help page
1010 } 1016 }
1011 1017
1012 qApp->processEvents(); 1018 qApp->processEvents();
1013 update(); 1019 update();
1014 } 1020 }
1015} 1021}
1016 1022
1017void QtRec::getOutVol( ) { 1023void QtRec::getOutVol( ) {
1018 filePara.outVol = soundDevice->getOutVolume(); 1024 filePara.outVol = soundDevice->getOutVolume();
1019// odebug << "out vol " << filePara.outVol << "" << oendl; 1025// odebug << "out vol " << filePara.outVol << "" << oendl;
1020 OutputSlider->setValue( -filePara.outVol); 1026 OutputSlider->setValue( -filePara.outVol);
1021} 1027}
1022 1028
1023void QtRec::getInVol() { 1029void QtRec::getInVol() {
1024 filePara.inVol = soundDevice->getInVolume(); 1030 filePara.inVol = soundDevice->getInVolume();
1025// odebug << "in vol " << filePara.inVol << "" << oendl; 1031// odebug << "in vol " << filePara.inVol << "" << oendl;
1026 InputSlider->setValue( -filePara.inVol); 1032 InputSlider->setValue( -filePara.inVol);
1027} 1033}
1028 1034
1029void QtRec::changedOutVolume() { 1035void QtRec::changedOutVolume() {
1030 soundDevice->changedOutVolume( -OutputSlider->value()); 1036 soundDevice->changedOutVolume( -OutputSlider->value());
1031} 1037}
1032 1038
1033void QtRec::changedInVolume( ) { 1039void QtRec::changedInVolume( ) {
1034 soundDevice->changedInVolume( -InputSlider->value()); 1040 soundDevice->changedInVolume( -InputSlider->value());
1035} 1041}
1036 1042
1037 1043
1038bool QtRec::setupAudio( bool b) { 1044bool QtRec::setupAudio( bool b) {
1039 bool ok; 1045 bool ok;
1040 int sampleformat, stereo, flags; 1046 int sampleformat, stereo, flags;
1041 QString dspString, mixerString; 1047 QString dspString, mixerString;
1042 1048
1043 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 1049 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
1044 1050
1045 if( !b) { 1051 if( !b) {
1046// we want to play 1052// we want to play
1047#ifdef PDAUDIO //ALSA 1053#ifdef PDAUDIO //ALSA
1048 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1054 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1049 sampleformat = SND_PCM_FORMAT_S16; 1055 sampleformat = SND_PCM_FORMAT_S16;
1050 filePara.resolution = 16; 1056 filePara.resolution = 16;
1051 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { 1057 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) {
1052 sampleformat = SND_PCM_FORMAT_S24; 1058 sampleformat = SND_PCM_FORMAT_S24;
1053 filePara.resolution = 24; 1059 filePara.resolution = 24;
1054 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { 1060 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) {
1055 sampleformat = SND_PCM_FORMAT_S32; 1061 sampleformat = SND_PCM_FORMAT_S32;
1056 filePara.resolution = 32; 1062 filePara.resolution = 32;
1057 } else { 1063 } else {
1058 sampleformat = SND_PCM_FORMAT_U8; 1064 sampleformat = SND_PCM_FORMAT_U8;
1059 filePara.resolution = 8; 1065 filePara.resolution = 8;
1060 } 1066 }
1061#else 1067#else
1062// we want to play 1068// we want to play
1063 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1069 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1064 sampleformat = AFMT_S16_LE; 1070 sampleformat = AFMT_S16_LE;
1065 filePara.resolution = 16; 1071 filePara.resolution = 16;
1066 } else { 1072 } else {
1067 sampleformat = AFMT_U8; 1073 sampleformat = AFMT_U8;
1068 filePara.resolution = 8; 1074 filePara.resolution = 8;
1069 } 1075 }
1070#endif 1076#endif
1071 1077
1072 stereo = filePara.channels; 1078 stereo = filePara.channels;
1073 flags = O_WRONLY; 1079 flags = O_WRONLY;
1074 Config hwcfg("OpieRec"); 1080 Config hwcfg("OpieRec");
1075 hwcfg.setGroup("Hardware"); 1081 hwcfg.setGroup("Hardware");
1076 dspString = hwcfg.readEntry( "Audio", DSPSTROUT); 1082 dspString = hwcfg.readEntry( "Audio", DSPSTROUT);
1077 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); 1083 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT);
1078 recording = false; 1084 recording = false;
1079 } else { // we want to record 1085 } else { // we want to record
1080 1086
1081#ifdef PDAUDIO //ALSA 1087#ifdef PDAUDIO //ALSA
1082 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1088 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1083 sampleformat = SND_PCM_FORMAT_S16; 1089 sampleformat = SND_PCM_FORMAT_S16;
1084 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") 1090 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
1085 sampleformat = SND_PCM_FORMAT_S24; 1091 sampleformat = SND_PCM_FORMAT_S24;
1086 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") 1092 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
1087 sampleformat = SND_PCM_FORMAT_S32; 1093 sampleformat = SND_PCM_FORMAT_S32;
1088 else 1094 else
1089 sampleformat = SND_PCM_FORMAT_U8; 1095 sampleformat = SND_PCM_FORMAT_U8;
1090 1096
1091#else 1097#else
1092 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1098 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1093 sampleformat = AFMT_S16_LE; 1099 sampleformat = AFMT_S16_LE;
1094 else 1100 else
1095 sampleformat = AFMT_U8; 1101 sampleformat = AFMT_U8;
1096 1102
1097 if( !compressionCheckBox->isChecked()) { 1103 if( !compressionCheckBox->isChecked()) {
1098 filePara.format = WAVE_FORMAT_PCM; 1104 filePara.format = WAVE_FORMAT_PCM;
1099// odebug << "WAVE_FORMAT_PCM" << oendl; 1105// odebug << "WAVE_FORMAT_PCM" << oendl;
1100 } else { 1106 } else {
1101 filePara.format = WAVE_FORMAT_DVI_ADPCM; 1107 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1102 sampleformat = AFMT_S16_LE; 1108 sampleformat = AFMT_S16_LE;
1103// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 1109// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
1104 } 1110 }
1105#endif 1111#endif
1106 1112
1107 stereo = filePara.channels; 1113 stereo = filePara.channels;
1108// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1114// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1109 flags= O_RDWR; 1115 flags= O_RDWR;
1110// flags= O_RDONLY; 1116// flags= O_RDONLY;
1111 Config hwcfg("OpieRec"); 1117 Config hwcfg("OpieRec");
1112 hwcfg.setGroup("Hardware"); 1118 hwcfg.setGroup("Hardware");
1113 dspString = hwcfg.readEntry( "Audio", DSPSTRIN); 1119 dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
1114 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); 1120 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
1115 recording = true; 1121 recording = true;
1116 } 1122 }
1117 1123
1118 // if(soundDevice) delete soundDevice; 1124 // if(soundDevice) delete soundDevice;
1119 odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; 1125 odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
1120 owarn << "change waveform settings" << oendl; 1126 owarn << "change waveform settings" << oendl;
1121 waveform->changeSettings( filePara.sampleRate, filePara.channels ); 1127 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1122 1128
1123 soundDevice = new Device( this, dspString, mixerString, b); 1129 soundDevice = new Device( this, dspString, mixerString, b);
1124// soundDevice->openDsp(); 1130// soundDevice->openDsp();
1125 soundDevice->reset(); 1131 soundDevice->reset();
1126 1132
1127 odebug << "device has been made " << soundDevice->sd << "" << oendl; 1133 odebug << "device has been made " << soundDevice->sd << "" << oendl;
1128 1134
1129 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> 1135 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1130 soundDevice->setDeviceFormat( sampleformat); 1136 soundDevice->setDeviceFormat( sampleformat);
1131 soundDevice->setDeviceChannels( filePara.channels); 1137 soundDevice->setDeviceChannels( filePara.channels);
1132 soundDevice->setDeviceRate( filePara.sampleRate); 1138 soundDevice->setDeviceRate( filePara.sampleRate);
1133 soundDevice->getDeviceFragSize(); 1139 soundDevice->getDeviceFragSize();
1134#ifdef QT_QWS_EBX 1140#ifdef QT_QWS_EBX
1135 int frag = FRAGSIZE; 1141 int frag = FRAGSIZE;
1136 soundDevice->setFragSize( frag); 1142 soundDevice->setFragSize( frag);
1137 soundDevice->getDeviceFragSize(); 1143 soundDevice->getDeviceFragSize();
1138#endif 1144#endif
1139 ///////////////// 1145 /////////////////
1140 filePara.sd = soundDevice->sd; 1146 filePara.sd = soundDevice->sd;
1141 1147
1142 if ( filePara.sd == -1) { 1148 if ( filePara.sd == -1) {
1143 1149
1144 monitoring = false; 1150 monitoring = false;
1145 stopped = true; 1151 stopped = true;
1146 update(); 1152 update();
1147 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); 1153 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
1148 return false; 1154 return false;
1149 } 1155 }
1150 if(autoMute) 1156 if(autoMute)
1151 doMute(false); 1157 doMute(false);
1152 1158
1153 return true; 1159 return true;
1154} 1160}
1155 1161
1156 1162
1157bool QtRec::setUpFile() { //setup file for recording 1163bool QtRec::setUpFile() { //setup file for recording
1158// odebug << "Setting up wavfile" << oendl; 1164// odebug << "Setting up wavfile" << oendl;
1159// if(wavFile) delete wavFile; 1165// if(wavFile) delete wavFile;
1160 wavFile = new WavFile( this, (const QString &)"", 1166 wavFile = new WavFile( this, (const QString &)"",
1161 true, 1167 true,
1162 filePara.sampleRate, 1168 filePara.sampleRate,
1163 filePara.channels, 1169 filePara.channels,
1164 filePara.resolution, 1170 filePara.resolution,
1165 filePara.format); 1171 filePara.format);
1166 1172
1167 filePara.fd = wavFile->wavHandle(); 1173 filePara.fd = wavFile->wavHandle();
1168 if(filePara.fd == -1) { 1174 if(filePara.fd == -1) {
1169 return false; 1175 return false;
1170 } else { 1176 } else {
1171// filePara.channels=1; 1177// filePara.channels=1;
1172 } 1178 }
1173 return true; 1179 return true;
1174} 1180}
1175 1181
1176/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1182/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1177bool QtRec::doPlay() { 1183bool QtRec::doPlay() {
1178 1184
1179 if( !paused) { 1185 if( !paused) {
1180 total = 0; 1186 total = 0;
1181 filePara.numberOfRecordedSeconds = 0; 1187 filePara.numberOfRecordedSeconds = 0;
1182 } else { 1188 } else {
1183 paused = false; 1189 paused = false;
1184 secCount = (int)filePara.numberOfRecordedSeconds; 1190 secCount = (int)filePara.numberOfRecordedSeconds;
1185 } 1191 }
1186 playing = true; 1192 playing = true;
1187 stopped = false; 1193 stopped = false;
1188 recording = false; 1194 recording = false;
1189 1195
1190 QString num; 1196 QString num;
1191 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; 1197 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
1192 1198
1193// timeSlider->setRange( 0, filePara.numberSamples); 1199// timeSlider->setRange( 0, filePara.numberSamples);
1194 1200
1195 timeString.sprintf("%f", filePara.numberOfRecordedSeconds); 1201 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1196 // timeLabel->setText( timeString+ tr(" seconds")); 1202 // timeLabel->setText( timeString+ tr(" seconds"));
1197 1203
1198 QString msg; 1204 QString msg;
1199 msg.sprintf("%d, %d, %d", 1205 msg.sprintf("%d, %d, %d",
1200 filePara.sampleRate, 1206 filePara.sampleRate,
1201 filePara.channels, 1207 filePara.channels,
1202 filePara.resolution); 1208 filePara.resolution);
1203#ifdef DEV_VERSION 1209#ifdef DEV_VERSION
1204 setCaption( msg); 1210 setCaption( msg);
1205#endif 1211#endif
1206 1212
1207 startTimer( 1000); 1213 startTimer( 1000);
1208#ifdef THREADED 1214#ifdef THREADED
1209 pthread_t thread2; 1215 pthread_t thread2;
1210 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1216 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1211#endif 1217#endif
1212 1218
1213 toBeginningButton->setEnabled( false); 1219 toBeginningButton->setEnabled( false);
1214 toEndButton->setEnabled( false); 1220 toEndButton->setEnabled( false);
1215#ifndef THREADED 1221#ifndef THREADED
1216 playIt(); 1222 playIt();
1217#endif 1223#endif
1218 return true; 1224 return true;
1219} 1225}
1220 1226
1221 1227
1222void QtRec::changebitrateCombo(int i) { 1228void QtRec::changebitrateCombo(int i) {
1223 Config cfg("OpieRec"); 1229 Config cfg("OpieRec");
1224 cfg.setGroup("Settings"); 1230 cfg.setGroup("Settings");
1225 int bits = 0; 1231 int bits = 0;
1226 if( i == 1) { bits = 16; } 1232 if( i == 1) { bits = 16; }
1227 else if( i == 2) { bits = 24; } 1233 else if( i == 2) { bits = 24; }
1228 else if( i == 3) { bits = 32; } 1234 else if( i == 3) { bits = 32; }
1229 else { bits=8; } 1235 else { bits=8; }
1230 cfg.writeEntry("bitrate", bits); 1236 cfg.writeEntry("bitrate", bits);
1231 filePara.resolution = bits; 1237 filePara.resolution = bits;
1232 cfg.write(); 1238 cfg.write();
1233} 1239}
1234 1240
1235void QtRec::changesamplerateCombo(int i) { 1241void QtRec::changesamplerateCombo(int i) {
1236 Config cfg("OpieRec"); 1242 Config cfg("OpieRec");
1237 cfg.setGroup("Settings"); 1243 cfg.setGroup("Settings");
1238 int rate=0; 1244 int rate=0;
1239 bool ok; 1245 bool ok;
1240 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1246 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1241 cfg.writeEntry( "samplerate",rate); 1247 cfg.writeEntry( "samplerate",rate);
1242 filePara.sampleRate=rate; 1248 filePara.sampleRate=rate;
1243 odebug << "Change sample rate " << rate << "" << oendl; 1249 odebug << "Change sample rate " << rate << "" << oendl;
1244 cfg.write(); 1250 cfg.write();
1245} 1251}
1246 1252
1247 1253
1248void QtRec::changeDirCombo(int index) { 1254void QtRec::changeDirCombo(int index) {
1249 Config cfg("OpieRec"); 1255 Config cfg("OpieRec");
1250 cfg.setGroup("Settings"); 1256 cfg.setGroup("Settings");
1251 QString sName = directoryComboBox->text(index); 1257 QString sName = directoryComboBox->text(index);
1252 1258
1253 StorageInfo storageInfo; 1259 StorageInfo storageInfo;
1254 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1260 const QList<FileSystem> &fs = storageInfo.fileSystems();
1255 QListIterator<FileSystem> it ( fs ); 1261 QListIterator<FileSystem> it ( fs );
1256 QString storage; 1262 QString storage;
1257 for( ; it.current(); ++it ){ 1263 for( ; it.current(); ++it ){
1258 if( sName == (*it)->name()+" "+ (*it)->path() || 1264 if( sName == (*it)->name()+" "+ (*it)->path() ||
1259 (*it)->name() == sName ) { 1265 (*it)->name() == sName ) {
1260 const QString path = (*it)->path(); 1266 const QString path = (*it)->path();
1261 recDir = path; 1267 recDir = path;
1262 cfg.writeEntry("directory", recDir); 1268 cfg.writeEntry("directory", recDir);
1263 odebug << "new rec dir "+recDir << oendl; 1269 odebug << "new rec dir "+recDir << oendl;
1264 } 1270 }
1265 } 1271 }
1266 cfg.write(); 1272 cfg.write();
1267} 1273}
1268 1274
1269 1275
1270void QtRec::changeSizeLimitCombo(int) { 1276void QtRec::changeSizeLimitCombo(int) {
1271 Config cfg("OpieRec"); 1277 Config cfg("OpieRec");
1272 cfg.setGroup("Settings"); 1278 cfg.setGroup("Settings");
1273 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1279 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1274 cfg.write(); 1280 cfg.write();
1275} 1281}
1276 1282
1277void QtRec::newSound() { 1283void QtRec::newSound() {
1278 if( !rec()) { 1284 if( !rec()) {
1279 endRecording(); 1285 endRecording();
1280 deleteSound(); 1286 deleteSound();
1281 } 1287 }
1282} 1288}
1283 1289
1284void QtRec::itClick(QListViewItem *item) { 1290void QtRec::itClick(QListViewItem *item) {
1285 currentFile = item->text(0); 1291 currentFile = item->text(0);
1286 setCaption("OpieRecord "+currentFile); 1292 setCaption("OpieRecord "+currentFile);
1287} 1293}
1288 1294
1289void QtRec::deleteSound() { 1295void QtRec::deleteSound() {
1290 Config cfg("OpieRec"); 1296 Config cfg("OpieRec");
1291 cfg.setGroup("Sounds"); 1297 cfg.setGroup("Sounds");
1292 if( ListView1->currentItem() == NULL) 1298 if( ListView1->currentItem() == NULL)
1293 return; 1299 return;
1294#ifndef DEV_VERSION 1300#ifndef DEV_VERSION
1295 switch ( QMessageBox::warning(this,tr("Delete"), 1301 switch ( QMessageBox::warning(this,tr("Delete"),
1296 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), 1302 tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"),
1297 tr("Yes"),tr("No"),0,1,1) ) { 1303 tr("Yes"),tr("No"),0,1,1) ) {
1298 case 0: 1304 case 0:
1299#endif 1305#endif
1300 { 1306 {
1301 QString file = ListView1->currentItem()->text(0); 1307 QString file = ListView1->currentItem()->text(0);
1302 QString fileName; 1308 QString fileName;
1303 fileName = cfg.readEntry( file, ""); 1309 fileName = cfg.readEntry( file, "");
1304 QFile f( fileName); 1310 QFile f( fileName);
1305 if( f.exists()) 1311 if( f.exists())
1306 if( !f.remove()) 1312 if( !f.remove())
1307 QMessageBox::message( tr("Error"), tr("Could not remove file.")); 1313 QMessageBox::message( tr("Error"), tr("Could not remove file."));
1308 1314
1309 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1315 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1310 bool found = false; 1316 bool found = false;
1311 for(int i=0;i<nFiles+1;i++) { 1317 for(int i=0;i<nFiles+1;i++) {
1312 1318
1313 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1319 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1314 found = true; 1320 found = true;
1315 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1321 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1316 } 1322 }
1317 if(found) 1323 if(found)
1318 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1324 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1319 } 1325 }
1320 1326
1321 cfg.removeEntry( cfg.readEntry( file)); 1327 cfg.removeEntry( cfg.readEntry( file));
1322 cfg.removeEntry( file); 1328 cfg.removeEntry( file);
1323 cfg.writeEntry( "NumberofFiles", nFiles-1); 1329 cfg.writeEntry( "NumberofFiles", nFiles-1);
1324 cfg.write(); 1330 cfg.write();
1325 1331
1326 ListView1->takeItem( ListView1->currentItem() ); 1332 ListView1->takeItem( ListView1->currentItem() );
1327 delete ListView1->currentItem(); 1333 delete ListView1->currentItem();
1328 1334
1329 ListView1->clear(); 1335 ListView1->clear();
1330 ListView1->setSelected( ListView1->firstChild(), true); 1336 ListView1->setSelected( ListView1->firstChild(), true);
1331 initIconView(); 1337 initIconView();
1332 update(); 1338 update();
1333 } 1339 }
1334#ifndef DEV_VERSION 1340#ifndef DEV_VERSION
1335 }; 1341 };
1336#endif 1342#endif
1337 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1343 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1338 1344
1339} 1345}
1340 1346
1341void QtRec::keyPressEvent( QKeyEvent *e) { 1347void QtRec::keyPressEvent( QKeyEvent *e) {
1342 1348
1343 switch ( e->key() ) { 1349 switch ( e->key() ) {
1344 // case Key_F1: 1350 // case Key_F1:
1345 // if(stopped && !recording) 1351 // if(stopped && !recording)
1346 // newSound(); 1352 // newSound();
1347 // else 1353 // else
1348 // stop(); 1354 // stop();
1349 // break; 1355 // break;
1350 // case Key_F2: { 1356 // case Key_F2: {
1351 // if( !e->isAutoRepeat()) 1357 // if( !e->isAutoRepeat())
1352 // rewindPressed(); 1358 // rewindPressed();
1353 // } 1359 // }
1354 // break; 1360 // break;
1355 // case Key_F3: { 1361 // case Key_F3: {
1356 // if( !e->isAutoRepeat()) 1362 // if( !e->isAutoRepeat())
1357 // FastforwardPressed(); 1363 // FastforwardPressed();
1358 // } 1364 // }
1359 // break; 1365 // break;
1360 1366
1361 ////////////////////////////// Zaurus keys 1367 ////////////////////////////// Zaurus keys
1362 case Key_F9: //activity 1368 case Key_F9: //activity
1363 break; 1369 break;
1364 case Key_F10: //contacts 1370 case Key_F10: //contacts
1365 break; 1371 break;
1366 case Key_F11: //menu 1372 case Key_F11: //menu
1367 break; 1373 break;
1368 case Key_F12: //home 1374 case Key_F12: //home
1369 break; 1375 break;
1370 case Key_F13: //mail 1376 case Key_F13: //mail
1371 break; 1377 break;
1372 case Key_Space: 1378 case Key_Space:
1373 break; 1379 break;
1374 case Key_Delete: 1380 case Key_Delete:
1375 break; 1381 break;
1376 case Key_Up: 1382 case Key_Up:
1377 // stop(); 1383 // stop();
1378 break; 1384 break;
1379 case Key_Down: 1385 case Key_Down:
1380 // newSound(); 1386 // newSound();
1381 break; 1387 break;
1382 case Key_Left: { 1388 case Key_Left: {
1383 odebug << "rewinding" << oendl; 1389 odebug << "rewinding" << oendl;
1384 if( !e->isAutoRepeat()) 1390 if( !e->isAutoRepeat())
1385 rewindPressed(); 1391 rewindPressed();
1386 } 1392 }
1387 break; 1393 break;
1388 case Key_Right: { 1394 case Key_Right: {
1389 if( !e->isAutoRepeat()) 1395 if( !e->isAutoRepeat())
1390 FastforwardPressed(); 1396 FastforwardPressed();
1391 } 1397 }
1392 break; 1398 break;
1393 } 1399 }
1394} 1400}
1395 1401
1396void QtRec::keyReleaseEvent( QKeyEvent *e) { 1402void QtRec::keyReleaseEvent( QKeyEvent *e) {
1397 switch ( e->key() ) { 1403 switch ( e->key() ) {
1398 // case Key_F1: 1404 // case Key_F1:
1399 // if(stopped && !recording) 1405 // if(stopped && !recording)
1400 // newSound(); 1406 // newSound();
1401 // else 1407 // else
1402 // stop(); 1408 // stop();
1403 // break; 1409 // break;
1404 // case Key_F2: 1410 // case Key_F2:
1405 // rewindReleased(); 1411 // rewindReleased();
1406 // break; 1412 // break;
1407 // case Key_F3: 1413 // case Key_F3:
1408 // FastforwardReleased(); 1414 // FastforwardReleased();
1409 // break; 1415 // break;
1410 1416
1411 ////////////////////////////// Zaurus keys 1417 ////////////////////////////// Zaurus keys
1412 case Key_F9: //activity 1418 case Key_F9: //activity
1413 break; 1419 break;
1414 case Key_F10: //contacts 1420 case Key_F10: //contacts
1415 break; 1421 break;
1416 case Key_F11: //menu 1422 case Key_F11: //menu
1417 break; 1423 break;
1418 case Key_F12: //home 1424 case Key_F12: //home
1419 if(stopped) 1425 if(stopped)
1420 doPlayBtn(); 1426 doPlayBtn();
1421 else 1427 else
1422 stop(); 1428 stop();
1423 break; 1429 break;
1424 case Key_F13: //mail 1430 case Key_F13: //mail
1425 break; 1431 break;
1426 case Key_Space: 1432 case Key_Space:
1427 if(stopped && !recording) 1433 if(stopped && !recording)
1428 newSound(); 1434 newSound();
1429 else 1435 else
1430 stop(); 1436 stop();
1431 break; 1437 break;
1432 case Key_Delete: 1438 case Key_Delete:
1433 deleteSound(); 1439 deleteSound();
1434 break; 1440 break;
1435 case Key_Up: 1441 case Key_Up:
1436 // stop(); 1442 // stop();
1437 odebug << "Up" << oendl; 1443 odebug << "Up" << oendl;
1438 break; 1444 break;
1439 case Key_Down: 1445 case Key_Down:
1440 // start(); 1446 // start();
1441 // odebug << "Down" << oendl; 1447 // odebug << "Down" << oendl;
1442 // newSound(); 1448 // newSound();
1443 break; 1449 break;
1444 case Key_Left: 1450 case Key_Left:
1445 odebug << "Left" << oendl; 1451 odebug << "Left" << oendl;
1446 rewindReleased(); 1452 rewindReleased();
1447 break; 1453 break;
1448 case Key_Right: 1454 case Key_Right:
1449 odebug << "Right" << oendl; 1455 odebug << "Right" << oendl;
1450 FastforwardReleased(); 1456 FastforwardReleased();
1451 break; 1457 break;
1452 } 1458 }
1453} 1459}
1454 1460
1455void QtRec::endRecording() { 1461void QtRec::endRecording() {
1456 monitoring = false; 1462 monitoring = false;
1457 recording = false; 1463 recording = false;
1458 stopped = true; 1464 stopped = true;
1459 waveform->reset(); 1465 waveform->reset();
1460 setRecordButton( false); 1466 setRecordButton( false);
1461 1467
1462 toBeginningButton->setEnabled( true); 1468 toBeginningButton->setEnabled( true);
1463 toEndButton->setEnabled( true); 1469 toEndButton->setEnabled( true);
1464 1470
1465 killTimers(); 1471 killTimers();
1466 1472
1467 if(autoMute) 1473 if(autoMute)
1468 doMute( true); 1474 doMute( true);
1469 1475
1470 soundDevice->closeDevice( true); 1476 soundDevice->closeDevice( true);
1471 1477
1472 if( wavFile->track.isOpen()) { 1478 if( wavFile->track.isOpen()) {
1473 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1479 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1474 // soundDevice->sd=-1; 1480 // soundDevice->sd=-1;
1475 filePara.numberSamples = 0; 1481 filePara.numberSamples = 0;
1476 // filePara.sd=-1; 1482 // filePara.sd=-1;
1477 wavFile->closeFile(); 1483 wavFile->closeFile();
1478 filePara.fd=0; 1484 filePara.fd=0;
1479 1485
1480 if( wavFile->isTempFile()) { 1486 if( wavFile->isTempFile()) {
1481// move tmp file to regular file 1487// move tmp file to regular file
1482 QString cmd; 1488 QString cmd;
1483 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1489 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1484 odebug << "moving tmp file to "+currentFileName << oendl; 1490 odebug << "moving tmp file to "+currentFileName << oendl;
1485 system( cmd.latin1()); 1491 system( cmd.latin1());
1486 } 1492 }
1487 1493
1488 odebug << "Just moved " + wavFile->currentFileName << oendl; 1494 odebug << "Just moved " + wavFile->currentFileName << oendl;
1489 Config cfg("OpieRec"); 1495 Config cfg("OpieRec");
1490 cfg.setGroup("Sounds"); 1496 cfg.setGroup("Sounds");
1491 1497
1492 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1498 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1493 1499
1494 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1500 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1495 currentFile = currentFile.left( currentFile.length() - 4); 1501 currentFile = currentFile.left( currentFile.length() - 4);
1496 1502
1497 cfg.writeEntry( "NumberofFiles", nFiles + 1); 1503 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1498 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1504 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1499 cfg.writeEntry( currentFile, wavFile->currentFileName); 1505 cfg.writeEntry( currentFile, wavFile->currentFileName);
1500 1506
1501 QString time; 1507 QString time;
1502 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1508 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1503 cfg.writeEntry( wavFile->currentFileName, time ); 1509 cfg.writeEntry( wavFile->currentFileName, time );
1504 odebug << "writing config numberOfRecordedSeconds "+time << oendl; 1510 odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1505 1511
1506 cfg.write(); 1512 cfg.write();
1507 odebug << "finished recording" << oendl; 1513 odebug << "finished recording" << oendl;
1508 // timeLabel->setText(""); 1514 // timeLabel->setText("");
1509 } 1515 }
1510 1516
1511// if(soundDevice) delete soundDevice; 1517// if(soundDevice) delete soundDevice;
1512 1518
1513 timeSlider->setValue(0); 1519 timeSlider->setValue(0);
1514 initIconView(); 1520 initIconView();
1515 selectItemByName( currentFile); 1521 selectItemByName( currentFile);
1516} 1522}
1517 1523
1518void QtRec::endPlaying() { 1524void QtRec::endPlaying() {
1519 monitoring = false; 1525 monitoring = false;
1520 recording = false; 1526 recording = false;
1521 playing = false; 1527 playing = false;
1522 stopped = true; 1528 stopped = true;
1523 waveform->reset(); 1529 waveform->reset();
1524// errorStop(); 1530// errorStop();
1525 odebug << "end playing" << oendl; 1531 odebug << "end playing" << oendl;
1526 setRecordButton( false); 1532 setRecordButton( false);
1527 1533
1528 toBeginningButton->setEnabled( true); 1534 toBeginningButton->setEnabled( true);
1529 toEndButton->setEnabled( true); 1535 toEndButton->setEnabled( true);
1530 1536
1531 if(autoMute) 1537 if(autoMute)
1532 doMute( true); 1538 doMute( true);
1533 1539
1534 soundDevice->closeDevice( false); 1540 soundDevice->closeDevice( false);
1535 soundDevice->sd = -1; 1541 soundDevice->sd = -1;
1536 // if(soundDevice) delete soundDevice; 1542 // if(soundDevice) delete soundDevice;
1537 odebug << "file and sound device closed" << oendl; 1543 odebug << "file and sound device closed" << oendl;
1538 // timeLabel->setText(""); 1544 // timeLabel->setText("");
1539 total = 0; 1545 total = 0;
1540 filePara.numberSamples = 0; 1546 filePara.numberSamples = 0;
1541 filePara.sd = -1; 1547 filePara.sd = -1;
1542// wavFile->closeFile(); 1548// wavFile->closeFile();
1543 filePara.fd = 0; 1549 filePara.fd = 0;
1544// if(wavFile) delete wavFile; //this crashes 1550// if(wavFile) delete wavFile; //this crashes
1545 1551
1546 odebug << "track closed" << oendl; 1552 odebug << "track closed" << oendl;
1547 killTimers(); 1553 killTimers();
1548 owarn << "reset slider" << oendl; 1554 owarn << "reset slider" << oendl;
1549 timeSlider->setValue(0); 1555 timeSlider->setValue(0);
1550 1556
1551// if(soundDevice) delete soundDevice; 1557// if(soundDevice) delete soundDevice;
1552 1558
1553} 1559}
1554 1560
1555bool QtRec::openPlayFile() { 1561bool QtRec::openPlayFile() {
1556 1562
1557 qApp->processEvents(); 1563 qApp->processEvents();
1558 if( currentFile.isEmpty()) { 1564 if( currentFile.isEmpty()) {
1559 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1565 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1560 endPlaying(); 1566 endPlaying();
1561 return false; 1567 return false;
1562 } 1568 }
1563 QString currentFileName; 1569 QString currentFileName;
1564 Config cfg("OpieRec"); 1570 Config cfg("OpieRec");
1565 cfg.setGroup("Sounds"); 1571 cfg.setGroup("Sounds");
1566 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1572 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1567 for(int i=0;i<nFiles+1;i++) { //look for file 1573 for(int i=0;i<nFiles+1;i++) { //look for file
1568 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1574 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1569 currentFileName = cfg.readEntry( currentFile, "" ); 1575 currentFileName = cfg.readEntry( currentFile, "" );
1570 odebug << "opening for play: " + currentFileName << oendl; 1576 odebug << "opening for play: " + currentFileName << oendl;
1571 } 1577 }
1572 } 1578 }
1573 wavFile = new WavFile(this, 1579 wavFile = new WavFile(this,
1574 currentFileName, 1580 currentFileName,
1575 false); 1581 false);
1576 filePara.fd = wavFile->wavHandle(); 1582 filePara.fd = wavFile->wavHandle();
1577 if(filePara.fd == -1) { 1583 if(filePara.fd == -1) {
1578 // if(!track.open(IO_ReadOnly)) { 1584 // if(!track.open(IO_ReadOnly)) {
1579 QString errorMsg = (QString)strerror(errno); 1585 QString errorMsg = (QString)strerror(errno);
1580 monitoring = false; 1586 monitoring = false;
1581 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1587 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1582 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") 1588 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
1583 + errorMsg + "\n" + currentFile); 1589 + errorMsg + "\n" + currentFile);
1584 return false; 1590 return false;
1585 } else { 1591 } else {
1586 1592
1587 filePara.numberSamples = wavFile->getNumberSamples(); 1593 filePara.numberSamples = wavFile->getNumberSamples();
1588 filePara.format = wavFile->getFormat(); 1594 filePara.format = wavFile->getFormat();
1589 filePara.sampleRate = wavFile->getSampleRate(); 1595 filePara.sampleRate = wavFile->getSampleRate();
1590 filePara.resolution = wavFile->getResolution(); 1596 filePara.resolution = wavFile->getResolution();
1591 filePara.channels = wavFile->getChannels(); 1597 filePara.channels = wavFile->getChannels();
1592 timeSlider->setPageStep(1); 1598 timeSlider->setPageStep(1);
1593 monitoring = true; 1599 monitoring = true;
1594 1600
1595 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; 1601 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
1596 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); 1602 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
1597 1603
1598 owarn << "seconds " << sec << "" << oendl; 1604 owarn << "seconds " << sec << "" << oendl;
1599 1605
1600 timeSlider->setRange(0, filePara.numberSamples ); 1606 timeSlider->setRange(0, filePara.numberSamples );
1601 } 1607 }
1602 1608
1603 return true; 1609 return true;
1604} 1610}
1605 1611
1606void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1612void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1607 if(item == NULL ) 1613 if(item == NULL )
1608 return; 1614 return;
1609 switch (mouse) { 1615 switch (mouse) {
1610 case 1: { 1616 case 1: {
1611 if( renameBox != 0 ) //tricky 1617 if( renameBox != 0 ) //tricky
1612 cancelRename(); 1618 cancelRename();
1613 1619
1614 currentFile = item->text(0); 1620 currentFile = item->text(0);
1615 setCaption( "OpieRecord " + currentFile); 1621 setCaption( "OpieRecord " + currentFile);
1616 } 1622 }
1617 break; 1623 break;
1618 case 2: 1624 case 2:
1619 showListMenu(item); 1625 showListMenu(item);
1620 ListView1->clearSelection(); 1626 ListView1->clearSelection();
1621 break; 1627 break;
1622 }; 1628 };
1623} 1629}
1624 1630
1625void QtRec::showListMenu(QListViewItem * item) { 1631void QtRec::showListMenu(QListViewItem * item) {
1626 if(item == NULL) 1632 if(item == NULL)
1627 return; 1633 return;
1628 QPopupMenu *m = new QPopupMenu(this); 1634 QPopupMenu *m = new QPopupMenu(this);
1629 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); 1635 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() ));
1630 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); 1636 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() ));
1631 m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); 1637 m->insertItem( tr( "Rename" ), this, SLOT( doRename() ));
1632 // #if defined (QTOPIA_INTERNAL_FSLP) 1638 // #if defined (QTOPIA_INTERNAL_FSLP)
1633 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1639 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1634 // #endif 1640 // #endif
1635 m->insertSeparator(); 1641 m->insertSeparator();
1636 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); 1642 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) );
1637 m->exec( QCursor::pos() ); 1643 m->exec( QCursor::pos() );
1638 qApp->processEvents(); 1644 qApp->processEvents();
1639} 1645}
1640 1646
1641void QtRec::fileBeamFinished( Ir *ir) { 1647void QtRec::fileBeamFinished( Ir *ir) {
1642 if(ir) 1648 if(ir)
1643 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); 1649 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") );
1644 1650
1645} 1651}
1646 1652
1647void QtRec::doBeam() { 1653void QtRec::doBeam() {
1648 qApp->processEvents(); 1654 qApp->processEvents();
1649 if( ListView1->currentItem() == NULL) 1655 if( ListView1->currentItem() == NULL)
1650 return; 1656 return;
1651 Ir ir; 1657 Ir ir;
1652 if( ir.supported()) { 1658 if( ir.supported()) {
1653 QString file = ListView1->currentItem()->text(0); 1659 QString file = ListView1->currentItem()->text(0);
1654 Config cfg("OpieRec"); 1660 Config cfg("OpieRec");
1655 cfg.setGroup("Sounds"); 1661 cfg.setGroup("Sounds");
1656 1662
1657 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1663 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1658 1664
1659 for(int i=0;i<nFiles+1;i++) { 1665 for(int i=0;i<nFiles+1;i++) {
1660 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { 1666 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) {
1661 QString filePath = cfg.readEntry(file,""); 1667 QString filePath = cfg.readEntry(file,"");
1662 Ir *file = new Ir(this, "IR"); 1668 Ir *file = new Ir(this, "IR");
1663 connect( file, SIGNAL( done(Ir*)), 1669 connect( file, SIGNAL( done(Ir*)),
1664 this, SLOT( fileBeamFinished(Ir*))); 1670 this, SLOT( fileBeamFinished(Ir*)));
1665 file->send( filePath, "OPieRec audio file\n" + filePath ); 1671 file->send( filePath, "OPieRec audio file\n" + filePath );
1666 } 1672 }
1667 } 1673 }
1668 } 1674 }
1669} 1675}
1670 1676
1671void QtRec::doMenuPlay() { 1677void QtRec::doMenuPlay() {
1672 qApp->processEvents(); 1678 qApp->processEvents();
1673 currentFile = ListView1->currentItem()->text(0); 1679 currentFile = ListView1->currentItem()->text(0);
1674} 1680}
1675 1681
1676void QtRec::doRename() { 1682void QtRec::doRename() {
1677 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1683 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1678 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1684 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1679 r.setX( ListView1->contentsX() ); 1685 r.setX( ListView1->contentsX() );
1680 if ( r.width() > ListView1->visibleWidth() ) 1686 if ( r.width() > ListView1->visibleWidth() )
1681 r.setWidth( ListView1->visibleWidth() ); 1687 r.setWidth( ListView1->visibleWidth() );
1682 1688
1683 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1689 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1684 renameBox->setFrame(true); 1690 renameBox->setFrame(true);
1685 1691
1686 renameBox->setText( ListView1->currentItem()->text(0) ); 1692 renameBox->setText( ListView1->currentItem()->text(0) );
1687 1693
1688 renameBox->selectAll(); 1694 renameBox->selectAll();
1689 renameBox->installEventFilter( this ); 1695 renameBox->installEventFilter( this );
1690 ListView1->addChild( renameBox, r.x(), r.y() ); 1696 ListView1->addChild( renameBox, r.x(), r.y() );
1691 renameBox->resize( r.size() ); 1697 renameBox->resize( r.size() );
1692 ListView1->viewport()->setFocusProxy( renameBox ); 1698 ListView1->viewport()->setFocusProxy( renameBox );
1693 renameBox->setFocus(); 1699 renameBox->setFocus();
1694 renameBox->show(); 1700 renameBox->show();
1695 1701
1696} 1702}
1697 1703
1698void QtRec::okRename() { 1704void QtRec::okRename() {
1699 odebug << renameBox->text() << oendl; 1705 odebug << renameBox->text() << oendl;
1700 QString filename = renameBox->text(); 1706 QString filename = renameBox->text();
1701 cancelRename(); 1707 cancelRename();
1702 1708
1703 if( ListView1->currentItem() == NULL) 1709 if( ListView1->currentItem() == NULL)
1704 return; 1710 return;
1705 1711
1706 Config cfg("OpieRec"); 1712 Config cfg("OpieRec");
1707 cfg.setGroup("Sounds"); 1713 cfg.setGroup("Sounds");
1708 1714
1709 QString file = ListView1->currentItem()->text(0); 1715 QString file = ListView1->currentItem()->text(0);
1710 1716
1711 odebug << "filename is " + filename << oendl; 1717 odebug << "filename is " + filename << oendl;
1712 1718
1713 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1719 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1714 1720
1715 for(int i=0;i<nFiles+1;i++) { //look for file 1721 for(int i=0;i<nFiles+1;i++) { //look for file
1716 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1722 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1717 1723
1718 QString filePath = cfg.readEntry(file,""); 1724 QString filePath = cfg.readEntry(file,"");
1719 1725
1720 cfg.writeEntry( QString::number(i), filename ); 1726 cfg.writeEntry( QString::number(i), filename );
1721 cfg.writeEntry( filename, filePath ); 1727 cfg.writeEntry( filename, filePath );
1722 cfg.removeEntry( file); 1728 cfg.removeEntry( file);
1723 cfg.write(); 1729 cfg.write();
1724 } 1730 }
1725 } 1731 }
1726 1732
1727 ListView1->takeItem( ListView1->currentItem() ); 1733 ListView1->takeItem( ListView1->currentItem() );
1728 delete ListView1->currentItem(); 1734 delete ListView1->currentItem();
1729 ListView1->clear(); 1735 ListView1->clear();
1730 initIconView(); 1736 initIconView();
1731 update(); 1737 update();
1732} 1738}
1733 1739
1734void QtRec::cancelRename() { 1740void QtRec::cancelRename() {
1735 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1741 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1736 delete renameBox; 1742 delete renameBox;
1737 renameBox = 0; 1743 renameBox = 0;
1738 if ( resetFocus ) { 1744 if ( resetFocus ) {
1739 ListView1->viewport()->setFocusProxy( ListView1 ); 1745 ListView1->viewport()->setFocusProxy( ListView1 );
1740 ListView1->setFocus(); 1746 ListView1->setFocus();
1741 } 1747 }
1742} 1748}
1743 1749
1744bool QtRec::eventFilter( QObject * o, QEvent * e ) { 1750bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1745 if ( o->inherits( "QLineEdit" ) ) { 1751 if ( o->inherits( "QLineEdit" ) ) {
1746 if ( e->type() == QEvent::KeyPress ) { 1752 if ( e->type() == QEvent::KeyPress ) {
1747 QKeyEvent *ke = (QKeyEvent*)e; 1753 QKeyEvent *ke = (QKeyEvent*)e;
1748 if ( ke->key() == Key_Return || 1754 if ( ke->key() == Key_Return ||
1749 ke->key() == Key_Enter ) { 1755 ke->key() == Key_Enter ) {
1750 okRename(); 1756 okRename();
1751 return true; 1757 return true;
1752 } else if ( ke->key() == Key_Escape ) { 1758 } else if ( ke->key() == Key_Escape ) {
1753 cancelRename(); 1759 cancelRename();
1754 return true; 1760 return true;
1755 } 1761 }
1756 } else if ( e->type() == QEvent::FocusOut ) { 1762 } else if ( e->type() == QEvent::FocusOut ) {
1757 cancelRename(); 1763 cancelRename();
1758 return true; 1764 return true;
1759 } 1765 }
1760 } 1766 }
1761 return QWidget::eventFilter( o, e ); 1767 return QWidget::eventFilter( o, e );
1762} 1768}
1763 1769
1764 1770
1765int QtRec::getCurrentSizeLimit() { 1771int QtRec::getCurrentSizeLimit() {
1766 return sizeLimitCombo->currentItem() * 5; 1772 return sizeLimitCombo->currentItem() * 5;
1767} 1773}
1768 1774
1769void QtRec::timerBreak() { 1775void QtRec::timerBreak() {
1770 endPlaying(); 1776 endPlaying();
1771} 1777}
1772 1778
1773void QtRec::doVolMuting(bool b) { 1779void QtRec::doVolMuting(bool b) {
1774 Config cfg( "qpe" ); 1780 Config cfg( "qpe" );
1775 cfg. setGroup( "Volume" ); 1781 cfg. setGroup( "Volume" );
1776 cfg.writeEntry( "Mute",b); 1782 cfg.writeEntry( "Mute",b);
1777 cfg.write(); 1783 cfg.write();
1778 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1784 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1779} 1785}
1780 1786
1781void QtRec::doMicMuting(bool b) { 1787void QtRec::doMicMuting(bool b) {
1782 // odebug << "mic mute" << oendl; 1788 // odebug << "mic mute" << oendl;
1783 Config cfg( "qpe" ); 1789 Config cfg( "qpe" );
1784 cfg. setGroup( "Volume" ); 1790 cfg. setGroup( "Volume" );
1785 cfg.writeEntry( "MicMute",b); 1791 cfg.writeEntry( "MicMute",b);
1786 cfg.write(); 1792 cfg.write();
1787 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1793 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1788} 1794}
1789 1795
1790void QtRec::compressionSelected(bool b) { 1796void QtRec::compressionSelected(bool b) {
1791 Config cfg("OpieRec"); 1797 Config cfg("OpieRec");
1792 cfg.setGroup("Settings"); 1798 cfg.setGroup("Settings");
1793 cfg.writeEntry("wavCompression", b); 1799 cfg.writeEntry("wavCompression", b);
1794 cfg.writeEntry("bitrate", 16); 1800 cfg.writeEntry("bitrate", 16);
1795 filePara.resolution = 16; 1801 filePara.resolution = 16;
1796 cfg.write(); 1802 cfg.write();
1797 1803
1798 if(b) { 1804 if(b) {
1799 bitRateComboBox->setEnabled( false); 1805 bitRateComboBox->setEnabled( false);
1800 bitRateComboBox->setCurrentItem( 1); 1806 bitRateComboBox->setCurrentItem( 1);
1801 filePara.resolution = 16; 1807 filePara.resolution = 16;
1802 } else{ 1808 } else{
1803 bitRateComboBox->setEnabled( true); 1809 bitRateComboBox->setEnabled( true);
1804 } 1810 }
1805} 1811}
1806 1812
1807long QtRec::checkDiskSpace(const QString &path) { 1813long QtRec::checkDiskSpace(const QString &path) {
1808 1814
1809 struct statfs fs; 1815 struct statfs fs;
1810 1816
1811 if ( !statfs( path.latin1(), &fs ) ) { 1817 if ( !statfs( path.latin1(), &fs ) ) {
1812 1818
1813 int blkSize = fs.f_bsize; 1819 int blkSize = fs.f_bsize;
1814 int availBlks = fs.f_bavail; 1820 int availBlks = fs.f_bavail;
1815 1821
1816 long mult = blkSize / 1024; 1822 long mult = blkSize / 1024;
1817 long div = 1024 / blkSize; 1823 long div = 1024 / blkSize;
1818 1824
1819 if ( !mult ) mult = 1; 1825 if ( !mult ) mult = 1;
1820 if ( !div ) div = 1; 1826 if ( !div ) div = 1;
1821 1827
1822 return availBlks * mult / div; 1828 return availBlks * mult / div;
1823 } 1829 }
1824 return -1; 1830 return -1;
1825} 1831}
1826 1832
1827// short f_fstyp; /* File system type */ 1833// short f_fstyp; /* File system type */
1828// long f_bsize; /* Block size */ 1834// long f_bsize; /* Block size */
1829// long f_frsize; /* Fragment size */ 1835// long f_frsize; /* Fragment size */
1830// long f_blocks; /* Total number of blocks*/ 1836// long f_blocks; /* Total number of blocks*/
1831// long f_bfree; /* Count of free blocks */ 1837// long f_bfree; /* Count of free blocks */
1832// long f_files; /* Total number of file nodes */ 1838// long f_files; /* Total number of file nodes */
1833// long f_ffree; /* Count of free file nodes */ 1839// long f_ffree; /* Count of free file nodes */
1834// char f_fname[6]; /* Volumename */ 1840// char f_fname[6]; /* Volumename */
1835// char f_fpack[6]; /* Pack name */ 1841// char f_fpack[6]; /* Pack name */
1836 1842
1837void QtRec::receive( const QCString &msg, const QByteArray & ) { 1843void QtRec::receive( const QCString &msg, const QByteArray & ) {
1838 odebug << "Voicerecord received message "+msg << oendl; 1844 odebug << "Voicerecord received message "+msg << oendl;
1839 1845
1840} 1846}
1841 1847
1842 1848
1843///////////////////////////// timerEvent 1849///////////////////////////// timerEvent
1844void QtRec::timerEvent( QTimerEvent * ) { 1850void QtRec::timerEvent( QTimerEvent * ) {
1845 1851
1846// if(!recording) 1852// if(!recording)
1847// timeSlider->setValue( secCount); 1853// timeSlider->setValue( secCount);
1848// else 1854// else
1849// timeSlider->setValue( filePara.numberOfRecordedSeconds); 1855// timeSlider->setValue( filePara.numberOfRecordedSeconds);
1850 1856
1851 if( stopped && playing) { 1857 if( stopped && playing) {
1852 stop(); 1858 stop();
1853 } 1859 }
1854 1860
1855 if( stopped && recording ){ 1861 if( stopped && recording ){
1856 stop(); 1862 stop();
1857 } 1863 }
1858 1864
1859 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { 1865 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
1860 stop(); 1866 stop();
1861 } 1867 }
1862 1868
1863 odebug << "" << secCount << "" << oendl; 1869 odebug << "" << secCount << "" << oendl;
1864 QString timeString; 1870 QString timeString;
1865#ifdef DEV_VERSION 1871#ifdef DEV_VERSION
1866 QString msg; 1872 QString msg;
1867 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1873 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1868 setCaption( msg +" :: "+QString::number(secCount)); 1874 setCaption( msg +" :: "+QString::number(secCount));
1869#endif 1875#endif
1870 1876
1871 timeString.sprintf("%d", secCount); 1877 timeString.sprintf("%d", secCount);
1872 // timeLabel->setText( timeString + " seconds"); 1878 // timeLabel->setText( timeString + " seconds");
1873 1879
1874 secCount++; 1880 secCount++;
1875} 1881}
1876 1882
1877void QtRec::changeTimeSlider(int index) { 1883void QtRec::changeTimeSlider(int index) {
1878 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1884 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
1879 odebug << "Slider moved to " << index << "" << oendl; 1885 odebug << "Slider moved to " << index << "" << oendl;
1880 paused = true; 1886 paused = true;
1881 stopped = true; 1887 stopped = true;
1882 1888
1883 sliderPos=index; 1889 sliderPos=index;
1884 1890
1885 QString timeString; 1891 QString timeString;
1886 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1892 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1887 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1893 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1888 secCount = (int)filePara.numberOfRecordedSeconds; 1894 secCount = (int)filePara.numberOfRecordedSeconds;
1889 // timeLabel->setText( timeString + tr(" seconds")); 1895 // timeLabel->setText( timeString + tr(" seconds"));
1890} 1896}
1891 1897
1892void QtRec::timeSliderPressed() { 1898void QtRec::timeSliderPressed() {
1893 if( ListView1->currentItem() == 0) return; 1899 if( ListView1->currentItem() == 0) return;
1894 odebug << "slider pressed" << oendl; 1900 odebug << "slider pressed" << oendl;
1895 paused = true; 1901 paused = true;
1896 stopped = true; 1902 stopped = true;
1897} 1903}
1898 1904
1899void QtRec::timeSliderReleased() { 1905void QtRec::timeSliderReleased() {
1900 if( ListView1->currentItem() == 0) return; 1906 if( ListView1->currentItem() == 0) return;
1901 sliderPos = timeSlider->value(); 1907 sliderPos = timeSlider->value();
1902 1908
1903 odebug << "slider released " << sliderPos << "" << oendl; 1909 odebug << "slider released " << sliderPos << "" << oendl;
1904 stopped = false; 1910 stopped = false;
1905 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1911 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1906 total = newPos*4; 1912 total = newPos*4;
1907 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1913 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1908 1914
1909 doPlay(); 1915 doPlay();
1910} 1916}
1911 1917
1912void QtRec::rewindPressed() { 1918void QtRec::rewindPressed() {
1913 if( ListView1->currentItem() == 0) return; 1919 if( ListView1->currentItem() == 0) return;
1914 if( !wavFile->track.isOpen()) { 1920 if( !wavFile->track.isOpen()) {
1915 if( !openPlayFile() ) 1921 if( !openPlayFile() )
1916 return; 1922 return;
1917 else 1923 else
1918 if( !setupAudio( false)) 1924 if( !setupAudio( false))
1919 return; 1925 return;
1920 } else { 1926 } else {
1921 killTimers(); 1927 killTimers();
1922 paused = true; 1928 paused = true;
1923 stopped = true; 1929 stopped = true;
1924 rewindTimer->start( 50, false); 1930 rewindTimer->start( 50, false);
1925 } 1931 }
1926} 1932}
1927 1933
1928void QtRec::rewindTimerTimeout() { 1934void QtRec::rewindTimerTimeout() {
1929 int sliderValue = timeSlider->value(); 1935 int sliderValue = timeSlider->value();
1930 sliderValue = sliderValue - ( filePara.numberSamples / 100); 1936 sliderValue = sliderValue - ( filePara.numberSamples / 100);
1931 // if(toBeginningButton->isDown()) 1937 // if(toBeginningButton->isDown())
1932 timeSlider->setValue( sliderValue ) ; 1938 timeSlider->setValue( sliderValue ) ;
1933 odebug << "" << sliderValue << "" << oendl; 1939 odebug << "" << sliderValue << "" << oendl;
1934 QString timeString; 1940 QString timeString;
1935 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1941 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1936 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1942 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1937 // timeLabel->setText( timeString+ tr(" seconds")); 1943 // timeLabel->setText( timeString+ tr(" seconds"));
1938} 1944}
1939 1945
1940void QtRec::rewindReleased() { 1946void QtRec::rewindReleased() {
1941 rewindTimer->stop(); 1947 rewindTimer->stop();
1942 if( wavFile->track.isOpen()) { 1948 if( wavFile->track.isOpen()) {
1943 sliderPos=timeSlider->value(); 1949 sliderPos=timeSlider->value();
1944 stopped = false; 1950 stopped = false;
1945 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1951 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1946 total = newPos * 4; 1952 total = newPos * 4;
1947 odebug << "rewind released " << total << "" << oendl; 1953 odebug << "rewind released " << total << "" << oendl;
1948 startTimer( 1000); 1954 startTimer( 1000);
1949 doPlay(); 1955 doPlay();
1950 } 1956 }
1951} 1957}
1952 1958
1953void QtRec::FastforwardPressed() { 1959void QtRec::FastforwardPressed() {
1954 if( ListView1->currentItem() == 0) return; 1960 if( ListView1->currentItem() == 0) return;
1955 if( !wavFile->track.isOpen()) 1961 if( !wavFile->track.isOpen())
1956 if( !openPlayFile() ) 1962 if( !openPlayFile() )
1957 return; 1963 return;
1958 else 1964 else
1959 if( !setupAudio( false)) 1965 if( !setupAudio( false))
1960 return; 1966 return;
1961 killTimers(); 1967 killTimers();
1962 1968
1963 paused = true; 1969 paused = true;
1964 stopped = true; 1970 stopped = true;
1965 forwardTimer->start(50, false); 1971 forwardTimer->start(50, false);
1966} 1972}
1967 1973
1968 1974
1969void QtRec::forwardTimerTimeout() { 1975void QtRec::forwardTimerTimeout() {
1970 int sliderValue = timeSlider->value(); 1976 int sliderValue = timeSlider->value();
1971 sliderValue = sliderValue + ( filePara.numberSamples / 100); 1977 sliderValue = sliderValue + ( filePara.numberSamples / 100);
1972 1978
1973 // if(toEndButton->isDown()) 1979 // if(toEndButton->isDown())
1974 timeSlider->setValue( sliderValue); 1980 timeSlider->setValue( sliderValue);
1975 1981
1976 QString timeString; 1982 QString timeString;
1977 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1983 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1978 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1984 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1979 // timeLabel->setText( timeString+ tr(" seconds")); 1985 // timeLabel->setText( timeString+ tr(" seconds"));
1980} 1986}
1981 1987
1982void QtRec::FastforwardReleased() { 1988void QtRec::FastforwardReleased() {
1983 forwardTimer->stop(); 1989 forwardTimer->stop();
1984 if( wavFile->track.isOpen()) { 1990 if( wavFile->track.isOpen()) {
1985 sliderPos=timeSlider->value(); 1991 sliderPos=timeSlider->value();
1986 stopped = false; 1992 stopped = false;
1987 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1993 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1988 total = newPos * 4; 1994 total = newPos * 4;
1989 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1995 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1990 startTimer( 1000); 1996 startTimer( 1000);
1991 doPlay(); 1997 doPlay();
1992 } 1998 }
1993} 1999}
1994 2000
1995 2001
1996QString QtRec::getStorage(const QString &fileName) { 2002QString QtRec::getStorage(const QString &fileName) {
1997 2003
1998 StorageInfo storageInfo; 2004 StorageInfo storageInfo;
1999 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2005 const QList<FileSystem> &fs = storageInfo.fileSystems();
2000 QListIterator<FileSystem> it ( fs ); 2006 QListIterator<FileSystem> it ( fs );
2001 QString storage; 2007 QString storage;
2002 for( ; it.current(); ++it ){ 2008 for( ; it.current(); ++it ){
2003 const QString name = ( *it)->name(); 2009 const QString name = ( *it)->name();
2004 const QString path = ( *it)->path(); 2010 const QString path = ( *it)->path();
2005 const QString disk = ( *it)->disk(); 2011 const QString disk = ( *it)->disk();
2006 if( fileName.find( path,0,true) != -1) 2012 if( fileName.find( path,0,true) != -1)
2007 storage = name; 2013 storage = name;
2008 // const QString options = (*it)->options(); 2014 // const QString options = (*it)->options();
2009 // if( name.find( tr("Internal"),0,true) == -1) { 2015 // if( name.find( tr("Internal"),0,true) == -1) {
2010 // storageComboBox->insertItem( name +" -> "+disk); 2016 // storageComboBox->insertItem( name +" -> "+disk);
2011 // odebug << name << oendl; 2017 // odebug << name << oendl;
2012 } 2018 }
2013 return storage; 2019 return storage;
2014 // struct mntent *me; 2020 // struct mntent *me;
2015 // // if(fileName == "/etc/mtab") { 2021 // // if(fileName == "/etc/mtab") {
2016 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 2022 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
2017 // if ( mntfp ) { 2023 // if ( mntfp ) {
2018 // while ( (me = getmntent( mntfp )) != 0 ) { 2024 // while ( (me = getmntent( mntfp )) != 0 ) {
2019 // QString filesystemType = me->mnt_type; 2025 // QString filesystemType = me->mnt_type;
2020 2026
2021 // } 2027 // }
2022 // } 2028 // }
2023 // endmntent( mntfp ); 2029 // endmntent( mntfp );
2024} 2030}
2025 2031
2026void QtRec::setRecordButton(bool b) { 2032void QtRec::setRecordButton(bool b) {
2027 2033
2028 if(b) { //about to record or play 2034 if(b) { //about to record or play
2029 2035
2030 Rec_PushButton->setDown( true); 2036 Rec_PushButton->setDown( true);
2031 QPixmap image3( ( const char** ) image3_data ); 2037 QPixmap image3( ( const char** ) image3_data );
2032 Stop_PushButton->setPixmap( image3 ); 2038 Stop_PushButton->setPixmap( image3 );
2033 if(Stop_PushButton->isDown()) 2039 if(Stop_PushButton->isDown())
2034 Stop_PushButton->setDown( true); 2040 Stop_PushButton->setDown( true);
2035 // playLabel2->setText( tr("Stop") ); 2041 // playLabel2->setText( tr("Stop") );
2036 2042
2037 } else { //about to stop 2043 } else { //about to stop
2038 2044
2039 QPixmap image4( ( const char** ) image4_data ); 2045 QPixmap image4( ( const char** ) image4_data );
2040 Stop_PushButton->setPixmap( image4); 2046 Stop_PushButton->setPixmap( image4);
2041 if(Stop_PushButton->isDown()) 2047 if(Stop_PushButton->isDown())
2042 Stop_PushButton->setDown( false); 2048 Stop_PushButton->setDown( false);
2043 // playLabel2->setText( tr("Play") ); 2049 // playLabel2->setText( tr("Play") );
2044 if(Rec_PushButton->isDown()) 2050 if(Rec_PushButton->isDown())
2045 Rec_PushButton->setDown( false); 2051 Rec_PushButton->setDown( false);
2046 } 2052 }
2047} 2053}
2048 2054
2049void QtRec::fillDirectoryCombo() { 2055void QtRec::fillDirectoryCombo() {
2050 if( directoryComboBox->count() > 0) 2056 if( directoryComboBox->count() > 0)
2051 directoryComboBox->clear(); 2057 directoryComboBox->clear();
2052 int index = 0; 2058 int index = 0;
2053 Config cfg("OpieRec"); 2059 Config cfg("OpieRec");
2054 cfg.setGroup("Settings"); 2060 cfg.setGroup("Settings");
2055 QString dir = cfg.readEntry("directory", "/"); 2061 QString dir = cfg.readEntry("directory", "/");
2056 StorageInfo storageInfo; 2062 StorageInfo storageInfo;
2057 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2063 const QList<FileSystem> &fs = storageInfo.fileSystems();
2058 QListIterator<FileSystem> it ( fs ); 2064 QListIterator<FileSystem> it ( fs );
2059 QString storage; 2065 QString storage;
2060 for( ; it.current(); ++it ){ 2066 for( ; it.current(); ++it ){
2061 const QString name = ( *it)->name(); 2067 const QString name = ( *it)->name();
2062 const QString path = ( *it)->path(); 2068 const QString path = ( *it)->path();
2063 // directoryComboBox->insertItem(name+" "+path); 2069 // directoryComboBox->insertItem(name+" "+path);
2064 directoryComboBox->insertItem(name); 2070 directoryComboBox->insertItem(name);
2065 if( path == dir) 2071 if( path == dir)
2066 directoryComboBox->setCurrentItem( index); 2072 directoryComboBox->setCurrentItem( index);
2067 index++; 2073 index++;
2068 } 2074 }
2069} 2075}
2070 2076
2071void QtRec::errorStop() { 2077void QtRec::errorStop() {
2072 stopped = true; 2078 stopped = true;
2073 wavFile->closeFile(); 2079 wavFile->closeFile();
2074 killTimers(); 2080 killTimers();
2075} 2081}
2076 2082
2077void QtRec::doMute(bool b) { 2083void QtRec::doMute(bool b) {
2078 doVolMuting( b); 2084 doVolMuting( b);
2079 doMicMuting( b); 2085 doMicMuting( b);
2080} 2086}
2081 2087
2082void QtRec::slotAutoMute(bool b) { 2088void QtRec::slotAutoMute(bool b) {
2083 autoMute = b; 2089 autoMute = b;
2084 Config cfg("OpieRec"); 2090 Config cfg("OpieRec");
2085 cfg.setGroup("Settings"); 2091 cfg.setGroup("Settings");
2086 cfg.writeEntry("useAutoMute",b); 2092 cfg.writeEntry("useAutoMute",b);
2087 doMute( b); 2093 doMute( b);
2088 outMuteCheckBox->setChecked( b); 2094 outMuteCheckBox->setChecked( b);
2089 inMuteCheckBox->setChecked( b); 2095 inMuteCheckBox->setChecked( b);
2090} 2096}
2091 2097
2092void QtRec::selectItemByName(const QString & name) { 2098void QtRec::selectItemByName(const QString & name) {
2093 QListViewItemIterator it( ListView1 ); 2099 QListViewItemIterator it( ListView1 );
2094 for ( ; it.current(); ++it ) 2100 for ( ; it.current(); ++it )
2095 if( name == it.current()->text(0)) 2101 if( name == it.current()->text(0))
2096 ListView1->setCurrentItem(it.current()); 2102 ListView1->setCurrentItem(it.current());
2097} 2103}
2098 2104
2099 2105
2100// long findPeak(long input ) { 2106// long findPeak(long input ) {
2101 2107
2102// // halfLife = time in seconds for output to decay to half value after an impulse 2108// // halfLife = time in seconds for output to decay to half value after an impulse
2103// static float output = 0.0; 2109// static float output = 0.0;
2104// float halfLife = .0025; 2110// float halfLife = .0025;
2105// float vsf = .0025; 2111// float vsf = .0025;
2106// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2112// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2107// if( input < 0.0 ) 2113// if( input < 0.0 )
2108// input = -input; // Absolute value. 2114// input = -input; // Absolute value.
2109// if ( input >= output ) { 2115// if ( input >= output ) {
2110// // When we hit a peak, ride the peak to the top. 2116// // When we hit a peak, ride the peak to the top.
2111// output = input; 2117// output = input;
2112// } else { 2118// } else {
2113// // Exponential decay of output when signal is low. 2119// // Exponential decay of output when signal is low.
2114// output = output * scalar; 2120// output = output * scalar;
2115// // 2121// //
2116// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2122// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2117// // which can cause a severe performance degradation due to a flood 2123// // which can cause a severe performance degradation due to a flood
2118// // of interrupts. 2124// // of interrupts.
2119// // 2125// //
2120// if( output < vsf ) output = 0.0; 2126// if( output < vsf ) output = 0.0;
2121// } 2127// }
2122 2128
2123// return (long) output; 2129// return (long) output;
2124// } 2130// }
2125 2131
2126void QtRec::changeStereoCheck(bool b) { 2132void QtRec::changeStereoCheck(bool b) {
2127 Config cfg("OpieRec"); 2133 Config cfg("OpieRec");
2128 cfg.setGroup("Settings"); 2134 cfg.setGroup("Settings");
2129 int ch = 0; 2135 int ch = 0;
2130 if ( !b) { ch = 1;} 2136 if ( !b) { ch = 1;}
2131 else { ch = 2;} 2137 else { ch = 2;}
2132 cfg.writeEntry("stereo", b); 2138 cfg.writeEntry("stereo", b);
2133 filePara.channels = ch; 2139 filePara.channels = ch;
2134 2140
2135 cfg.write(); 2141 cfg.write();
2136} 2142}
2137 2143
2138 2144