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