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