-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,1332 +1,1309 @@ | |||
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 | } |
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 |