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