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