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