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