summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index e3385cd..1141faa 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,840 +1,846 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/ 5****************************************************************************/
6#define DEV_VERSION 6#define DEV_VERSION
7 7
8#include "pixmaps.h" 8#include "pixmaps.h"
9#include "qtrec.h" 9#include "qtrec.h"
10#include "waveform.h" 10#include "waveform.h"
11extern "C" { 11extern "C" {
12#include "adpcm.h" 12#include "adpcm.h"
13} 13}
14 14
15/* OPIE */ 15/* OPIE */
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/qcopenvelope_qws.h> 18#include <qpe/qcopenvelope_qws.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/storage.h> 21#include <qpe/storage.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT */ 24/* QT */
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qtimer.h> 37#include <qtimer.h>
38 38
39/* STD */ 39/* STD */
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <math.h> 42#include <math.h>
43#include <mntent.h> 43#include <mntent.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <sys/ioctl.h> 46#include <sys/ioctl.h>
47#include <sys/soundcard.h> 47#include <sys/soundcard.h>
48#include <sys/stat.h> 48#include <sys/stat.h>
49#include <sys/time.h> 49#include <sys/time.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/vfs.h> 51#include <sys/vfs.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <sys/wait.h> 53#include <sys/wait.h>
54#include <sys/signal.h> 54#include <sys/signal.h>
55#include <pthread.h> 55#include <pthread.h>
56 56
57#ifdef PDAUDIO //ALSA 57#ifdef PDAUDIO //ALSA
58#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
60static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
61#else //OSS 61#else //OSS
62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
63static int deviceBitRates[] = { 8, 16, -1 }; 63static int deviceBitRates[] = { 8, 16, -1 };
64#endif 64#endif
65 65
66#if defined(QT_QWS_SL5XXX) 66#if defined(QT_QWS_SL5XXX)
67///#if defined(QT_QWS_EBX) 67///#if defined(QT_QWS_EBX)
68 68
69#define DSPSTROUT "/dev/dsp" 69#define DSPSTROUT "/dev/dsp"
70#define DSPSTRIN "/dev/dsp1"
71#define DSPSTRMIXEROUT "/dev/mixer" 70#define DSPSTRMIXEROUT "/dev/mixer"
71
72#ifdef SHARP
73#define DSPSTRIN "/dev/dsp1"
72#define DSPSTRMIXERIN "/dev/mixer1" 74#define DSPSTRMIXERIN "/dev/mixer1"
75#else
76#define DSPSTRIN "/dev/dsp"
77#define DSPSTRMIXERIN "/dev/mixer"
78#endif
73 79
74#else 80#else
75 81
76#define DSPSTROUT "/dev/dsp" 82#define DSPSTROUT "/dev/dsp"
77#define DSPSTRIN "/dev/dsp" 83#define DSPSTRIN "/dev/dsp"
78#define DSPSTRMIXERIN "/dev/mixer" 84#define DSPSTRMIXERIN "/dev/mixer"
79#define DSPSTRMIXEROUT "/dev/mixer" 85#define DSPSTRMIXEROUT "/dev/mixer"
80 86
81#endif 87#endif
82 88
83//#define ZAURUS 0 89//#define ZAURUS 0
84struct adpcm_state encoder_state; 90struct adpcm_state encoder_state;
85struct adpcm_state decoder_state; 91struct adpcm_state decoder_state;
86 92
87typedef struct { 93typedef struct {
88 int sampleRate; 94 int sampleRate;
89 /* int fragSize; */ 95 /* int fragSize; */
90 /* int blockSize; */ 96 /* int blockSize; */
91 int resolution; //bitrate 97 int resolution; //bitrate
92 int channels; //number of channels 98 int channels; //number of channels
93 int fd; //file descriptor 99 int fd; //file descriptor
94 int sd; //sound device descriptor 100 int sd; //sound device descriptor
95 int numberSamples; //total number of samples 101 int numberSamples; //total number of samples
96 int SecondsToRecord; // number of seconds that should be recorded 102 int SecondsToRecord; // number of seconds that should be recorded
97 float numberOfRecordedSeconds; //total number of samples recorded 103 float numberOfRecordedSeconds; //total number of samples recorded
98 int samplesToRecord; //number of samples to be recorded 104 int samplesToRecord; //number of samples to be recorded
99 int inVol; //input volume 105 int inVol; //input volume
100 int outVol; //output volume 106 int outVol; //output volume
101 int format; //wavfile format PCM.. ADPCM 107 int format; //wavfile format PCM.. ADPCM
102 const char *fileName; //name of fiel to be played/recorded 108 const char *fileName; //name of fiel to be played/recorded
103} fileParameters; 109} fileParameters;
104 110
105fileParameters filePara; 111fileParameters filePara;
106 112
107bool monitoring, recording, playing; 113bool monitoring, recording, playing;
108bool stopped; 114bool stopped;
109QLabel *timeLabel; 115QLabel *timeLabel;
110QSlider *timeSlider; 116QSlider *timeSlider;
111int sd; 117int sd;
112 118
113Waveform* waveform; 119Waveform* waveform;
114Device *soundDevice; 120Device *soundDevice;
115 121
116 122
117#ifdef THREADED 123#ifdef THREADED
118void quickRec() 124void quickRec()
119#else 125#else
120 void QtRec::quickRec() 126 void QtRec::quickRec()
121#endif 127#endif
122{ 128{
123 129
124 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl; 130 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl;
125 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate 131 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate
126 << ", channels " << filePara.channels << oendl; 132 << ", channels " << filePara.channels << oendl;
127 133
128 int total = 0; // Total number of bytes read in so far. 134 int total = 0; // Total number of bytes read in so far.
129 int bytesWritten, number; 135 int bytesWritten, number;
130 136
131 bytesWritten = 0; 137 bytesWritten = 0;
132 number = 0; 138 number = 0;
133 QString num; 139 QString num;
134 int level = 0; 140 int level = 0;
135 int threshold = 0; 141 int threshold = 0;
136 int bits = filePara.resolution; 142 int bits = filePara.resolution;
137 odebug << "bits " << bits << "" << oendl; 143 odebug << "bits " << bits << "" << oendl;
138 144
139 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 145 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
140 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; 146 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
141 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; 147 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
142 odebug << "" << filePara.sd << "" << oendl; 148 odebug << "" << filePara.sd << "" << oendl;
143 level = 7; 149 level = 7;
144 threshold = 0; 150 threshold = 0;
145 151
146 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 152 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
147 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; 153 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
148// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 154// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
149 char abuf[ BUFSIZE/2 ]; 155 char abuf[ BUFSIZE/2 ];
150 short sbuf[ BUFSIZE ]; 156 short sbuf[ BUFSIZE ];
151 short sbuf2[ BUFSIZE ]; 157 short sbuf2[ BUFSIZE ];
152 memset( abuf, 0, BUFSIZE/2); 158 memset( abuf, 0, BUFSIZE/2);
153 memset( sbuf, 0, BUFSIZE); 159 memset( sbuf, 0, BUFSIZE);
154 memset( sbuf2, 0, BUFSIZE); 160 memset( sbuf2, 0, BUFSIZE);
155 161
156 for(;;) { 162 for(;;) {
157 if ( stopped) { 163 if ( stopped) {
158 odebug << "quickRec:: stopped" << oendl; 164 odebug << "quickRec:: stopped" << oendl;
159 break; 165 break;
160 } 166 }
161 167
162// number=::read( filePara.sd, sbuf, BUFSIZE); 168// number=::read( filePara.sd, sbuf, BUFSIZE);
163 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE); 169 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE);
164 170
165 if(number <= 0) { 171 if(number <= 0) {
166 perror("recording error "); 172 perror("recording error ");
167 odebug << "" << filePara.fileName << " " << number << "" << oendl; 173 odebug << "" << filePara.fileName << " " << number << "" << oendl;
168 stopped = true; 174 stopped = true;
169 return; 175 return;
170 } 176 }
171 //if(stereo == 2) { 177 //if(stereo == 2) {
172// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 178// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
173 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 179 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
174 180
175 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); 181 bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
176 182
177 waveform->newSamples( sbuf, number ); 183 waveform->newSamples( sbuf, number );
178 184
179 total += bytesWritten; 185 total += bytesWritten;
180 filePara.numberSamples = total; 186 filePara.numberSamples = total;
181 timeSlider->setValue( total); 187 timeSlider->setValue( total);
182 188
183 printf("%d, bytes %d,total %d\r",number, bytesWritten, total); 189 printf("%d, bytes %d,total %d\r",number, bytesWritten, total);
184 fflush(stdout); 190 fflush(stdout);
185 191
186 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels; 192 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2/ filePara.channels;
187 193
188 qApp->processEvents(); 194 qApp->processEvents();
189 if( total >= filePara.samplesToRecord) { 195 if( total >= filePara.samplesToRecord) {
190 stopped = true; 196 stopped = true;
191 break; 197 break;
192 } 198 }
193 } 199 }
194 } else { 200 } else {
195 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 201 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
196 odebug << "start recording WAVE_FORMAT_PCM" << oendl; 202 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
197 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 203 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
198 memset( inbuffer, 0, BUFSIZE); 204 memset( inbuffer, 0, BUFSIZE);
199 memset( outbuffer, 0, BUFSIZE); 205 memset( outbuffer, 0, BUFSIZE);
200 206
201 for(;;) { 207 for(;;) {
202 if ( stopped) { 208 if ( stopped) {
203 odebug << "quickRec:: stopped" << oendl; 209 odebug << "quickRec:: stopped" << oendl;
204 stopped = true; 210 stopped = true;
205 break; // stop if playing was set to false 211 break; // stop if playing was set to false
206 return; 212 return;
207 } 213 }
208 214
209 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE); 215 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE);
210 216
211 if( number <= 0) { 217 if( number <= 0) {
212 perror( "recording error "); 218 perror( "recording error ");
213 odebug << filePara.fileName << oendl; 219 odebug << filePara.fileName << oendl;
214 stopped = true; 220 stopped = true;
215 return; 221 return;
216 } 222 }
217 223
218 bytesWritten = ::write( filePara.fd , inbuffer, number); 224 bytesWritten = ::write( filePara.fd , inbuffer, number);
219 waveform->newSamples( inbuffer, number ); 225 waveform->newSamples( inbuffer, number );
220 226
221 if( bytesWritten < 0) { 227 if( bytesWritten < 0) {
222 perror("File writing error "); 228 perror("File writing error ");
223 stopped = true; 229 stopped = true;
224 return; 230 return;
225 } 231 }
226 232
227 total += bytesWritten; 233 total += bytesWritten;
228 234
229 filePara.numberSamples = total; 235 filePara.numberSamples = total;
230 236
231 if( filePara.SecondsToRecord != 0) 237 if( filePara.SecondsToRecord != 0)
232 timeSlider->setValue( total); 238 timeSlider->setValue( total);
233 printf("%d, bytes %d,total %d\r",number, bytesWritten , total); 239 printf("%d, bytes %d,total %d\r",number, bytesWritten , total);
234 fflush(stdout); 240 fflush(stdout);
235 241
236 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate 242 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate
237 / (float)2/filePara.channels; 243 / (float)2/filePara.channels;
238 qApp->processEvents(); 244 qApp->processEvents();
239 245
240 if( total >= filePara.samplesToRecord) { 246 if( total >= filePara.samplesToRecord) {
241 stopped = true; 247 stopped = true;
242 break; 248 break;
243 } 249 }
244 } 250 }
245 } //end main loop 251 } //end main loop
246 252
247 } else { 253 } else {
248// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 254// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
249 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 255 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
250 memset( unsigned_inbuffer, 0, BUFSIZE); 256 memset( unsigned_inbuffer, 0, BUFSIZE);
251 memset( unsigned_outbuffer, 0, BUFSIZE); 257 memset( unsigned_outbuffer, 0, BUFSIZE);
252 258
253 for(;;) { 259 for(;;) {
254 if ( stopped) { 260 if ( stopped) {
255 odebug << "quickRec:: stopped" << oendl; 261 odebug << "quickRec:: stopped" << oendl;
256 break; // stop if playing was set to false 262 break; // stop if playing was set to false
257 } 263 }
258 264
259 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE); 265 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE);
260 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 266 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
261 waveform->newSamples( (const short *) unsigned_inbuffer, number ); 267 waveform->newSamples( (const short *) unsigned_inbuffer, number );
262 268
263 if(bytesWritten < 0) { 269 if(bytesWritten < 0) {
264 stopped = true; 270 stopped = true;
265 QMessageBox::message("Note","<p>There was a problem writing to the file</p>"); 271 QMessageBox::message("Note","<p>There was a problem writing to the file</p>");
266 perror("File writing error "); 272 perror("File writing error ");
267 return; 273 return;
268 } 274 }
269 275
270 total += bytesWritten; 276 total += bytesWritten;
271 filePara.numberSamples = total; 277 filePara.numberSamples = total;
272 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total); 278 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total);
273 // fflush(stdout); 279 // fflush(stdout);
274 if( filePara.SecondsToRecord !=0) 280 if( filePara.SecondsToRecord !=0)
275 timeSlider->setValue( total); 281 timeSlider->setValue( total);
276 282
277 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 283 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
278 284
279 qApp->processEvents(); 285 qApp->processEvents();
280 if( total >= filePara.samplesToRecord) { 286 if( total >= filePara.samplesToRecord) {
281 stopped = true; 287 stopped = true;
282 break; 288 break;
283 } 289 }
284 } //end main loop 290 } //end main loop
285 } 291 }
286} /// END quickRec() 292} /// END quickRec()
287 293
288 294
289#ifdef THREADED 295#ifdef THREADED
290void playIt() 296void playIt()
291#else 297#else
292 void QtRec::playIt() 298 void QtRec::playIt()
293#endif 299#endif
294{ 300{
295 int bytesWritten = 0; 301 int bytesWritten = 0;
296 int number = 0; 302 int number = 0;
297 int total = 0; // Total number of bytes read in so far. 303 int total = 0; // Total number of bytes read in so far.
298 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 304 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
299 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 305 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
300 char abuf[ BUFSIZE / 2 ]; 306 char abuf[ BUFSIZE / 2 ];
301 short sbuf[ BUFSIZE ]; 307 short sbuf[ BUFSIZE ];
302 short sbuf2[ BUFSIZE * 2 ]; 308 short sbuf2[ BUFSIZE * 2 ];
303 memset( abuf, 0, BUFSIZE / 2); 309 memset( abuf, 0, BUFSIZE / 2);
304 memset( sbuf, 0, BUFSIZE); 310 memset( sbuf, 0, BUFSIZE);
305 memset( sbuf2, 0, BUFSIZE * 2); 311 memset( sbuf2, 0, BUFSIZE * 2);
306// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 312// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
307 for(;;) { // play loop 313 for(;;) { // play loop
308 if ( stopped) { 314 if ( stopped) {
309 break; 315 break;
310 return; 316 return;
311 }// stop if playing was set to false 317 }// stop if playing was set to false
312 318
313 number = ::read( filePara.fd, abuf, BUFSIZE / 2); 319 number = ::read( filePara.fd, abuf, BUFSIZE / 2);
314 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); 320 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
315 321
316// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 322// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
317// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 323// sbuf2[i+1]=sbuf2[i]=sbuf[i];
318// } 324// }
319 bytesWritten = write ( filePara.sd, sbuf, number * 4); 325 bytesWritten = write ( filePara.sd, sbuf, number * 4);
320 waveform->newSamples( (const short *)sbuf, number *4); 326 waveform->newSamples( (const short *)sbuf, number *4);
321 // if(filePara.channels==1) 327 // if(filePara.channels==1)
322 // total += bytesWritten/2; //mono 328 // total += bytesWritten/2; //mono
323 // else 329 // else
324 total += bytesWritten; 330 total += bytesWritten;
325 filePara.numberSamples = total/4; 331 filePara.numberSamples = total/4;
326 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 332 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
327 333
328 timeSlider->setValue( total/4); 334 timeSlider->setValue( total/4);
329// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 335// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
330// if(filePara.numberOfRecordedSeconds>1) 336// if(filePara.numberOfRecordedSeconds>1)
331// timeLabel->setText( timeString+ tr(" seconds")); 337// timeLabel->setText( timeString+ tr(" seconds"));
332// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 338// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
333// fflush(stdout); 339// fflush(stdout);
334 340
335 qApp->processEvents(); 341 qApp->processEvents();
336 342
337 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 343 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
338// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { 344// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
339 stopped = true; 345 stopped = true;
340 break; 346 break;
341 } 347 }
342 } 348 }
343 } else { 349 } else {
344 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 350 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
345 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 351 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
346 memset( inbuffer, 0, BUFSIZE); 352 memset( inbuffer, 0, BUFSIZE);
347 memset( outbuffer, 0, BUFSIZE); 353 memset( outbuffer, 0, BUFSIZE);
348 354
349 for(;;) { // play loop 355 for(;;) { // play loop
350 if ( stopped) { 356 if ( stopped) {
351 break; 357 break;
352 return; 358 return;
353 } 359 }
354// stop if playing was set to false 360// stop if playing was set to false
355 number = ::read( filePara.fd, inbuffer, BUFSIZE); 361 number = ::read( filePara.fd, inbuffer, BUFSIZE);
356// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 362// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
357// // for (int i=0;i< number ; i++) { //2*i is left channel 363// // for (int i=0;i< number ; i++) { //2*i is left channel
358// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 364// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
359// } 365// }
360 bytesWritten = ::write( filePara.sd, inbuffer, number); 366 bytesWritten = ::write( filePara.sd, inbuffer, number);
361 waveform->newSamples( inbuffer, number); 367 waveform->newSamples( inbuffer, number);
362 //-------------->>>> out to device 368 //-------------->>>> out to device
363 // total+=bytesWritten; 369 // total+=bytesWritten;
364 // if(filePara.channels==1) 370 // if(filePara.channels==1)
365 // total += bytesWritten/2; //mono 371 // total += bytesWritten/2; //mono
366 // else 372 // else
367 total += bytesWritten; 373 total += bytesWritten;
368 timeSlider->setValue( total); 374 timeSlider->setValue( total);
369 375
370 filePara.numberSamples = total; 376 filePara.numberSamples = total;
371 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 377 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
372 378
373// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 379// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
374// timeLabel->setText( timeString + tr(" seconds")); 380// timeLabel->setText( timeString + tr(" seconds"));
375 381
376 qApp->processEvents(); 382 qApp->processEvents();
377 383
378 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 384 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
379 owarn << "Jane! Stop this crazy thing!" << oendl; 385 owarn << "Jane! Stop this crazy thing!" << oendl;
380 stopped = true; 386 stopped = true;
381// playing = false; 387// playing = false;
382 break; 388 break;
383 } 389 }
384 } 390 }
385// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 391// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
386// fflush(stdout); 392// fflush(stdout);
387 } //end loop 393 } //end loop
388 } else { 394 } else {
389/////////////////////////////// format = AFMT_U8; 395/////////////////////////////// format = AFMT_U8;
390 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; 396 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
391 memset( unsigned_inbuffer, 0, BUFSIZE); 397 memset( unsigned_inbuffer, 0, BUFSIZE);
392 for(;;) { 398 for(;;) {
393// main loop 399// main loop
394 if (stopped) { 400 if (stopped) {
395 break; // stop if playing was set to false 401 break; // stop if playing was set to false
396 return; 402 return;
397 } 403 }
398 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 404 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
399//data = (val >> 8) ^ 0x80; 405//data = (val >> 8) ^ 0x80;
400 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 406 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
401 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 407 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
402 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); 408 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
403 total += bytesWritten; 409 total += bytesWritten;
404 410
405 timeSlider->setValue( total); 411 timeSlider->setValue( total);
406 filePara.numberSamples = total; 412 filePara.numberSamples = total;
407 413
408 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 414 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
409// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 415// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
410// timeLabel->setText( timeString + tr(" seconds")); 416// timeLabel->setText( timeString + tr(" seconds"));
411 qApp->processEvents(); 417 qApp->processEvents();
412 418
413 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 419 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
414// if( total >= filePara.numberSamples ) { 420// if( total >= filePara.numberSamples ) {
415 stopped = true; 421 stopped = true;
416 break; 422 break;
417 } 423 }
418// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 424// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
419// fflush(stdout); 425// fflush(stdout);
420 } 426 }
421 } 427 }
422} 428}
423 429
424 430
425QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 431QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
426 : QWidget( parent, name, fl ) 432 : QWidget( parent, name, fl )
427{ 433{
428 if ( !name ) 434 if ( !name )
429 setName( "OpieRec" ); 435 setName( "OpieRec" );
430 init(); 436 init();
431 initConfig(); 437 initConfig();
432 initConnections(); 438 initConnections();
433 renameBox = 0; 439 renameBox = 0;
434 440
435// open sound device to get volumes 441// open sound device to get volumes
436 Config hwcfg("OpieRec"); 442 Config hwcfg("OpieRec");
437 hwcfg.setGroup("Hardware"); 443 hwcfg.setGroup("Hardware");
438 444
439 445
440 soundDevice = new Device( this, 446 soundDevice = new Device( this,
441 hwcfg.readEntry( "Audio",DSPSTROUT), 447 hwcfg.readEntry( "Audio",DSPSTROUT),
442 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); 448 hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false);
443// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); 449// soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false);
444 450
445// soundDevice->setDeviceFormat(AFMT_S16_LE); 451// soundDevice->setDeviceFormat(AFMT_S16_LE);
446// soundDevice->setDeviceChannels(1); 452// soundDevice->setDeviceChannels(1);
447// soundDevice->setDeviceRate( 22050); 453// soundDevice->setDeviceRate( 22050);
448 454
449 getInVol(); 455 getInVol();
450 getOutVol(); 456 getOutVol();
451 457
452 soundDevice->closeDevice( true); 458 soundDevice->closeDevice( true);
453 soundDevice->sd = -1; 459 soundDevice->sd = -1;
454 soundDevice = 0; 460 soundDevice = 0;
455 wavFile = 0; 461 wavFile = 0;
456 462
457// if( soundDevice) delete soundDevice; 463// if( soundDevice) delete soundDevice;
458 464
459 initIconView(); 465 initIconView();
460 466
461 if( autoMute) 467 if( autoMute)
462 doMute( true); 468 doMute( true);
463 ListView1->setFocus(); 469 ListView1->setFocus();
464 playing = false; 470 playing = false;
465} 471}
466 472
467QtRec::~QtRec() { 473QtRec::~QtRec() {
468// if( soundDevice) delete soundDevice; 474// if( soundDevice) delete soundDevice;
469 475
470} 476}
471 477
472void QtRec::cleanUp() { 478void QtRec::cleanUp() {
473 479
474 if( !stopped) { 480 if( !stopped) {
475 stopped = true; 481 stopped = true;
476 endRecording(); 482 endRecording();
477 } 483 }
478 484
479 ListView1->clear(); 485 ListView1->clear();
480 486
481 if( autoMute) 487 if( autoMute)
482 doMute(false); 488 doMute(false);
483 489
484// if( wavFile) delete wavFile; 490// if( wavFile) delete wavFile;
485// if(soundDevice) delete soundDevice; 491// if(soundDevice) delete soundDevice;
486} 492}
487 493
488void QtRec::init() { 494void QtRec::init() {
489 495
490 needsStereoOut = false; 496 needsStereoOut = false;
491 QPixmap image3( ( const char** ) image3_data ); 497 QPixmap image3( ( const char** ) image3_data );
492 QPixmap image4( ( const char** ) image4_data ); 498 QPixmap image4( ( const char** ) image4_data );
493 QPixmap image6( ( const char** ) image6_data ); 499 QPixmap image6( ( const char** ) image6_data );
494 500
495 stopped = true; 501 stopped = true;
496 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 502 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
497 QGridLayout *layout = new QGridLayout( this ); 503 QGridLayout *layout = new QGridLayout( this );
498 layout->setSpacing( 2); 504 layout->setSpacing( 2);
499 layout->setMargin( 2); 505 layout->setMargin( 2);
500 506
501 TabWidget = new QTabWidget( this, "TabWidget" ); 507 TabWidget = new QTabWidget( this, "TabWidget" );
502 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); 508 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8);
503// TabWidget->setTabShape(QTabWidget::Triangular); 509// TabWidget->setTabShape(QTabWidget::Triangular);
504 510
505 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 511 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
506 tab = new QWidget( TabWidget, "tab" ); 512 tab = new QWidget( TabWidget, "tab" );
507 513
508 QGridLayout *layout1 = new QGridLayout( tab); 514 QGridLayout *layout1 = new QGridLayout( tab);
509 layout1->setSpacing( 2); 515 layout1->setSpacing( 2);
510 layout1->setMargin( 2); 516 layout1->setMargin( 2);
511 517
512 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 518 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
513 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 519 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
514 520
515 // timeLabel = new QLabel( tab, "TimeLabel" ); 521 // timeLabel = new QLabel( tab, "TimeLabel" );
516 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 522 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
517 523
518 // playLabel2 = new QLabel(tab, "PlayLabel2" ); 524 // playLabel2 = new QLabel(tab, "PlayLabel2" );
519 // playLabel2->setText(tr("Play") ); 525 // playLabel2->setText(tr("Play") );
520 // playLabel2->setFixedHeight( 18); 526 // playLabel2->setFixedHeight( 18);
521 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 527 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
522 528
523 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 529 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
524 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 530 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
525 Stop_PushButton->setFixedSize( 22, 22); 531 Stop_PushButton->setFixedSize( 22, 22);
526 Stop_PushButton->setPixmap( image4 ); 532 Stop_PushButton->setPixmap( image4 );
527 533
528 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 534 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
529 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 535 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
530 toBeginningButton->setFixedSize( 22, 22); 536 toBeginningButton->setFixedSize( 22, 22);
531 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 537 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") );
532 538
533 toEndButton = new QPushButton( tab, "End_PushButton" ); 539 toEndButton = new QPushButton( tab, "End_PushButton" );
534 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 540 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
535 toEndButton->setFixedSize( 22, 22); 541 toEndButton->setFixedSize( 22, 22);
536 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 542 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) );
537 543
538 // QLabel *recLabel2; 544 // QLabel *recLabel2;
539 // recLabel2 = new QLabel( tab, "recLabel2" ); 545 // recLabel2 = new QLabel( tab, "recLabel2" );
540 // recLabel2->setText(tr("Rec")); 546 // recLabel2->setText(tr("Rec"));
541 // recLabel2->setFixedHeight( 18); 547 // recLabel2->setFixedHeight( 18);
542 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 548 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
543 549
544 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 550 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
545 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 551 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
546 Rec_PushButton->setFixedSize( 22, 22); 552 Rec_PushButton->setFixedSize( 22, 22);
547 Rec_PushButton->setPixmap( image6 ); 553 Rec_PushButton->setPixmap( image6 );
548 554
549 t = new QTimer( this ); 555 t = new QTimer( this );
550 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 556 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
551 557
552 rewindTimer = new QTimer( this ); 558 rewindTimer = new QTimer( this );
553 connect( rewindTimer, SIGNAL( timeout() ), 559 connect( rewindTimer, SIGNAL( timeout() ),
554 this, SLOT( rewindTimerTimeout() ) ); 560 this, SLOT( rewindTimerTimeout() ) );
555 561
556 forwardTimer = new QTimer( this ); 562 forwardTimer = new QTimer( this );
557 connect( forwardTimer, SIGNAL( timeout() ), 563 connect( forwardTimer, SIGNAL( timeout() ),
558 this, SLOT( forwardTimerTimeout() ) ); 564 this, SLOT( forwardTimerTimeout() ) );
559 565
560 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 566 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
561 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 567 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
562 deleteSoundButton->setText( tr( "Del" ) ); 568 deleteSoundButton->setText( tr( "Del" ) );
563 569
564 ListView1 = new QListView( tab, "IconView1" ); 570 ListView1 = new QListView( tab, "IconView1" );
565 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 571 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
566 572
567 ListView1->addColumn( tr( "Name" ) ); 573 ListView1->addColumn( tr( "Name" ) );
568 // ListView1->setColumnWidth( 0, 140); 574 // ListView1->setColumnWidth( 0, 140);
569 ListView1->setSorting( 1, false); 575 ListView1->setSorting( 1, false);
570 ListView1->addColumn( tr( "Time" ) ); //in seconds 576 ListView1->addColumn( tr( "Time" ) ); //in seconds
571 // ListView1->setColumnWidth( 1, -1); 577 // ListView1->setColumnWidth( 1, -1);
572 // ListView1->addColumn( tr("Location") ); 578 // ListView1->addColumn( tr("Location") );
573 // ListView1->setColumnWidth( 2, -1); 579 // ListView1->setColumnWidth( 2, -1);
574 // ListView1->addColumn( tr("Date") ); 580 // ListView1->addColumn( tr("Date") );
575 // ListView1->setColumnWidth( 3, -1); 581 // ListView1->setColumnWidth( 3, -1);
576 ListView1->setColumnWidthMode(0, QListView::Maximum); 582 ListView1->setColumnWidthMode(0, QListView::Maximum);
577 // ListView1->setColumnWidthMode(1, QListView::Maximum); 583 // ListView1->setColumnWidthMode(1, QListView::Maximum);
578 584
579 // ListView1->setColumnWidthMode( 0, QListView::Manual); 585 // ListView1->setColumnWidthMode( 0, QListView::Manual);
580 ListView1->setColumnAlignment( 1, QListView::AlignCenter); 586 ListView1->setColumnAlignment( 1, QListView::AlignCenter);
581 // ListView1->setColumnAlignment( 2, QListView::AlignRight); 587 // ListView1->setColumnAlignment( 2, QListView::AlignRight);
582 // ListView1->setColumnAlignment( 3, QListView::AlignLeft); 588 // ListView1->setColumnAlignment( 3, QListView::AlignLeft);
583 ListView1->setAllColumnsShowFocus( true ); 589 ListView1->setAllColumnsShowFocus( true );
584 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); 590 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold);
585 591
586 TabWidget->insertTab( tab, tr( "Files" ) ); 592 TabWidget->insertTab( tab, tr( "Files" ) );
587 593
588 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 594 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
589 tab_3 = new QWidget( TabWidget, "tab_3" ); 595 tab_3 = new QWidget( TabWidget, "tab_3" );
590 QGridLayout *glayout3 = new QGridLayout( tab_3 ); 596 QGridLayout *glayout3 = new QGridLayout( tab_3 );
591 glayout3->setSpacing( 2); 597 glayout3->setSpacing( 2);
592 glayout3->setMargin( 2); 598 glayout3->setMargin( 2);
593 //////////////////////////////////// 599 ////////////////////////////////////
594 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 600 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
595 sampleGroup->setTitle( tr( "Sample Rate" ) ); 601 sampleGroup->setTitle( tr( "Sample Rate" ) );
596 sampleGroup->setFixedSize( 95,50); 602 sampleGroup->setFixedSize( 95,50);
597 603
598 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 604 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
599 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 605 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
600//#ifndef QT_QWS_EBX 606//#ifndef QT_QWS_EBX
601 QString s; 607 QString s;
602 int z = 0; 608 int z = 0;
603 while( deviceSampleRates[z] != -1) { 609 while( deviceSampleRates[z] != -1) {
604 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); 610 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
605 z++; 611 z++;
606 } 612 }
607 613
608 614
609 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); 615 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
610 616
611 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 617 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
612 sizeGroup->setTitle( tr( "Limit Size" ) ); 618 sizeGroup->setTitle( tr( "Limit Size" ) );
613 sizeGroup->setFixedSize( 80, 50); 619 sizeGroup->setFixedSize( 80, 50);
614 620
615 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 621 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
616 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 622 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
617 sizeLimitCombo->insertItem(tr("Unlimited")); 623 sizeLimitCombo->insertItem(tr("Unlimited"));
618 624
619 for(int i=1;i<13; i++) { 625 for(int i=1;i<13; i++) {
620 sizeLimitCombo->insertItem( QString::number( i * 5)); 626 sizeLimitCombo->insertItem( QString::number( i * 5));
621 } 627 }
622 628
623 629
624 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); 630 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1);
625 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 631 dirGroup = new QGroupBox( tab_3, "dirGroup" );
626 dirGroup->setTitle( tr( "File Directory" ) ); 632 dirGroup->setTitle( tr( "File Directory" ) );
627 dirGroup->setFixedSize( 130, 50); 633 dirGroup->setFixedSize( 130, 50);
628 634
629 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 635 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
630 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 636 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
631 637
632 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); 638 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
633 639
634 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 640 bitGroup = new QGroupBox( tab_3, "bitGroup" );
635 bitGroup->setTitle( tr( "Bit Depth" ) ); 641 bitGroup->setTitle( tr( "Bit Depth" ) );
636 bitGroup->setFixedSize( 65, 50); 642 bitGroup->setFixedSize( 65, 50);
637 643
638 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 644 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
639 645
640 z = 0; 646 z = 0;
641 while( deviceBitRates[z] != -1) { 647 while( deviceBitRates[z] != -1) {
642 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); 648 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
643 z++; 649 z++;
644 } 650 }
645 651
646 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 652 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
647 653
648 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); 654 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
649 655
650 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); 656 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
651 657
652 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); 658 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
653 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); 659 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 );
654 660
655 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); 661 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
656 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); 662 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
657 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); 663 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
658 664
659 tab_5 = new QWidget( TabWidget, "tab_5" ); 665 tab_5 = new QWidget( TabWidget, "tab_5" );
660 666
661 QHBoxLayout *Layout19a; 667 QHBoxLayout *Layout19a;
662 Layout19a = new QHBoxLayout( tab_5); 668 Layout19a = new QHBoxLayout( tab_5);
663 Layout19a->setSpacing( 2 ); 669 Layout19a->setSpacing( 2 );
664 Layout19a->setMargin( 0 ); 670 Layout19a->setMargin( 0 );
665 671
666 Layout15 = new QVBoxLayout( this); 672 Layout15 = new QVBoxLayout( this);
667 Layout15->setSpacing( 2 ); 673 Layout15->setSpacing( 2 );
668 Layout15->setMargin( 0 ); 674 Layout15->setMargin( 0 );
669 675
670 Layout15b = new QVBoxLayout( this); 676 Layout15b = new QVBoxLayout( this);
671 Layout15b->setSpacing( 2 ); 677 Layout15b->setSpacing( 2 );
672 Layout15b->setMargin( 0 ); 678 Layout15b->setMargin( 0 );
673 679
674 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 680 TextLabel2 = new QLabel( tab_5, "InputLabel" );
675 TextLabel2->setText( tr( "In")); 681 TextLabel2->setText( tr( "In"));
676 TextLabel2->setFixedWidth( 35); 682 TextLabel2->setFixedWidth( 35);
677 Layout15->addWidget( TextLabel2 ); 683 Layout15->addWidget( TextLabel2 );
678 684
679 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 685 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
680 TextLabel3->setText( tr( "Out" ) ); 686 TextLabel3->setText( tr( "Out" ) );
681 Layout15b->addWidget( TextLabel3 ); 687 Layout15b->addWidget( TextLabel3 );
682 688
683 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 689 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
684 InputSlider->setTickmarks( QSlider::Both); 690 InputSlider->setTickmarks( QSlider::Both);
685 Layout15->addWidget( InputSlider); 691 Layout15->addWidget( InputSlider);
686 692
687 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 693 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
688 OutputSlider->setTickmarks( QSlider::Both); 694 OutputSlider->setTickmarks( QSlider::Both);
689 695
690 Layout15b->addWidget( OutputSlider ); 696 Layout15b->addWidget( OutputSlider );
691 697
692 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 698 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
693 Layout15->addWidget( outMuteCheckBox ); 699 Layout15->addWidget( outMuteCheckBox );
694 700
695 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 701 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
696 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 702 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
697 Layout15b->addWidget( inMuteCheckBox ); 703 Layout15b->addWidget( inMuteCheckBox );
698 704
699 705
700 Layout19a->addLayout( Layout15 ); 706 Layout19a->addLayout( Layout15 );
701 Layout19a->addLayout( Layout15b ); 707 Layout19a->addLayout( Layout15b );
702 708
703 fillDirectoryCombo(); 709 fillDirectoryCombo();
704 710
705 TabWidget->insertTab( tab_3, tr( "Options" ) ); 711 TabWidget->insertTab( tab_3, tr( "Options" ) );
706 712
707 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 713 TabWidget->insertTab( tab_5, tr( "Volume" ) );
708 714
709 715
710 waveform = new Waveform( this, "waveform" ); 716 waveform = new Waveform( this, "waveform" );
711// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); 717// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
712 waveform->setMinimumSize( QSize( 0, 50 ) ); 718 waveform->setMinimumSize( QSize( 0, 50 ) );
713 719
714 layout->addMultiCellWidget( waveform, 8, 8, 0, 8); 720 layout->addMultiCellWidget( waveform, 8, 8, 0, 8);
715 waveform->setBackgroundColor ( black ); 721 waveform->setBackgroundColor ( black );
716} 722}
717 723
718void QtRec::initIconView() { 724void QtRec::initIconView() {
719 725
720 ListView1->clear(); 726 ListView1->clear();
721 Config cfg("OpieRec"); 727 Config cfg("OpieRec");
722 cfg.setGroup("Sounds"); 728 cfg.setGroup("Sounds");
723 QString temp; 729 QString temp;
724 QPixmap image0( ( const char** ) image0_data ); 730 QPixmap image0( ( const char** ) image0_data );
725 731
726 int nFiles = cfg.readNumEntry("NumberofFiles",0); 732 int nFiles = cfg.readNumEntry("NumberofFiles",0);
727// odebug << "init number of files " << nFiles << "" << oendl; 733// odebug << "init number of files " << nFiles << "" << oendl;
728 734
729 for(int i=1;i<= nFiles;i++) { 735 for(int i=1;i<= nFiles;i++) {
730 736
731 QListViewItem * item; 737 QListViewItem * item;
732 QString fileS, mediaLocation, fileDate, filePath; 738 QString fileS, mediaLocation, fileDate, filePath;
733 739
734 temp.sprintf( "%d",i); 740 temp.sprintf( "%d",i);
735 temp = cfg.readEntry( temp,""); //reads currentFile 741 temp = cfg.readEntry( temp,""); //reads currentFile
736 filePath = cfg.readEntry( temp,""); //currentFileName 742 filePath = cfg.readEntry( temp,""); //currentFileName
737 743
738 QFileInfo info(filePath); 744 QFileInfo info(filePath);
739 fileDate = info.lastModified().toString(); 745 fileDate = info.lastModified().toString();
740 746
741 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 747 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
742 mediaLocation = getStorage( filePath); 748 mediaLocation = getStorage( filePath);
743 if( info.exists()) { 749 if( info.exists()) {
744 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); 750 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/);
745 item->setPixmap( 0, image0); 751 item->setPixmap( 0, image0);
746 if( currentFileName == filePath) 752 if( currentFileName == filePath)
747 ListView1->setSelected( item, true); 753 ListView1->setSelected( item, true);
748 } 754 }
749 } 755 }
750} 756}
751 757
752void QtRec::initConnections() { 758void QtRec::initConnections() {
753 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 759 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
754 760
755 connect( toBeginningButton, SIGNAL( pressed()), 761 connect( toBeginningButton, SIGNAL( pressed()),
756 this, SLOT( rewindPressed() )); 762 this, SLOT( rewindPressed() ));
757 connect( toBeginningButton, SIGNAL( released()), 763 connect( toBeginningButton, SIGNAL( released()),
758 this, SLOT( rewindReleased() )); 764 this, SLOT( rewindReleased() ));
759 connect( toEndButton, SIGNAL( pressed()), 765 connect( toEndButton, SIGNAL( pressed()),
760 this, SLOT( FastforwardPressed() )); 766 this, SLOT( FastforwardPressed() ));
761 connect( toEndButton, SIGNAL( released()), 767 connect( toEndButton, SIGNAL( released()),
762 this, SLOT( FastforwardReleased() )); 768 this, SLOT( FastforwardReleased() ));
763 connect( deleteSoundButton, SIGNAL(released()), 769 connect( deleteSoundButton, SIGNAL(released()),
764 this, SLOT( deleteSound() )); 770 this, SLOT( deleteSound() ));
765 connect( Stop_PushButton, SIGNAL(released()), 771 connect( Stop_PushButton, SIGNAL(released()),
766 this, SLOT( doPlayBtn() )); 772 this, SLOT( doPlayBtn() ));
767 connect( Rec_PushButton, SIGNAL(released()), 773 connect( Rec_PushButton, SIGNAL(released()),
768 this, SLOT( newSound() ) ); 774 this, SLOT( newSound() ) );
769 connect( TabWidget, SIGNAL( currentChanged(QWidget*)), 775 connect( TabWidget, SIGNAL( currentChanged(QWidget*)),
770 this, SLOT(thisTab(QWidget*) )); 776 this, SLOT(thisTab(QWidget*) ));
771 connect( OutputSlider, SIGNAL(sliderReleased()), 777 connect( OutputSlider, SIGNAL(sliderReleased()),
772 this, SLOT( changedOutVolume()) ); 778 this, SLOT( changedOutVolume()) );
773 connect( InputSlider, SIGNAL(sliderReleased()), 779 connect( InputSlider, SIGNAL(sliderReleased()),
774 this, SLOT( changedInVolume()) ); 780 this, SLOT( changedInVolume()) );
775 781
776 connect( sampleRateComboBox, SIGNAL(activated(int)), 782 connect( sampleRateComboBox, SIGNAL(activated(int)),
777 this, SLOT( changesamplerateCombo(int)) ); 783 this, SLOT( changesamplerateCombo(int)) );
778 connect( bitRateComboBox, SIGNAL(activated(int)), 784 connect( bitRateComboBox, SIGNAL(activated(int)),
779 this, SLOT( changebitrateCombo(int)) ); 785 this, SLOT( changebitrateCombo(int)) );
780 786
781 connect( directoryComboBox, SIGNAL(activated(int)), 787 connect( directoryComboBox, SIGNAL(activated(int)),
782 this, SLOT( changeDirCombo(int)) ); 788 this, SLOT( changeDirCombo(int)) );
783 connect( sizeLimitCombo, SIGNAL(activated(int)), 789 connect( sizeLimitCombo, SIGNAL(activated(int)),
784 this, SLOT( changeSizeLimitCombo(int)) ); 790 this, SLOT( changeSizeLimitCombo(int)) );
785 791
786 connect( stereoCheckBox, SIGNAL(toggled(bool)), 792 connect( stereoCheckBox, SIGNAL(toggled(bool)),
787 this, SLOT( changeStereoCheck(bool)) ); 793 this, SLOT( changeStereoCheck(bool)) );
788 794
789 connect( outMuteCheckBox, SIGNAL(toggled(bool)), 795 connect( outMuteCheckBox, SIGNAL(toggled(bool)),
790 this, SLOT( doVolMuting(bool)) ); 796 this, SLOT( doVolMuting(bool)) );
791 connect( inMuteCheckBox , SIGNAL(toggled(bool)), 797 connect( inMuteCheckBox , SIGNAL(toggled(bool)),
792 this, SLOT( doMicMuting(bool)) ); 798 this, SLOT( doMicMuting(bool)) );
793 799
794 connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), 800 connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)),
795 this,SLOT( itClick(QListViewItem*))); 801 this,SLOT( itClick(QListViewItem*)));
796 connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 802 connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
797 this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); 803 this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) );
798 connect( timeSlider, SIGNAL( sliderMoved(int)), 804 connect( timeSlider, SIGNAL( sliderMoved(int)),
799 this, SLOT( changeTimeSlider(int) )); 805 this, SLOT( changeTimeSlider(int) ));
800 connect( timeSlider, SIGNAL( sliderPressed()), 806 connect( timeSlider, SIGNAL( sliderPressed()),
801 this, SLOT( timeSliderPressed() )); 807 this, SLOT( timeSliderPressed() ));
802 connect( timeSlider, SIGNAL( sliderReleased()), 808 connect( timeSlider, SIGNAL( sliderReleased()),
803 this, SLOT( timeSliderReleased() )); 809 this, SLOT( timeSliderReleased() ));
804 connect( compressionCheckBox, SIGNAL( toggled(bool)), 810 connect( compressionCheckBox, SIGNAL( toggled(bool)),
805 this, SLOT( compressionSelected(bool))); 811 this, SLOT( compressionSelected(bool)));
806 connect( autoMuteCheckBox, SIGNAL( toggled(bool)), 812 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),
807 this, SLOT( slotAutoMute(bool))); 813 this, SLOT( slotAutoMute(bool)));
808} 814}
809 815
810void QtRec::initConfig() { 816void QtRec::initConfig() {
811 int index, fred, i; 817 int index, fred, i;
812 Config cfg("OpieRec"); 818 Config cfg("OpieRec");
813 cfg.setGroup("Settings"); 819 cfg.setGroup("Settings");
814 820
815 index = cfg.readNumEntry("samplerate",22050); 821 index = cfg.readNumEntry("samplerate",22050);
816 bool ok; 822 bool ok;
817 823
818 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 824 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
819 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 825 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
820 if( index == fred) { 826 if( index == fred) {
821 filePara.sampleRate = fred; 827 filePara.sampleRate = fred;
822 sampleRateComboBox->setCurrentItem(ws); 828 sampleRateComboBox->setCurrentItem(ws);
823 } 829 }
824 } 830 }
825 831
826 i = cfg.readNumEntry("bitrate",16); 832 i = cfg.readNumEntry("bitrate",16);
827 if(i == 16) 833 if(i == 16)
828 bitRateComboBox->setCurrentItem( 1); 834 bitRateComboBox->setCurrentItem( 1);
829 else if(i == 24) 835 else if(i == 24)
830 bitRateComboBox->setCurrentItem( 2); 836 bitRateComboBox->setCurrentItem( 2);
831 else if(i == 32) 837 else if(i == 32)
832 bitRateComboBox->setCurrentItem( 3); 838 bitRateComboBox->setCurrentItem( 3);
833 else 839 else
834 bitRateComboBox->setCurrentItem( 0); 840 bitRateComboBox->setCurrentItem( 0);
835 841
836 filePara.resolution = i; 842 filePara.resolution = i;
837 843
838 i = cfg.readNumEntry("sizeLimit", 5 ); 844 i = cfg.readNumEntry("sizeLimit", 5 );
839 QString temp; 845 QString temp;
840 sizeLimitCombo->setCurrentItem((i/5)); 846 sizeLimitCombo->setCurrentItem((i/5));