Diffstat (limited to 'noncore/multimedia/opierec/qtrec.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 121 |
1 files changed, 87 insertions, 34 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index aeab26d..bc6abcc 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -11,312 +11,325 @@ | |||
11 | #include "waveform.h" | 11 | #include "waveform.h" |
12 | #include "device.h" | 12 | #include "device.h" |
13 | 13 | ||
14 | #include <pthread.h> | 14 | #include <pthread.h> |
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | #include "adpcm.h" | 17 | #include "adpcm.h" |
18 | } | 18 | } |
19 | 19 | ||
20 | #include <sys/soundcard.h> | 20 | #include <sys/soundcard.h> |
21 | 21 | ||
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | 27 | ||
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | //#include <qdatetime.h> | 30 | //#include <qdatetime.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qgroupbox.h> | 32 | #include <qgroupbox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qslider.h> | 39 | #include <qslider.h> |
40 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | 42 | ||
43 | #include <errno.h> | 43 | #include <errno.h> |
44 | #include <fcntl.h> | 44 | #include <fcntl.h> |
45 | #include <math.h> | 45 | #include <math.h> |
46 | #include <mntent.h> | 46 | #include <mntent.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/soundcard.h> | 50 | #include <sys/soundcard.h> |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <sys/time.h> | 52 | #include <sys/time.h> |
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #include <sys/vfs.h> | 54 | #include <sys/vfs.h> |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | #include <sys/wait.h> | 56 | #include <sys/wait.h> |
57 | #include <sys/signal.h> | 57 | #include <sys/signal.h> |
58 | 58 | ||
59 | |||
60 | #ifdef PDAUDIO //ALSA | ||
61 | #include <alsa/asoundlib.h> | ||
62 | static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; | ||
63 | static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; | ||
64 | #else //OSS | ||
65 | static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; | ||
66 | static int deviceBitRates[] = { 8, 16, -1 }; | ||
67 | #endif | ||
68 | |||
59 | #if defined(QT_QWS_SL5XXX) | 69 | #if defined(QT_QWS_SL5XXX) |
60 | ///#if defined(QT_QWS_EBX) | 70 | ///#if defined(QT_QWS_EBX) |
61 | 71 | ||
62 | #define DSPSTROUT "/dev/dsp" | 72 | #define DSPSTROUT "/dev/dsp" |
63 | #define DSPSTRIN "/dev/dsp1" | 73 | #define DSPSTRIN "/dev/dsp1" |
64 | #define DSPSTRMIXEROUT "/dev/mixer" | 74 | #define DSPSTRMIXEROUT "/dev/mixer" |
65 | #define DSPSTRMIXERIN "/dev/mixer1" | 75 | #define DSPSTRMIXERIN "/dev/mixer1" |
66 | 76 | ||
67 | #else | 77 | #else |
68 | 78 | ||
69 | #define DSPSTROUT "/dev/dsp" | 79 | #define DSPSTROUT "/dev/dsp" |
70 | #define DSPSTRIN "/dev/dsp" | 80 | #define DSPSTRIN "/dev/dsp" |
71 | #define DSPSTRMIXERIN "/dev/mixer" | 81 | #define DSPSTRMIXERIN "/dev/mixer" |
72 | #define DSPSTRMIXEROUT "/dev/mixer" | 82 | #define DSPSTRMIXEROUT "/dev/mixer" |
73 | 83 | ||
74 | #endif | 84 | #endif |
75 | 85 | ||
76 | //#define ZAURUS 0 | 86 | //#define ZAURUS 0 |
77 | struct adpcm_state encoder_state; | 87 | struct adpcm_state encoder_state; |
78 | struct adpcm_state decoder_state; | 88 | struct adpcm_state decoder_state; |
79 | 89 | ||
80 | typedef struct { | 90 | typedef struct { |
81 | int sampleRate; | 91 | int sampleRate; |
82 | /* int fragSize; */ | 92 | /* int fragSize; */ |
83 | /* int blockSize; */ | 93 | /* int blockSize; */ |
84 | int resolution; //bitrate | 94 | int resolution; //bitrate |
85 | int channels; //number of channels | 95 | int channels; //number of channels |
86 | int fd; //file descriptor | 96 | int fd; //file descriptor |
87 | int sd; //sound device descriptor | 97 | int sd; //sound device descriptor |
88 | int numberSamples; //total number of samples | 98 | int numberSamples; //total number of samples |
89 | int SecondsToRecord; // number of seconds that should be recorded | 99 | int SecondsToRecord; // number of seconds that should be recorded |
90 | float numberOfRecordedSeconds; //total number of samples recorded | 100 | float numberOfRecordedSeconds; //total number of samples recorded |
91 | int samplesToRecord; //number of samples to be recorded | 101 | int samplesToRecord; //number of samples to be recorded |
92 | int inVol; //input volume | 102 | int inVol; //input volume |
93 | int outVol; //output volume | 103 | int outVol; //output volume |
94 | int format; //wavfile format PCM.. ADPCM | 104 | int format; //wavfile format PCM.. ADPCM |
95 | const char *fileName; //name of fiel to be played/recorded | 105 | const char *fileName; //name of fiel to be played/recorded |
96 | } fileParameters; | 106 | } fileParameters; |
97 | 107 | ||
98 | fileParameters filePara; | 108 | fileParameters filePara; |
99 | 109 | ||
100 | bool monitoring, recording, playing; | 110 | bool monitoring, recording, playing; |
101 | bool stopped; | 111 | bool stopped; |
102 | QLabel *timeLabel; | 112 | QLabel *timeLabel; |
103 | QSlider *timeSlider; | 113 | QSlider *timeSlider; |
104 | int sd; | 114 | int sd; |
105 | 115 | ||
106 | Waveform* waveform; | 116 | Waveform* waveform; |
107 | Device *soundDevice; | 117 | Device *soundDevice; |
108 | 118 | ||
109 | // threaded recording | 119 | // threaded recording |
110 | //fuckin fulgy here | 120 | //fuckin fulgy here |
111 | void quickRec() | 121 | //void quickRec() |
112 | { | 122 | //{ |
113 | //void QtRec::quickRec() { | 123 | void QtRec::quickRec() { |
114 | 124 | ||
115 | qDebug("%d", | 125 | qDebug("%d", |
116 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | 126 | filePara.numberSamples/filePara.sampleRate * filePara.channels); |
117 | qDebug("samples %d, rate %d, channels %d", | 127 | qDebug("samples %d, rate %d, channels %d", |
118 | filePara.numberSamples, filePara.sampleRate, filePara.channels); | 128 | filePara.numberSamples, filePara.sampleRate, filePara.channels); |
119 | 129 | ||
120 | int total = 0; // Total number of bytes read in so far. | 130 | int total = 0; // Total number of bytes read in so far. |
121 | int bytesWritten, number; | 131 | int bytesWritten, number; |
122 | 132 | ||
123 | bytesWritten = 0; | 133 | bytesWritten = 0; |
124 | number = 0; | 134 | number = 0; |
125 | QString num; | 135 | QString num; |
126 | int level = 0; | 136 | int level = 0; |
127 | int threshold = 0; | 137 | int threshold = 0; |
128 | // int bits = filePara.resolution; | 138 | // int bits = filePara.resolution; |
129 | // qDebug("bits %d", bits); | 139 | // qDebug("bits %d", bits); |
130 | 140 | ||
131 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 141 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
132 | // qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); | 142 | // qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); |
133 | // qDebug("samples to record %d", filePara.samplesToRecord); | 143 | // qDebug("samples to record %d", filePara.samplesToRecord); |
134 | // qDebug("%d", filePara.sd); | 144 | // qDebug("%d", filePara.sd); |
135 | level = 7; | 145 | level = 7; |
136 | threshold = 0; | 146 | threshold = 0; |
137 | 147 | ||
138 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 148 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
139 | // qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); | 149 | // qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); |
140 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 150 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
141 | char abuf[ BUFSIZE/2 ]; | 151 | char abuf[ BUFSIZE/2 ]; |
142 | short sbuf[ BUFSIZE ]; | 152 | short sbuf[ BUFSIZE ]; |
143 | short sbuf2[ BUFSIZE ]; | 153 | short sbuf2[ BUFSIZE ]; |
144 | memset( abuf, 0, BUFSIZE/2); | 154 | memset( abuf, 0, BUFSIZE/2); |
145 | memset( sbuf, 0, BUFSIZE); | 155 | memset( sbuf, 0, BUFSIZE); |
146 | memset( sbuf2, 0, BUFSIZE); | 156 | memset( sbuf2, 0, BUFSIZE); |
147 | 157 | ||
148 | for(;;) { | 158 | for(;;) { |
149 | if ( stopped) { | 159 | if ( stopped) { |
150 | qDebug("quickRec:: stopped"); | 160 | qDebug("quickRec:: stopped"); |
151 | break; | 161 | break; |
152 | } | 162 | } |
153 | 163 | ||
154 | // number=::read( filePara.sd, sbuf, BUFSIZE); | 164 | // number=::read( filePara.sd, sbuf, BUFSIZE); |
155 | number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); | 165 | number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); |
156 | 166 | ||
157 | if(number <= 0) { | 167 | if(number <= 0) { |
158 | perror("recording error "); | 168 | perror("recording error "); |
159 | qDebug( "%s %d", filePara.fileName, number); | 169 | qDebug( "%s %d", filePara.fileName, number); |
160 | stopped = true; | 170 | stopped = true; |
161 | return; | 171 | return; |
162 | } | 172 | } |
163 | //if(stereo == 2) { | 173 | //if(stereo == 2) { |
164 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 174 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
165 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 175 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
166 | bytesWritten = soundDevice->devWrite( filePara.fd , (short *)abuf, number/4); | 176 | |
167 | waveform->newSamples( (const short *)abuf, bytesWritten ); | 177 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); |
178 | |||
179 | waveform->newSamples( (const short *)abuf, bytesWritten ); | ||
168 | 180 | ||
169 | total += bytesWritten; | 181 | total += bytesWritten; |
170 | filePara.numberSamples = total; | 182 | filePara.numberSamples = total; |
171 | timeSlider->setValue( total); | 183 | timeSlider->setValue( total); |
172 | 184 | ||
173 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; | 185 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; |
174 | 186 | ||
175 | qApp->processEvents(); | 187 | qApp->processEvents(); |
176 | if( total >= filePara.samplesToRecord) { | 188 | if( total >= filePara.samplesToRecord) { |
177 | stopped = true; | 189 | stopped = true; |
178 | break; | 190 | break; |
179 | } | 191 | } |
180 | } | 192 | } |
181 | } else { | 193 | } else { |
182 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 194 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> |
183 | qDebug("start recording WAVE_FORMAT_PCM"); | 195 | qDebug("start recording WAVE_FORMAT_PCM"); |
184 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; | 196 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; |
185 | memset( inbuffer, 0, BUFSIZE); | 197 | memset( inbuffer, 0, BUFSIZE); |
186 | memset( outbuffer, 0, BUFSIZE); | 198 | memset( outbuffer, 0, BUFSIZE); |
187 | 199 | ||
188 | for(;;) { | 200 | for(;;) { |
189 | if ( stopped) { | 201 | if ( stopped) { |
190 | qDebug("quickRec:: stopped"); | 202 | qDebug("quickRec:: stopped"); |
191 | stopped = true; | 203 | stopped = true; |
192 | break; // stop if playing was set to false | 204 | break; // stop if playing was set to false |
193 | return; | 205 | return; |
194 | } | 206 | } |
195 | 207 | ||
196 | number = soundDevice ->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); | 208 | number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); |
197 | waveform->newSamples( inbuffer, number ); | 209 | waveform->newSamples( inbuffer, number ); |
198 | 210 | ||
199 | if( number <= 0) { | 211 | if( number <= 0) { |
200 | perror( "recording error "); | 212 | perror( "recording error "); |
201 | qDebug( filePara.fileName); | 213 | qDebug( filePara.fileName); |
202 | stopped = true; | 214 | stopped = true; |
203 | return; | 215 | return; |
204 | } | 216 | } |
205 | 217 | ||
206 | bytesWritten = soundDevice->devWrite( filePara.fd , inbuffer, number); | 218 | bytesWritten = ::write( filePara.fd , inbuffer, number); |
207 | 219 | ||
208 | if( bytesWritten < 0) { | 220 | if( bytesWritten < 0) { |
209 | perror("File writing error "); | 221 | perror("File writing error "); |
210 | stopped = true; | 222 | stopped = true; |
211 | return; | 223 | return; |
212 | } | 224 | } |
213 | 225 | ||
214 | total += bytesWritten; | 226 | total += bytesWritten; |
215 | 227 | ||
216 | filePara.numberSamples = total; | 228 | filePara.numberSamples = total; |
217 | 229 | ||
218 | if( filePara.SecondsToRecord != 0) | 230 | if( filePara.SecondsToRecord != 0) |
219 | timeSlider->setValue( total); | 231 | timeSlider->setValue( total); |
220 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); | 232 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); |
221 | // fflush(stdout); | 233 | // fflush(stdout); |
222 | 234 | ||
223 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; | 235 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; |
224 | 236 | ||
225 | qApp->processEvents(); | 237 | qApp->processEvents(); |
226 | 238 | ||
227 | if( total >= filePara.samplesToRecord) { | 239 | if( total >= filePara.samplesToRecord) { |
228 | stopped = true; | 240 | stopped = true; |
229 | break; | 241 | break; |
230 | } | 242 | } |
231 | } | 243 | } |
232 | } //end main loop | 244 | } //end main loop |
233 | 245 | ||
234 | } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; | 246 | } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; |
235 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; | 247 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; |
236 | memset( unsigned_inbuffer, 0, BUFSIZE); | 248 | memset( unsigned_inbuffer, 0, BUFSIZE); |
237 | memset( unsigned_outbuffer, 0, BUFSIZE); | 249 | memset( unsigned_outbuffer, 0, BUFSIZE); |
238 | 250 | ||
239 | for(;;) { | 251 | for(;;) { |
240 | if ( stopped) { | 252 | if ( stopped) { |
241 | qDebug("quickRec:: stopped"); | 253 | qDebug("quickRec:: stopped"); |
242 | break; // stop if playing was set to false | 254 | break; // stop if playing was set to false |
243 | } | 255 | } |
244 | 256 | ||
245 | number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); | 257 | number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); |
246 | bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); | 258 | bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); |
247 | 259 | ||
248 | if(bytesWritten < 0) { | 260 | if(bytesWritten < 0) { |
249 | stopped = true; | 261 | stopped = true; |
250 | QMessageBox::message("Note","There was a problem\nwriting to the file"); | 262 | QMessageBox::message("Note","There was a problem\nwriting to the file"); |
251 | perror("File writing error "); | 263 | perror("File writing error "); |
252 | return; | 264 | return; |
253 | } | 265 | } |
254 | 266 | ||
255 | total += bytesWritten; | 267 | total += bytesWritten; |
256 | filePara.numberSamples = total; | 268 | filePara.numberSamples = total; |
257 | // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); | 269 | // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); |
258 | // fflush(stdout); | 270 | // fflush(stdout); |
259 | if( filePara.SecondsToRecord !=0) | 271 | if( filePara.SecondsToRecord !=0) |
260 | timeSlider->setValue( total); | 272 | timeSlider->setValue( total); |
261 | 273 | ||
262 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; | 274 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; |
263 | 275 | ||
264 | qApp->processEvents(); | 276 | qApp->processEvents(); |
265 | if( total >= filePara.samplesToRecord) { | 277 | if( total >= filePara.samplesToRecord) { |
266 | stopped = true; | 278 | stopped = true; |
267 | break; | 279 | break; |
268 | } | 280 | } |
269 | } //end main loop | 281 | } //end main loop |
270 | } | 282 | } |
271 | } /// END quickRec() | 283 | } /// END quickRec() |
272 | 284 | ||
285 | void QtRec::playIt() | ||
273 | 286 | ||
274 | void playIt() | 287 | //void playIt() |
275 | { | 288 | { |
276 | int bytesWritten, number; | 289 | int bytesWritten, number; |
277 | int total = 0; // Total number of bytes read in so far. | 290 | int total = 0; // Total number of bytes read in so far. |
278 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { | 291 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { |
279 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 292 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
280 | char abuf[ BUFSIZE / 2 ]; | 293 | char abuf[ BUFSIZE / 2 ]; |
281 | short sbuf[ BUFSIZE ]; | 294 | short sbuf[ BUFSIZE ]; |
282 | short sbuf2[ BUFSIZE * 2 ]; | 295 | short sbuf2[ BUFSIZE * 2 ]; |
283 | memset( abuf, 0, BUFSIZE / 2); | 296 | memset( abuf, 0, BUFSIZE / 2); |
284 | memset( sbuf, 0, BUFSIZE); | 297 | memset( sbuf, 0, BUFSIZE); |
285 | memset( sbuf2, 0, BUFSIZE * 2); | 298 | memset( sbuf2, 0, BUFSIZE * 2); |
286 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 299 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
287 | for(;;) { // play loop | 300 | for(;;) { // play loop |
288 | if ( stopped) { | 301 | if ( stopped) { |
289 | break; | 302 | break; |
290 | return; | 303 | return; |
291 | }// stop if playing was set to false | 304 | }// stop if playing was set to false |
292 | 305 | ||
293 | number = ::read( filePara.fd, abuf, BUFSIZE / 2); | 306 | number = ::read( filePara.fd, abuf, BUFSIZE / 2); |
294 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); | 307 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); |
295 | 308 | ||
296 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 309 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
297 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; | 310 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; |
298 | // } | 311 | // } |
299 | bytesWritten = write ( filePara.sd, sbuf, number * 4); | 312 | bytesWritten = write ( filePara.sd, sbuf, number * 4); |
300 | waveform->newSamples( (const short *)sbuf, number ); | 313 | waveform->newSamples( (const short *)sbuf, number ); |
301 | // if(filePara.channels==1) | 314 | // if(filePara.channels==1) |
302 | // total += bytesWritten/2; //mono | 315 | // total += bytesWritten/2; //mono |
303 | // else | 316 | // else |
304 | total += bytesWritten; | 317 | total += bytesWritten; |
305 | filePara.numberSamples = total/4; | 318 | filePara.numberSamples = total/4; |
306 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; | 319 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; |
307 | 320 | ||
308 | timeSlider->setValue( total/4); | 321 | timeSlider->setValue( total/4); |
309 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 322 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
310 | // if(filePara.numberOfRecordedSeconds>1) | 323 | // if(filePara.numberOfRecordedSeconds>1) |
311 | // timeLabel->setText( timeString+ tr(" seconds")); | 324 | // timeLabel->setText( timeString+ tr(" seconds")); |
312 | printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); | 325 | printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); |
313 | fflush(stdout); | 326 | fflush(stdout); |
314 | 327 | ||
315 | qApp->processEvents(); | 328 | qApp->processEvents(); |
316 | 329 | ||
317 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 330 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
318 | // if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { | 331 | // if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { |
319 | stopped = true; | 332 | stopped = true; |
320 | break; | 333 | break; |
321 | } | 334 | } |
322 | } | 335 | } |
@@ -524,139 +537,142 @@ void QtRec::init() { | |||
524 | 537 | ||
525 | rewindTimer = new QTimer( this ); | 538 | rewindTimer = new QTimer( this ); |
526 | connect( rewindTimer, SIGNAL( timeout() ), | 539 | connect( rewindTimer, SIGNAL( timeout() ), |
527 | this, SLOT( rewindTimerTimeout() ) ); | 540 | this, SLOT( rewindTimerTimeout() ) ); |
528 | 541 | ||
529 | forwardTimer = new QTimer( this ); | 542 | forwardTimer = new QTimer( this ); |
530 | connect( forwardTimer, SIGNAL( timeout() ), | 543 | connect( forwardTimer, SIGNAL( timeout() ), |
531 | this, SLOT( forwardTimerTimeout() ) ); | 544 | this, SLOT( forwardTimerTimeout() ) ); |
532 | 545 | ||
533 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); | 546 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); |
534 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); | 547 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); |
535 | deleteSoundButton->setText( tr( "Delete" ) ); | 548 | deleteSoundButton->setText( tr( "Delete" ) ); |
536 | 549 | ||
537 | ListView1 = new QListView( tab, "IconView1" ); | 550 | ListView1 = new QListView( tab, "IconView1" ); |
538 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); | 551 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); |
539 | 552 | ||
540 | ListView1->addColumn( tr( "Name" ) ); | 553 | ListView1->addColumn( tr( "Name" ) ); |
541 | ListView1->setColumnWidth( 0, 140); | 554 | ListView1->setColumnWidth( 0, 140); |
542 | ListView1->setSorting( 1, false); | 555 | ListView1->setSorting( 1, false); |
543 | ListView1->addColumn( tr( "Time" ) ); //in seconds | 556 | ListView1->addColumn( tr( "Time" ) ); //in seconds |
544 | ListView1->setColumnWidth( 1, 50); | 557 | ListView1->setColumnWidth( 1, 50); |
545 | ListView1->addColumn( tr("Location") ); | 558 | ListView1->addColumn( tr("Location") ); |
546 | ListView1->setColumnWidth( 2, 50); | 559 | ListView1->setColumnWidth( 2, 50); |
547 | ListView1->addColumn( tr("Date") ); | 560 | ListView1->addColumn( tr("Date") ); |
548 | ListView1->setColumnWidth( 3, 63); | 561 | ListView1->setColumnWidth( 3, 63); |
549 | 562 | ||
550 | ListView1->setColumnWidthMode( 0, QListView::Manual); | 563 | ListView1->setColumnWidthMode( 0, QListView::Manual); |
551 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); | 564 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); |
552 | ListView1->setColumnAlignment( 2, QListView::AlignRight); | 565 | ListView1->setColumnAlignment( 2, QListView::AlignRight); |
553 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); | 566 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); |
554 | ListView1->setAllColumnsShowFocus( true ); | 567 | ListView1->setAllColumnsShowFocus( true ); |
555 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); | 568 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); |
556 | 569 | ||
557 | TabWidget->insertTab( tab, tr( "Files" ) ); | 570 | TabWidget->insertTab( tab, tr( "Files" ) ); |
558 | 571 | ||
559 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 572 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
560 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 573 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
561 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); | 574 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); |
562 | glayout3->setSpacing( 2); | 575 | glayout3->setSpacing( 2); |
563 | glayout3->setMargin( 2); | 576 | glayout3->setMargin( 2); |
564 | //////////////////////////////////// | 577 | //////////////////////////////////// |
565 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 578 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
566 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 579 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
567 | sampleGroup->setFixedSize( 95,50); | 580 | sampleGroup->setFixedSize( 95,50); |
568 | 581 | ||
569 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 582 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
570 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 583 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
571 | //#ifndef QT_QWS_EBX | 584 | //#ifndef QT_QWS_EBX |
572 | sampleRateComboBox->insertItem( tr( "44100")); | 585 | QString s; |
573 | sampleRateComboBox->insertItem( tr( "32000")); | 586 | int z = 0; |
574 | //#endif | 587 | while( deviceSampleRates[z] != -1) { |
575 | sampleRateComboBox->insertItem( tr( "22050")); | 588 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); |
576 | //#ifndef QT_QWS_VERCEL_IDR | 589 | z++; |
577 | sampleRateComboBox->insertItem( tr( "16000")); | 590 | } |
578 | sampleRateComboBox->insertItem( tr( "11025")); | 591 | |
579 | sampleRateComboBox->insertItem( tr( "8000")); | ||
580 | //#endif | ||
581 | 592 | ||
582 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); | 593 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); |
583 | 594 | ||
584 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 595 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
585 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 596 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
586 | sizeGroup->setFixedSize( 80, 50); | 597 | sizeGroup->setFixedSize( 80, 50); |
587 | 598 | ||
588 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 599 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
589 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); | 600 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); |
590 | sizeLimitCombo->insertItem(tr("Unlimited")); | 601 | sizeLimitCombo->insertItem(tr("Unlimited")); |
591 | 602 | ||
592 | for(int i=1;i<13; i++) { | 603 | for(int i=1;i<13; i++) { |
593 | sizeLimitCombo->insertItem( QString::number( i * 5)); | 604 | sizeLimitCombo->insertItem( QString::number( i * 5)); |
594 | } | 605 | } |
595 | 606 | ||
596 | 607 | ||
597 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); | 608 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); |
598 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); | 609 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); |
599 | dirGroup->setTitle( tr( "File Directory" ) ); | 610 | dirGroup->setTitle( tr( "File Directory" ) ); |
600 | dirGroup->setFixedSize( 130, 50); | 611 | dirGroup->setFixedSize( 130, 50); |
601 | 612 | ||
602 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); | 613 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); |
603 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); | 614 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); |
604 | 615 | ||
605 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); | 616 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); |
606 | 617 | ||
607 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); | 618 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); |
608 | bitGroup->setTitle( tr( "Bit Depth" ) ); | 619 | bitGroup->setTitle( tr( "Bit Depth" ) ); |
609 | bitGroup->setFixedSize( 65, 50); | 620 | bitGroup->setFixedSize( 65, 50); |
610 | 621 | ||
611 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); | 622 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); |
612 | bitRateComboBox->insertItem( tr( "16" ) ); | 623 | |
613 | bitRateComboBox->insertItem( tr( "8" ) ); | 624 | z = 0; |
614 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | 625 | while( deviceBitRates[z] != -1) { |
626 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); | ||
627 | z++; | ||
628 | } | ||
629 | |||
630 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | ||
615 | 631 | ||
616 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); | 632 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); |
617 | 633 | ||
618 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); | 634 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); |
619 | 635 | ||
620 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); | 636 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); |
621 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); | 637 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); |
622 | 638 | ||
623 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); | 639 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); |
624 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); | 640 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); |
625 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); | 641 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); |
626 | 642 | ||
627 | QWidget *d = QApplication::desktop(); | 643 | QWidget *d = QApplication::desktop(); |
628 | int width = d->width(); | 644 | int width = d->width(); |
629 | int height = d->height(); | 645 | int height = d->height(); |
630 | 646 | ||
631 | if( width < height) { | 647 | if( width < height) { |
632 | 648 | ||
633 | tab_5 = new QWidget( TabWidget, "tab_5" ); | 649 | tab_5 = new QWidget( TabWidget, "tab_5" ); |
634 | 650 | ||
635 | QHBoxLayout *Layout19a; | 651 | QHBoxLayout *Layout19a; |
636 | Layout19a = new QHBoxLayout( tab_5); | 652 | Layout19a = new QHBoxLayout( tab_5); |
637 | Layout19a->setSpacing( 2 ); | 653 | Layout19a->setSpacing( 2 ); |
638 | Layout19a->setMargin( 0 ); | 654 | Layout19a->setMargin( 0 ); |
639 | 655 | ||
640 | Layout15 = new QVBoxLayout( this); | 656 | Layout15 = new QVBoxLayout( this); |
641 | Layout15->setSpacing( 2 ); | 657 | Layout15->setSpacing( 2 ); |
642 | Layout15->setMargin( 0 ); | 658 | Layout15->setMargin( 0 ); |
643 | 659 | ||
644 | Layout15b = new QVBoxLayout( this); | 660 | Layout15b = new QVBoxLayout( this); |
645 | Layout15b->setSpacing( 2 ); | 661 | Layout15b->setSpacing( 2 ); |
646 | Layout15b->setMargin( 0 ); | 662 | Layout15b->setMargin( 0 ); |
647 | 663 | ||
648 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); | 664 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); |
649 | TextLabel2->setText( tr( "In")); | 665 | TextLabel2->setText( tr( "In")); |
650 | TextLabel2->setFixedWidth( 35); | 666 | TextLabel2->setFixedWidth( 35); |
651 | Layout15->addWidget( TextLabel2 ); | 667 | Layout15->addWidget( TextLabel2 ); |
652 | 668 | ||
653 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); | 669 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); |
654 | TextLabel3->setText( tr( "Out" ) ); | 670 | TextLabel3->setText( tr( "Out" ) ); |
655 | Layout15b->addWidget( TextLabel3 ); | 671 | Layout15b->addWidget( TextLabel3 ); |
656 | 672 | ||
657 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); | 673 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); |
658 | InputSlider->setTickmarks( QSlider::Both); | 674 | InputSlider->setTickmarks( QSlider::Both); |
659 | Layout15->addWidget( InputSlider); | 675 | Layout15->addWidget( InputSlider); |
660 | 676 | ||
661 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); | 677 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); |
662 | OutputSlider->setTickmarks( QSlider::Both); | 678 | OutputSlider->setTickmarks( QSlider::Both); |
@@ -799,100 +815,105 @@ void QtRec::initConnections() { | |||
799 | this, SLOT( changebitrateCombo(int)) ); | 815 | this, SLOT( changebitrateCombo(int)) ); |
800 | 816 | ||
801 | connect( directoryComboBox, SIGNAL(activated( int)), | 817 | connect( directoryComboBox, SIGNAL(activated( int)), |
802 | this, SLOT( changeDirCombo(int)) ); | 818 | this, SLOT( changeDirCombo(int)) ); |
803 | connect( sizeLimitCombo, SIGNAL(activated( int)), | 819 | connect( sizeLimitCombo, SIGNAL(activated( int)), |
804 | this, SLOT( changeSizeLimitCombo(int)) ); | 820 | this, SLOT( changeSizeLimitCombo(int)) ); |
805 | 821 | ||
806 | connect( stereoCheckBox, SIGNAL(toggled( bool)), | 822 | connect( stereoCheckBox, SIGNAL(toggled( bool)), |
807 | this, SLOT( changeStereoCheck(bool)) ); | 823 | this, SLOT( changeStereoCheck(bool)) ); |
808 | 824 | ||
809 | connect( outMuteCheckBox, SIGNAL(toggled( bool)), | 825 | connect( outMuteCheckBox, SIGNAL(toggled( bool)), |
810 | this, SLOT( doVolMuting(bool)) ); | 826 | this, SLOT( doVolMuting(bool)) ); |
811 | connect( inMuteCheckBox , SIGNAL(toggled( bool)), | 827 | connect( inMuteCheckBox , SIGNAL(toggled( bool)), |
812 | this, SLOT( doMicMuting(bool)) ); | 828 | this, SLOT( doMicMuting(bool)) ); |
813 | 829 | ||
814 | connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)), | 830 | connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)), |
815 | this,SLOT( itClick(QListViewItem*))); | 831 | this,SLOT( itClick(QListViewItem*))); |
816 | connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 832 | connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
817 | this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); | 833 | this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); |
818 | connect( timeSlider, SIGNAL( sliderMoved( int)), | 834 | connect( timeSlider, SIGNAL( sliderMoved( int)), |
819 | this, SLOT( changeTimeSlider(int) )); | 835 | this, SLOT( changeTimeSlider(int) )); |
820 | connect( timeSlider, SIGNAL( sliderPressed( )), | 836 | connect( timeSlider, SIGNAL( sliderPressed( )), |
821 | this, SLOT( timeSliderPressed() )); | 837 | this, SLOT( timeSliderPressed() )); |
822 | connect( timeSlider, SIGNAL( sliderReleased( )), | 838 | connect( timeSlider, SIGNAL( sliderReleased( )), |
823 | this, SLOT( timeSliderReleased() )); | 839 | this, SLOT( timeSliderReleased() )); |
824 | connect( compressionCheckBox, SIGNAL( toggled(bool)), | 840 | connect( compressionCheckBox, SIGNAL( toggled(bool)), |
825 | this, SLOT( compressionSelected(bool))); | 841 | this, SLOT( compressionSelected(bool))); |
826 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), | 842 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), |
827 | this, SLOT( slotAutoMute(bool))); | 843 | this, SLOT( slotAutoMute(bool))); |
828 | } | 844 | } |
829 | 845 | ||
830 | void QtRec::initConfig() { | 846 | void QtRec::initConfig() { |
831 | int index, fred, i; | 847 | int index, fred, i; |
832 | Config cfg("OpieRec"); | 848 | Config cfg("OpieRec"); |
833 | cfg.setGroup("Settings"); | 849 | cfg.setGroup("Settings"); |
834 | 850 | ||
835 | index = cfg.readNumEntry("samplerate",22050); | 851 | index = cfg.readNumEntry("samplerate",22050); |
836 | bool ok; | 852 | bool ok; |
837 | 853 | ||
838 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { | 854 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { |
839 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 855 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
840 | if( index == fred) { | 856 | if( index == fred) { |
841 | filePara.sampleRate = fred; | 857 | filePara.sampleRate = fred; |
842 | sampleRateComboBox->setCurrentItem(ws); | 858 | sampleRateComboBox->setCurrentItem(ws); |
843 | } | 859 | } |
844 | } | 860 | } |
845 | 861 | ||
846 | i = cfg.readNumEntry("bitrate",16); | 862 | i = cfg.readNumEntry("bitrate",16); |
847 | if(i == 16) | 863 | if(i == 16) |
848 | bitRateComboBox->setCurrentItem( 0); | 864 | bitRateComboBox->setCurrentItem( 1); |
849 | else | 865 | elseif(i == 24) |
850 | bitRateComboBox->setCurrentItem( 1); | 866 | bitRateComboBox->setCurrentItem( 2); |
867 | elseif(i == 32) | ||
868 | bitRateComboBox->setCurrentItem( 3); | ||
869 | else | ||
870 | bitRateComboBox->setCurrentItem( 0); | ||
871 | |||
851 | filePara.resolution = i; | 872 | filePara.resolution = i; |
852 | 873 | ||
853 | i = cfg.readNumEntry("sizeLimit", 5 ); | 874 | i = cfg.readNumEntry("sizeLimit", 5 ); |
854 | QString temp; | 875 | QString temp; |
855 | sizeLimitCombo->setCurrentItem((i/5)); | 876 | sizeLimitCombo->setCurrentItem((i/5)); |
856 | 877 | ||
857 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 878 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
858 | if( stereoCheckBox->isChecked()) { | 879 | if( stereoCheckBox->isChecked()) { |
859 | filePara.channels = 2; | 880 | filePara.channels = 2; |
860 | } else { | 881 | } else { |
861 | filePara.channels = 1; | 882 | filePara.channels = 1; |
862 | } | 883 | } |
863 | 884 | ||
864 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 885 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
865 | if( compressionCheckBox->isChecked()) { | 886 | if( compressionCheckBox->isChecked()) { |
866 | bitRateComboBox->setEnabled(false); | 887 | bitRateComboBox->setEnabled(false); |
867 | bitRateComboBox->setCurrentItem(0); | 888 | bitRateComboBox->setCurrentItem(0); |
868 | filePara.resolution=16; | 889 | filePara.resolution=16; |
869 | } | 890 | } |
870 | 891 | ||
871 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 892 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
872 | if( autoMuteCheckBox->isChecked()) | 893 | if( autoMuteCheckBox->isChecked()) |
873 | slotAutoMute(true); | 894 | slotAutoMute(true); |
874 | else | 895 | else |
875 | slotAutoMute(false); | 896 | slotAutoMute(false); |
876 | 897 | ||
877 | Config cofg( "qpe"); | 898 | Config cofg( "qpe"); |
878 | cofg.setGroup( "Volume"); | 899 | cofg.setGroup( "Volume"); |
879 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 900 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
880 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 901 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
881 | } | 902 | } |
882 | 903 | ||
883 | void QtRec::stop() { | 904 | void QtRec::stop() { |
884 | qWarning("STOP"); | 905 | qWarning("STOP"); |
885 | setRecordButton(false); | 906 | setRecordButton(false); |
886 | 907 | ||
887 | if( !recording) | 908 | if( !recording) |
888 | endPlaying(); | 909 | endPlaying(); |
889 | else | 910 | else |
890 | endRecording(); | 911 | endRecording(); |
891 | timeSlider->setValue(0); | 912 | timeSlider->setValue(0); |
892 | } | 913 | } |
893 | 914 | ||
894 | void QtRec::doPlayBtn() { | 915 | void QtRec::doPlayBtn() { |
895 | 916 | ||
896 | if(!stopped) { | 917 | if(!stopped) { |
897 | playLabel2->setText(tr("Play")); | 918 | playLabel2->setText(tr("Play")); |
898 | stop(); | 919 | stop(); |
@@ -945,190 +966,219 @@ bool QtRec::rec() { //record | |||
945 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 966 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
946 | // qDebug("sample rate is %d", filePara.sampleRate); | 967 | // qDebug("sample rate is %d", filePara.sampleRate); |
947 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 968 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
948 | 969 | ||
949 | // qDebug("size limit %d sec", filePara.SecondsToRecord); | 970 | // qDebug("size limit %d sec", filePara.SecondsToRecord); |
950 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 971 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
951 | 972 | ||
952 | if( filePara.SecondsToRecord == 0) { | 973 | if( filePara.SecondsToRecord == 0) { |
953 | fileSize = diskSize; | 974 | fileSize = diskSize; |
954 | } else if( filePara.format == WAVE_FORMAT_PCM) { | 975 | } else if( filePara.format == WAVE_FORMAT_PCM) { |
955 | // qDebug("WAVE_FORMAT_PCM"); | 976 | // qDebug("WAVE_FORMAT_PCM"); |
956 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 977 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
957 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; | 978 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; |
958 | } else { | 979 | } else { |
959 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 980 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
960 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 981 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
961 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; | 982 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; |
962 | } | 983 | } |
963 | 984 | ||
964 | filePara.samplesToRecord = fileSize; | 985 | filePara.samplesToRecord = fileSize; |
965 | qDebug("filesize should be %d, bits %d, rate %d", | 986 | qDebug("filesize should be %d, bits %d, rate %d", |
966 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); | 987 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); |
967 | if( paused) { | 988 | if( paused) { |
968 | paused = false; | 989 | paused = false; |
969 | } | 990 | } |
970 | // else { | 991 | // else { |
971 | qDebug("Setting timeslider %d", filePara.samplesToRecord); | 992 | qDebug("Setting timeslider %d", filePara.samplesToRecord); |
972 | // if(fileSize != 0) | 993 | // if(fileSize != 0) |
973 | timeSlider->setRange(0, filePara.samplesToRecord); | 994 | timeSlider->setRange(0, filePara.samplesToRecord); |
974 | // } | 995 | // } |
975 | 996 | ||
976 | if( diskSize < fileSize/1024) { | 997 | if( diskSize < fileSize/1024) { |
977 | QMessageBox::warning(this, | 998 | QMessageBox::warning(this, |
978 | tr("Low Disk Space"), | 999 | tr("Low Disk Space"), |
979 | tr("You are running low of\nrecording space\n" | 1000 | tr("You are running low of\nrecording space\n" |
980 | "or a card isn't being recognized")); | 1001 | "or a card isn't being recognized")); |
981 | stopped = true; //we need to be stopped | 1002 | stopped = true; //we need to be stopped |
982 | stop(); | 1003 | stop(); |
983 | } else { | 1004 | } else { |
984 | QString msg; | 1005 | QString msg; |
985 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1006 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
986 | #ifdef DEV_VERSION | 1007 | #ifdef DEV_VERSION |
987 | setCaption( msg); | 1008 | setCaption( msg); |
988 | #endif | 1009 | #endif |
989 | filePara.fileName=currentFile.latin1(); | 1010 | filePara.fileName=currentFile.latin1(); |
990 | // qDebug("Start recording thread"); | 1011 | // qDebug("Start recording thread"); |
991 | stopped = false; | 1012 | stopped = false; |
992 | 1013 | ||
993 | pthread_t thread1; | 1014 | // pthread_t thread1; |
994 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 1015 | // pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
995 | toBeginningButton->setEnabled( false); | 1016 | toBeginningButton->setEnabled( false); |
996 | toEndButton->setEnabled( false); | 1017 | toEndButton->setEnabled( false); |
997 | 1018 | ||
998 | startTimer(1000); | 1019 | startTimer(1000); |
999 | // quickRec(); | 1020 | quickRec(); |
1000 | } | 1021 | } |
1001 | } //end setUpFile | 1022 | } //end setUpFile |
1002 | } //end setupAudio | 1023 | } //end setupAudio |
1003 | return true; | 1024 | return true; |
1004 | } | 1025 | } |
1005 | /* | 1026 | /* |
1006 | This happens when a tab is selected*/ | 1027 | This happens when a tab is selected*/ |
1007 | void QtRec::thisTab(QWidget* widg) { | 1028 | void QtRec::thisTab(QWidget* widg) { |
1008 | if(widg != NULL) { | 1029 | if(widg != NULL) { |
1009 | int index = TabWidget->currentPageIndex(); | 1030 | int index = TabWidget->currentPageIndex(); |
1010 | 1031 | ||
1011 | if(index == 0) { //file page | 1032 | if(index == 0) { //file page |
1012 | } | 1033 | } |
1013 | 1034 | ||
1014 | if(index == 1) { //control page | 1035 | if(index == 1) { //control page |
1015 | fillDirectoryCombo(); | 1036 | fillDirectoryCombo(); |
1016 | // soundDevice->getOutVol(); | 1037 | // soundDevice->getOutVol(); |
1017 | // soundDevice->getInVol(); | 1038 | // soundDevice->getInVol(); |
1018 | } | 1039 | } |
1019 | 1040 | ||
1020 | if( index==2) { //help page | 1041 | if( index==2) { //help page |
1021 | } | 1042 | } |
1022 | 1043 | ||
1023 | qApp->processEvents(); | 1044 | qApp->processEvents(); |
1024 | update(); | 1045 | update(); |
1025 | } | 1046 | } |
1026 | } | 1047 | } |
1027 | 1048 | ||
1028 | void QtRec::getOutVol( ) { | 1049 | void QtRec::getOutVol( ) { |
1029 | filePara.outVol = soundDevice->getOutVolume(); | 1050 | filePara.outVol = soundDevice->getOutVolume(); |
1030 | // qDebug("out vol %d", filePara.outVol); | 1051 | // qDebug("out vol %d", filePara.outVol); |
1031 | OutputSlider->setValue( -filePara.outVol); | 1052 | OutputSlider->setValue( -filePara.outVol); |
1032 | } | 1053 | } |
1033 | 1054 | ||
1034 | void QtRec::getInVol() { | 1055 | void QtRec::getInVol() { |
1035 | filePara.inVol = soundDevice->getInVolume(); | 1056 | filePara.inVol = soundDevice->getInVolume(); |
1036 | // qDebug("in vol %d", filePara.inVol); | 1057 | // qDebug("in vol %d", filePara.inVol); |
1037 | InputSlider->setValue( -filePara.inVol); | 1058 | InputSlider->setValue( -filePara.inVol); |
1038 | } | 1059 | } |
1039 | 1060 | ||
1040 | void QtRec::changedOutVolume() { | 1061 | void QtRec::changedOutVolume() { |
1041 | soundDevice->changedOutVolume( -OutputSlider->value()); | 1062 | soundDevice->changedOutVolume( -OutputSlider->value()); |
1042 | } | 1063 | } |
1043 | 1064 | ||
1044 | void QtRec::changedInVolume( ) { | 1065 | void QtRec::changedInVolume( ) { |
1045 | soundDevice->changedInVolume( -InputSlider->value()); | 1066 | soundDevice->changedInVolume( -InputSlider->value()); |
1046 | } | 1067 | } |
1047 | 1068 | ||
1048 | 1069 | ||
1049 | bool QtRec::setupAudio( bool b) { | 1070 | bool QtRec::setupAudio( bool b) { |
1050 | bool ok; | 1071 | bool ok; |
1051 | int sampleformat, stereo, flags; | 1072 | int sampleformat, stereo, flags; |
1052 | char * dspString, *mixerString; | 1073 | char * dspString, *mixerString; |
1053 | 1074 | ||
1054 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 | 1075 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 |
1055 | 1076 | ||
1077 | #ifdef PDAUDIO //ALSA | ||
1078 | if( !b) { // we want to play | ||
1079 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | ||
1080 | sampleformat = SND_PCM_FORMAT_S16; | ||
1081 | filePara.resolution = 16; | ||
1082 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { | ||
1083 | sampleformat = SND_PCM_FORMAT_S24; | ||
1084 | filePara.resolution = 24; | ||
1085 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { | ||
1086 | sampleformat = SND_PCM_FORMAT_S32; | ||
1087 | filePara.resolution = 32; | ||
1088 | } else { | ||
1089 | sampleformat = SND_PCM_FORMAT_U8; | ||
1090 | filePara.resolution = 8; | ||
1091 | } | ||
1092 | #else | ||
1056 | if( !b) { | 1093 | if( !b) { |
1057 | // we want to play | 1094 | // we want to play |
1058 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1095 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1059 | sampleformat = AFMT_S16_LE; | 1096 | sampleformat = AFMT_S16_LE; |
1060 | filePara.resolution = 16; | 1097 | filePara.resolution = 16; |
1061 | } else { | 1098 | } else { |
1062 | sampleformat = AFMT_U8; | 1099 | sampleformat = AFMT_U8; |
1063 | filePara.resolution = 8; | 1100 | filePara.resolution = 8; |
1064 | } | 1101 | } |
1065 | 1102 | #endif | |
1103 | |||
1066 | stereo = filePara.channels; | 1104 | stereo = filePara.channels; |
1067 | flags = O_WRONLY; | 1105 | flags = O_WRONLY; |
1068 | dspString = DSPSTROUT; | 1106 | dspString = DSPSTROUT; |
1069 | mixerString = DSPSTRMIXEROUT; | 1107 | mixerString = DSPSTRMIXEROUT; |
1070 | recording = false; | 1108 | recording = false; |
1071 | } else { // we want to record | 1109 | } else { // we want to record |
1072 | 1110 | ||
1073 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1111 | #ifdef PDAUDIO //ALSA |
1112 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | ||
1113 | sampleformat = SND_PCM_FORMAT_S16; | ||
1114 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") | ||
1115 | sampleformat = SND_PCM_FORMAT_S24; | ||
1116 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") | ||
1117 | sampleformat = SND_PCM_FORMAT_S32; | ||
1118 | else | ||
1119 | sampleformat = SND_PCM_FORMAT_U8; | ||
1120 | |||
1121 | #else | ||
1122 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | ||
1074 | sampleformat = AFMT_S16_LE; | 1123 | sampleformat = AFMT_S16_LE; |
1075 | else | 1124 | else |
1076 | sampleformat = AFMT_U8; | 1125 | sampleformat = AFMT_U8; |
1077 | 1126 | ||
1078 | if( !compressionCheckBox->isChecked()) { | 1127 | if( !compressionCheckBox->isChecked()) { |
1079 | filePara.format = WAVE_FORMAT_PCM; | 1128 | filePara.format = WAVE_FORMAT_PCM; |
1080 | // qDebug("WAVE_FORMAT_PCM"); | 1129 | // qDebug("WAVE_FORMAT_PCM"); |
1081 | } else { | 1130 | } else { |
1082 | filePara.format = WAVE_FORMAT_DVI_ADPCM; | 1131 | filePara.format = WAVE_FORMAT_DVI_ADPCM; |
1083 | sampleformat = AFMT_S16_LE; | 1132 | sampleformat = AFMT_S16_LE; |
1084 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 1133 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
1085 | } | 1134 | } |
1086 | 1135 | #endif | |
1136 | |||
1087 | stereo = filePara.channels; | 1137 | stereo = filePara.channels; |
1088 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1138 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1089 | flags= O_RDWR; | 1139 | flags= O_RDWR; |
1090 | // flags= O_RDONLY; | 1140 | // flags= O_RDONLY; |
1091 | dspString = DSPSTRIN; | 1141 | dspString = DSPSTRIN; |
1092 | mixerString = DSPSTRMIXEROUT; | 1142 | mixerString = DSPSTRMIXEROUT; |
1093 | recording = true; | 1143 | recording = true; |
1094 | } | 1144 | } |
1095 | 1145 | ||
1096 | // if(soundDevice) delete soundDevice; | 1146 | // if(soundDevice) delete soundDevice; |
1097 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); | 1147 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); |
1098 | qWarning("change waveform settings"); | 1148 | qWarning("change waveform settings"); |
1099 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1149 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1100 | 1150 | ||
1101 | soundDevice = new Device( this, dspString, mixerString, b); | 1151 | soundDevice = new Device( this, dspString, mixerString, b); |
1102 | // soundDevice->openDsp(); | 1152 | // soundDevice->openDsp(); |
1103 | soundDevice->reset(); | 1153 | soundDevice->reset(); |
1104 | 1154 | ||
1105 | qDebug("device has been made %d", soundDevice->sd); | 1155 | qDebug("device has been made %d", soundDevice->sd); |
1106 | 1156 | ||
1107 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | 1157 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> |
1108 | soundDevice->setDeviceFormat( sampleformat); | 1158 | soundDevice->setDeviceFormat( sampleformat); |
1109 | soundDevice->setDeviceChannels( filePara.channels); | 1159 | soundDevice->setDeviceChannels( filePara.channels); |
1110 | soundDevice->setDeviceRate( filePara.sampleRate); | 1160 | soundDevice->setDeviceRate( filePara.sampleRate); |
1111 | soundDevice->getDeviceFragSize(); | 1161 | soundDevice->getDeviceFragSize(); |
1112 | #ifdef QT_QWS_EBX | 1162 | #ifdef QT_QWS_EBX |
1113 | int frag = FRAGSIZE; | 1163 | int frag = FRAGSIZE; |
1114 | soundDevice->setFragSize( frag); | 1164 | soundDevice->setFragSize( frag); |
1115 | soundDevice->getDeviceFragSize(); | 1165 | soundDevice->getDeviceFragSize(); |
1116 | #endif | 1166 | #endif |
1117 | ///////////////// | 1167 | ///////////////// |
1118 | filePara.sd = soundDevice->sd; | 1168 | filePara.sd = soundDevice->sd; |
1119 | 1169 | ||
1120 | if ( filePara.sd == -1) { | 1170 | if ( filePara.sd == -1) { |
1121 | 1171 | ||
1122 | monitoring = false; | 1172 | monitoring = false; |
1123 | stopped = true; | 1173 | stopped = true; |
1124 | update(); | 1174 | update(); |
1125 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); | 1175 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); |
1126 | return false; | 1176 | return false; |
1127 | } | 1177 | } |
1128 | if(autoMute) | 1178 | if(autoMute) |
1129 | doMute(false); | 1179 | doMute(false); |
1130 | 1180 | ||
1131 | return true; | 1181 | return true; |
1132 | } | 1182 | } |
1133 | 1183 | ||
1134 | 1184 | ||
@@ -1138,112 +1188,115 @@ bool QtRec::setUpFile() { //setup file for recording | |||
1138 | wavFile = new WavFile( this, (const QString &)"", | 1188 | wavFile = new WavFile( this, (const QString &)"", |
1139 | true, | 1189 | true, |
1140 | filePara.sampleRate, | 1190 | filePara.sampleRate, |
1141 | filePara.channels, | 1191 | filePara.channels, |
1142 | filePara.resolution, | 1192 | filePara.resolution, |
1143 | filePara.format); | 1193 | filePara.format); |
1144 | 1194 | ||
1145 | filePara.fd = wavFile->wavHandle(); | 1195 | filePara.fd = wavFile->wavHandle(); |
1146 | if(filePara.fd == -1) { | 1196 | if(filePara.fd == -1) { |
1147 | return false; | 1197 | return false; |
1148 | } else { | 1198 | } else { |
1149 | // filePara.channels=1; | 1199 | // filePara.channels=1; |
1150 | } | 1200 | } |
1151 | return true; | 1201 | return true; |
1152 | } | 1202 | } |
1153 | 1203 | ||
1154 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> | 1204 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> |
1155 | bool QtRec::doPlay() { | 1205 | bool QtRec::doPlay() { |
1156 | 1206 | ||
1157 | if( !paused) { | 1207 | if( !paused) { |
1158 | total = 0; | 1208 | total = 0; |
1159 | filePara.numberOfRecordedSeconds = 0; | 1209 | filePara.numberOfRecordedSeconds = 0; |
1160 | } else { | 1210 | } else { |
1161 | paused = false; | 1211 | paused = false; |
1162 | secCount = (int)filePara.numberOfRecordedSeconds; | 1212 | secCount = (int)filePara.numberOfRecordedSeconds; |
1163 | } | 1213 | } |
1164 | playing = true; | 1214 | playing = true; |
1165 | stopped = false; | 1215 | stopped = false; |
1166 | recording = false; | 1216 | recording = false; |
1167 | 1217 | ||
1168 | QString num; | 1218 | QString num; |
1169 | qDebug( "Play number of samples %d", filePara.numberSamples); | 1219 | qDebug( "Play number of samples %d", filePara.numberSamples); |
1170 | 1220 | ||
1171 | // timeSlider->setRange( 0, filePara.numberSamples); | 1221 | // timeSlider->setRange( 0, filePara.numberSamples); |
1172 | 1222 | ||
1173 | timeString.sprintf("%d", filePara.numberOfRecordedSeconds); | 1223 | timeString.sprintf("%d", filePara.numberOfRecordedSeconds); |
1174 | timeLabel->setText( timeString+ tr(" seconds")); | 1224 | timeLabel->setText( timeString+ tr(" seconds")); |
1175 | 1225 | ||
1176 | QString msg; | 1226 | QString msg; |
1177 | msg.sprintf("%d, %d, %d", | 1227 | msg.sprintf("%d, %d, %d", |
1178 | filePara.sampleRate, | 1228 | filePara.sampleRate, |
1179 | filePara.channels, | 1229 | filePara.channels, |
1180 | filePara.resolution); | 1230 | filePara.resolution); |
1181 | #ifdef DEV_VERSION | 1231 | #ifdef DEV_VERSION |
1182 | setCaption( msg); | 1232 | setCaption( msg); |
1183 | #endif | 1233 | #endif |
1184 | 1234 | ||
1185 | startTimer( 1000); | 1235 | startTimer( 1000); |
1186 | pthread_t thread2; | 1236 | // pthread_t thread2; |
1187 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | 1237 | // pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); |
1188 | 1238 | ||
1189 | toBeginningButton->setEnabled( false); | 1239 | toBeginningButton->setEnabled( false); |
1190 | toEndButton->setEnabled( false); | 1240 | toEndButton->setEnabled( false); |
1241 | playIt(); | ||
1191 | 1242 | ||
1192 | return true; | 1243 | return true; |
1193 | } | 1244 | } |
1194 | 1245 | ||
1195 | 1246 | ||
1196 | void QtRec::changebitrateCombo(int i) { | 1247 | void QtRec::changebitrateCombo(int i) { |
1197 | Config cfg("OpieRec"); | 1248 | Config cfg("OpieRec"); |
1198 | cfg.setGroup("Settings"); | 1249 | cfg.setGroup("Settings"); |
1199 | int bits = 0; | 1250 | int bits = 0; |
1200 | if( i == 0) { bits = 16; } | 1251 | if( i == 1) { bits = 16; } |
1201 | else { bits=8; } | 1252 | else if( i == 2) { bits = 24; } |
1253 | else if( i == 3) { bits = 32; } | ||
1254 | else { bits=8; } | ||
1202 | cfg.writeEntry("bitrate", bits); | 1255 | cfg.writeEntry("bitrate", bits); |
1203 | filePara.resolution = bits; | 1256 | filePara.resolution = bits; |
1204 | cfg.write(); | 1257 | cfg.write(); |
1205 | } | 1258 | } |
1206 | 1259 | ||
1207 | void QtRec::changesamplerateCombo(int i) { | 1260 | void QtRec::changesamplerateCombo(int i) { |
1208 | Config cfg("OpieRec"); | 1261 | Config cfg("OpieRec"); |
1209 | cfg.setGroup("Settings"); | 1262 | cfg.setGroup("Settings"); |
1210 | int rate=0; | 1263 | int rate=0; |
1211 | bool ok; | 1264 | bool ok; |
1212 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); | 1265 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); |
1213 | cfg.writeEntry( "samplerate",rate); | 1266 | cfg.writeEntry( "samplerate",rate); |
1214 | filePara.sampleRate=rate; | 1267 | filePara.sampleRate=rate; |
1215 | qDebug( "Change sample rate %d", rate); | 1268 | qDebug( "Change sample rate %d", rate); |
1216 | cfg.write(); | 1269 | cfg.write(); |
1217 | } | 1270 | } |
1218 | 1271 | ||
1219 | 1272 | ||
1220 | void QtRec::changeDirCombo(int index) { | 1273 | void QtRec::changeDirCombo(int index) { |
1221 | Config cfg("OpieRec"); | 1274 | Config cfg("OpieRec"); |
1222 | cfg.setGroup("Settings"); | 1275 | cfg.setGroup("Settings"); |
1223 | QString sName = directoryComboBox->text(index); | 1276 | QString sName = directoryComboBox->text(index); |
1224 | 1277 | ||
1225 | StorageInfo storageInfo; | 1278 | StorageInfo storageInfo; |
1226 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1279 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1227 | QListIterator<FileSystem> it ( fs ); | 1280 | QListIterator<FileSystem> it ( fs ); |
1228 | QString storage; | 1281 | QString storage; |
1229 | for( ; it.current(); ++it ){ | 1282 | for( ; it.current(); ++it ){ |
1230 | if( sName == (*it)->name()+" "+ (*it)->path() || | 1283 | if( sName == (*it)->name()+" "+ (*it)->path() || |
1231 | (*it)->name() == sName ) { | 1284 | (*it)->name() == sName ) { |
1232 | const QString path = (*it)->path(); | 1285 | const QString path = (*it)->path(); |
1233 | recDir = path; | 1286 | recDir = path; |
1234 | cfg.writeEntry("directory", recDir); | 1287 | cfg.writeEntry("directory", recDir); |
1235 | qDebug("new rec dir "+recDir); | 1288 | qDebug("new rec dir "+recDir); |
1236 | } | 1289 | } |
1237 | } | 1290 | } |
1238 | cfg.write(); | 1291 | cfg.write(); |
1239 | } | 1292 | } |
1240 | 1293 | ||
1241 | 1294 | ||
1242 | void QtRec::changeSizeLimitCombo(int) { | 1295 | void QtRec::changeSizeLimitCombo(int) { |
1243 | Config cfg("OpieRec"); | 1296 | Config cfg("OpieRec"); |
1244 | cfg.setGroup("Settings"); | 1297 | cfg.setGroup("Settings"); |
1245 | cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); | 1298 | cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); |
1246 | cfg.write(); | 1299 | cfg.write(); |
1247 | } | 1300 | } |
1248 | 1301 | ||
1249 | void QtRec::newSound() { | 1302 | void QtRec::newSound() { |