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