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