summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp59
-rw-r--r--noncore/multimedia/opierec/device.h59
-rw-r--r--noncore/multimedia/opierec/main.cpp5
-rw-r--r--noncore/multimedia/opierec/opierec.control2
-rw-r--r--noncore/multimedia/opierec/opierec.pro25
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp1409
-rw-r--r--noncore/multimedia/opierec/qtrec.h15
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp17
-rw-r--r--noncore/multimedia/opierec/wavFile.h1
9 files changed, 791 insertions, 801 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index 11071d8..ce49e96 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -5,5 +5,5 @@
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
7#include <qpe/custom.h> 7
8 8
9#include <fcntl.h> 9#include <fcntl.h>
@@ -27,5 +27,5 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco
27 dspstr = (char *)dsp; 27 dspstr = (char *)dsp;
28 mixstr = (char *)mixr; 28 mixstr = (char *)mixr;
29 29
30 devForm=-1; 30 devForm=-1;
31 devCh=-1; 31 devCh=-1;
@@ -39,5 +39,7 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco
39 flags = O_RDWR; 39 flags = O_RDWR;
40// flags = O_RDONLY; 40// flags = O_RDONLY;
41 selectMicInput(); 41
42// selectMicInput();
43
42 } 44 }
43} 45}
@@ -95,4 +97,5 @@ void Device::changedOutVolume(int vol) {
95 cfg.writeEntry("VolumePercent", QString::number( vol )); 97 cfg.writeEntry("VolumePercent", QString::number( vol ));
96 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; 98 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
99 qWarning("changing output vol %d", vol);
97 } 100 }
98 ::close(fd); 101 ::close(fd);
@@ -109,4 +112,5 @@ void Device::changedInVolume(int vol ) {
109 cfg.writeEntry("Mic", QString::number(vol )); 112 cfg.writeEntry("Mic", QString::number(vol ));
110 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; 113 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false;
114 qWarning("changing input volume %d", vol);
111 } 115 }
112 ::close(fd); 116 ::close(fd);
@@ -114,5 +118,5 @@ void Device::changedInVolume(int vol ) {
114 118
115bool Device::selectMicInput() { 119bool Device::selectMicInput() {
116/* 120
117 int md=0; 121 int md=0;
118 int info=MIXER_WRITE(SOUND_MIXER_MIC); 122 int info=MIXER_WRITE(SOUND_MIXER_MIC);
@@ -127,5 +131,5 @@ bool Device::selectMicInput() {
127 } 131 }
128 ::close(md); 132 ::close(md);
129*/ 133
130 return true; 134 return true;
131} 135}
@@ -146,16 +150,20 @@ exit(1);
146 case 0: { 150 case 0: {
147 */ 151 */
148 if (( sd = ::open( dspstr, flags)) == -1) { 152qDebug("Opening %s",dspstr);
153 if (( sd = ::open( dspstr, flags)) == -1) {
149 perror("open(\"/dev/dsp\")"); 154 perror("open(\"/dev/dsp\")");
150 QString errorMsg="Could not open audio device\n /dev/dsp\n" 155 QString errorMsg="Could not open audio device\n /dev/dsp\n"
151 +(QString)strerror(errno); 156 +(QString)strerror(errno);
152 qDebug(errorMsg); 157 qDebug("XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg);
153 return -1; 158 return -1;
154 } 159 }
155 160
161qDebug("Opening mixer");
156 int mixerHandle=0; 162 int mixerHandle=0;
157 /* Set the input dsp device and its input gain the weird Zaurus way */ 163 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) {
158 if (( mixerHandle = open("/dev/mixer1",O_RDWR))<0) { 164 perror("open(\"/dev/mixer\")");
159 perror("open(\"/dev/mixer1\")"); 165 QString errorMsg="Could not open audio device\n /dev/dsp\n"
166 +(QString)strerror(errno);
167 qDebug("XXXXXXXXXXXXXXXXXXXXXX "+errorMsg);
160 } 168 }
161 169
@@ -200,14 +208,14 @@ exit(1);
200// sd = s.toInt(&ok, 10); 208// sd = s.toInt(&ok, 10);
201// qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s); 209// qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s);
202 210
203// f2.close(); 211// f2.close();
204// } 212// }
205::close(mixerHandle ); 213::close(mixerHandle );
206 qDebug("open device %s", dspstr); 214// qDebug("open device %s", dspstr);
207 qDebug("success! %d",sd); 215// qDebug("success! %d",sd);
208 return sd; 216 return sd;
209} 217}
210 218
211bool Device::closeDevice( bool b) { 219bool Device::closeDevice( bool) {
212// if(b) {//close now 220// if(b) {//close now
213// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { 221// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
@@ -223,5 +231,5 @@ bool Device::closeDevice( bool b) {
223// sdfd=0; 231// sdfd=0;
224 // sd=0; 232 // sd=0;
225 qDebug("closed dsp"); 233// qDebug("closed dsp");
226 return true; 234 return true;
227} 235}
@@ -291,5 +299,5 @@ int Device::getDeviceRate() {
291int Device::getDeviceBits() { 299int Device::getDeviceBits() {
292 int dBits=0; 300 int dBits=0;
293#if !defined(OPIE_NO_SOUND_PCM_READ_BITS) // zaurus doesnt have this 301#ifndef QT_QWS_EBX // zaurus doesnt have this
294 if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) { 302 if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) {
295 perror("ioctl(\"SNDCTL_PCM_READ_BITS\")"); 303 perror("ioctl(\"SNDCTL_PCM_READ_BITS\")");
@@ -309,9 +317,10 @@ int Device::getDeviceChannels() {
309int Device::getDeviceFragSize() { 317int Device::getDeviceFragSize() {
310 int frag_size; 318 int frag_size;
311 319
312 if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { 320 if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
313 qDebug("no fragsize"); 321 qDebug("no fragsize");
314 } else 322 } else {
315 qDebug("driver says frag size is %d", frag_size); 323 qDebug("driver says frag size is %d", frag_size);
324 }
316 return frag_size; 325 return frag_size;
317} 326}
@@ -334,2 +343,16 @@ bool Device::reset() {
334 return true; 343 return true;
335} 344}
345
346int Device::devRead(int soundDescriptor, short *buf, int size) {
347 int number = 0;
348 number = ::read( soundDescriptor, (char *)buf, size);
349 return number;
350}
351
352int Device::devWrite(int soundDescriptor, short * buf, int size) {
353 int bytesWritten = 0;
354 bytesWritten = ::write( soundDescriptor, buf, size);
355 return bytesWritten;
356}
357
358
diff --git a/noncore/multimedia/opierec/device.h b/noncore/multimedia/opierec/device.h
index f92be98..8152e85 100644
--- a/noncore/multimedia/opierec/device.h
+++ b/noncore/multimedia/opierec/device.h
@@ -6,35 +6,38 @@
6 6
7class Device : public QObject { 7class Device : public QObject {
8 Q_OBJECT 8 Q_OBJECT
9public: 9public:
10 Device( QObject * parent=0, const char * dspStr=0, const char * mixerStr=0, bool record=0 ); 10 Device( QObject * parent=0, const char * dspStr=0, const char * mixerStr=0, bool record=0 );
11 ~Device() {}; 11 ~Device() {};
12 bool closeDevice( bool); 12 bool closeDevice( bool);
13 int getChannels(); 13 int getChannels();
14 int getFormat(); 14 int getFormat();
15 int getInVolume(); 15 int getInVolume();
16 int getOutVolume(); 16 int getOutVolume();
17 int getRate(); 17 int getRate();
18 int getRes(); 18 int getRes();
19 int sd; //sound descriptor 19 int sd; //sound descriptor
20 void changedInVolume(int); 20 void changedInVolume(int);
21 void changedOutVolume(int); 21 void changedOutVolume(int);
22 bool openDsp(); 22 bool openDsp();
23 int getDeviceFormat(); 23 int getDeviceFormat();
24 int getDeviceRate(); 24 int getDeviceRate();
25 int getDeviceBits(); 25 int getDeviceBits();
26 int getDeviceChannels(); 26 int getDeviceChannels();
27 int getDeviceFragSize(); 27 int getDeviceFragSize();
28 bool setFragSize(int); 28 bool setFragSize(int);
29 bool setDeviceChannels(int); 29 bool setDeviceChannels(int);
30 bool setDeviceRate(int); 30 bool setDeviceRate(int);
31 bool setDeviceFormat(int); 31 bool setDeviceFormat(int);
32bool reset(); 32 bool reset();
33
34 int devRead(int, short *, int);
35 int devWrite(int, short *, int);
33 36
34private: 37private:
35 int devRes, devCh, devRate, devForm, flags; 38 int devRes, devCh, devRate, devForm, flags;
36 char *dspstr, *mixstr; 39 char *dspstr, *mixstr;
37 bool selectMicInput(); 40 bool selectMicInput();
38 int openDevice( int ); 41 int openDevice( int );
39private slots: 42private slots:
40 43
diff --git a/noncore/multimedia/opierec/main.cpp b/noncore/multimedia/opierec/main.cpp
index 4a94800..e36d050 100644
--- a/noncore/multimedia/opierec/main.cpp
+++ b/noncore/multimedia/opierec/main.cpp
@@ -13,4 +13,7 @@
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14#include <opie/oapplicationfactory.h> 14#include <opie/oapplicationfactory.h>
15 15
16OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) 16OPIE_EXPORT_APP( OApplicationFactory<QtRec> )
17
18
19
diff --git a/noncore/multimedia/opierec/opierec.control b/noncore/multimedia/opierec/opierec.control
index cb97933..b01406e 100644
--- a/noncore/multimedia/opierec/opierec.control
+++ b/noncore/multimedia/opierec/opierec.control
@@ -1,4 +1,4 @@
1Package: opierec 1Package: opierec
2Files: plugins/application/libopierec.so* bin/opierec pics/opierec apps/Applications/opierec.desktop 2Files: bin/opierec pics/opierec apps/Applications/opierec.desktop
3Priority: optional 3Priority: optional
4Section: multimedia/applications 4Section: multimedia/applications
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro
index 7dbc4f7..b607c09 100644
--- a/noncore/multimedia/opierec/opierec.pro
+++ b/noncore/multimedia/opierec/opierec.pro
@@ -1,11 +1,26 @@
1CONFIG = qt warn_on debug 1CONFIG = qt warn_on release
2#CONFIG = qt warn_on release quick-app 2#CONFIG = qt warn_on release quick-app
3HEADERS = adpcm.h pixmaps.h qtrec.h device.h wavFile.h 3HEADERS = adpcm.h \
4SOURCES = adpcm.c main.cpp qtrec.cpp device.cpp wavFile.cpp 4 pixmaps.h \
5 helpwindow.h \
6 qtrec.h \
7 device.h \
8 wavFile.h \
9 waveform.h
10SOURCES = adpcm.c \
11 helpwindow.cpp \
12 main.cpp \
13 qtrec.cpp \
14 device.cpp \
15 wavFile.cpp \
16 waveform.cpp
5INCLUDEPATH += $(OPIEDIR)/include 17INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include 18DEPENDPATH += $(OPIEDIR)/include
19#LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz
7LIBS += -lqpe -lpthread 20LIBS += -lqpe -lpthread
8INTERFACES = 21INTERFACES =
9TARGET = opierec 22TARGET = opierec
10#TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti 23DESTDIR=$(OPIEDIR)/bin
24
11include ( $(OPIEDIR)/include.pro ) 25include ( $(OPIEDIR)/include.pro )
26
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 1e36c96..aeab26d 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -9,4 +9,6 @@
9#include "pixmaps.h" 9#include "pixmaps.h"
10#include "qtrec.h" 10#include "qtrec.h"
11#include "waveform.h"
12#include "device.h"
11 13
12#include <pthread.h> 14#include <pthread.h>
@@ -18,8 +20,4 @@ extern "C" {
18#include <sys/soundcard.h> 20#include <sys/soundcard.h>
19 21
20// #if defined (QTOPIA_INTERNAL_FSLP)
21// #include <qpe/lnkproperties.h>
22// #endif
23
24#include <qpe/config.h> 22#include <qpe/config.h>
25#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
@@ -56,14 +54,28 @@ extern "C" {
56#include <sys/vfs.h> 54#include <sys/vfs.h>
57#include <unistd.h> 55#include <unistd.h>
58#include<sys/wait.h> 56#include <sys/wait.h>
59#include <sys/signal.h> 57#include <sys/signal.h>
60 58
59#if defined(QT_QWS_SL5XXX)
60///#if defined(QT_QWS_EBX)
61
62#define DSPSTROUT "/dev/dsp"
63#define DSPSTRIN "/dev/dsp1"
64#define DSPSTRMIXEROUT "/dev/mixer"
65#define DSPSTRMIXERIN "/dev/mixer1"
66
67#else
68
69#define DSPSTROUT "/dev/dsp"
70#define DSPSTRIN "/dev/dsp"
71#define DSPSTRMIXERIN "/dev/mixer"
72#define DSPSTRMIXEROUT "/dev/mixer"
73
74#endif
75
61//#define ZAURUS 0 76//#define ZAURUS 0
62struct adpcm_state encoder_state; 77struct adpcm_state encoder_state;
63struct adpcm_state decoder_state; 78struct adpcm_state decoder_state;
64 79
65long findPeak(long input );
66//char deviceRates[];
67
68typedef struct { 80typedef struct {
69 int sampleRate; 81 int sampleRate;
@@ -86,5 +98,5 @@ typedef struct {
86fileParameters filePara; 98fileParameters filePara;
87 99
88bool monitoring, recording; 100bool monitoring, recording, playing;
89bool stopped; 101bool stopped;
90QLabel *timeLabel; 102QLabel *timeLabel;
@@ -92,67 +104,59 @@ QSlider *timeSlider;
92int sd; 104int sd;
93 105
94// #if defined(QT_QWS_EBX) 106Waveform* waveform;
95// #define DSPSTROUT "/dev/dsp" 107Device *soundDevice;
96// #define DSPSTRIN "/dev/dsp1"
97// #define DSPSTRMIXEROUT "/dev/mixer"
98// #define DSPSTRMIXERIN "/dev/mixer1"
99// #else
100#define DSPSTROUT "/dev/dsp"
101#define DSPSTRIN "/dev/dsp"
102#define DSPSTRMIXERIN "/dev/mixer"
103#define DSPSTRMIXEROUT "/dev/mixer"
104//#endif
105 108
106// threaded recording 109// threaded recording
107void quickRec() { 110//fuckin fulgy here
111void quickRec()
112{
108//void QtRec::quickRec() { 113//void QtRec::quickRec() {
109 114
115 qDebug("%d",
116 filePara.numberSamples/filePara.sampleRate * filePara.channels);
117 qDebug("samples %d, rate %d, channels %d",
118 filePara.numberSamples, filePara.sampleRate, filePara.channels);
119
110 int total = 0; // Total number of bytes read in so far. 120 int total = 0; // Total number of bytes read in so far.
111 int bytesWritten, number; 121 int bytesWritten, number;
112 122
113 count_info info; 123 bytesWritten = 0;
114 124 number = 0;
115 bytesWritten=0; 125 QString num;
116 number=0; 126 int level = 0;
117 QString num, timeString; 127 int threshold = 0;
118 int level=0; 128// int bits = filePara.resolution;
119 int threshold=0; 129// qDebug("bits %d", bits);
120 // if(limit != 0)
121 // t->start( ( limit +.3) , true);
122
123 recording = true;
124 //rate=filePara.sampleRate;
125 // int bits = filePara.resolution;
126 audio_buf_info inInfo;
127 ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo);
128 // qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal);
129 130
130 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 131 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
131 level=7; 132// qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord);
132 threshold=0; 133// qDebug("samples to record %d", filePara.samplesToRecord);
133 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 134// qDebug("%d", filePara.sd);
134 timeLabel->setText( timeString+ " seconds"); 135 level = 7;
135 136 threshold = 0;
136 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { 137
137 // qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); 138 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
138 char abuf[BUFSIZE/2]; 139// qDebug("start recording WAVE_FORMAT_DVI_ADPCM");
139 short sbuf[BUFSIZE]; 140 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
140 short sbuf2[BUFSIZE]; 141 char abuf[ BUFSIZE/2 ];
141 memset( abuf,0,BUFSIZE/2); 142 short sbuf[ BUFSIZE ];
142 memset( sbuf,0,BUFSIZE); 143 short sbuf2[ BUFSIZE ];
143 memset( sbuf2,0,BUFSIZE); 144 memset( abuf, 0, BUFSIZE/2);
145 memset( sbuf, 0, BUFSIZE);
146 memset( sbuf2, 0, BUFSIZE);
144 147
145 for(;;) { 148 for(;;) {
146 if (stopped) { 149 if ( stopped) {
147 break; // stop if playing was set to false 150 qDebug("quickRec:: stopped");
151 break;
148 } 152 }
149 153
150 number=::read( filePara.sd, sbuf, BUFSIZE); 154// number=::read( filePara.sd, sbuf, BUFSIZE);
155 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
156
151 if(number <= 0) { 157 if(number <= 0) {
152 perror("recording error "); 158 perror("recording error ");
153 // qDebug( "%s %d", filePara.fileName, number); 159 qDebug( "%s %d", filePara.fileName, number);
154 // errorStop(); 160 stopped = true;
155 recording=stopped=false;
156// QMessageBox::message("Note", "Error recording to file\n%s",filePara.fileName);
157 return; 161 return;
158 } 162 }
@@ -160,158 +164,247 @@ void quickRec() {
160// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 164// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
161 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 165 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
162 bytesWritten = ::write( filePara.fd , abuf, number/4); 166 bytesWritten = soundDevice->devWrite( filePara.fd , (short *)abuf, number/4);
163 long peak; 167 waveform->newSamples( (const short *)abuf, bytesWritten );
164 for (int i = 0; i < number; i++) 168
165 { //since Z is mono do normally
166 peak = findPeak((long)sbuf[i]);
167 printf("peak %ld\r",peak);
168 fflush(stdout);
169 }
170 //------------->>>> out to file
171 // if(filePara.channels==1)
172 // total += bytesWritten/2; //mono
173 // else
174 total += bytesWritten; 169 total += bytesWritten;
175 filePara.numberSamples = total; 170 filePara.numberSamples = total;
176// if( total >= filePara.samplesToRecord)
177// timeSlider->setValue(0);
178// else if( filePara.SecondsToRecord !=0)
179 timeSlider->setValue( total); 171 timeSlider->setValue( total);
180 172
181 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; 173 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
182 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info);
183 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
184 timeLabel->setText( timeString + " seconds");
185 174
186 qApp->processEvents(); 175 qApp->processEvents();
187 if( total >= filePara.samplesToRecord) 176 if( total >= filePara.samplesToRecord) {
177 stopped = true;
188 break; 178 break;
179 }
189 } 180 }
190 } else { 181 } else {
191 // qDebug("start recording WAVE_FORMAT_PCM"); 182 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
192 short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; 183 qDebug("start recording WAVE_FORMAT_PCM");
193 memset( inbuffer,0,BUFSIZE); 184 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
194 memset( outbuffer,0,BUFSIZE); 185 memset( inbuffer, 0, BUFSIZE);
186 memset( outbuffer, 0, BUFSIZE);
187
195 for(;;) { 188 for(;;) {
196 if (stopped) { 189 if ( stopped) {
190 qDebug("quickRec:: stopped");
191 stopped = true;
197 break; // stop if playing was set to false 192 break; // stop if playing was set to false
193 return;
198 } 194 }
199 195
200 number=::read( filePara.sd, inbuffer, BUFSIZE); 196 number = soundDevice ->devRead( filePara.sd, (short *)inbuffer, BUFSIZE);
201 if(number <= 0) { 197 waveform->newSamples( inbuffer, number );
202 perror("recording error "); 198
203 recording=stopped=false; 199 if( number <= 0) {
204 // errorStop(); 200 perror( "recording error ");
205 return;// false; 201 qDebug( filePara.fileName);
202 stopped = true;
203 return;
206 } 204 }
207/* for (int i=0;i< number;i++) { //2*i is left channel 205
208outbuffer[i]=inbuffer[i]>>1; // no clippy, please 206 bytesWritten = soundDevice->devWrite( filePara.fd , inbuffer, number);
209}*/ 207
210 bytesWritten = ::write( filePara.fd , inbuffer, number); 208 if( bytesWritten < 0) {
211//------------->>>> out to file
212 if(bytesWritten < 0) {
213 // errorStop();
214 perror("File writing error "); 209 perror("File writing error ");
215 return;// false; 210 stopped = true;
211 return;
216 } 212 }
217 213
218 // if(filePara.channels==1)
219 // total += bytesWritten/2; //mono
220 // else
221 total += bytesWritten; 214 total += bytesWritten;
222 long peak; 215
223 for (int i = 0; i < number; i++)
224 { //since Z is mono do normally
225 peak = findPeak((long)inbuffer[i]);
226 printf("peak %ld\r",peak);
227 fflush(stdout);
228 }
229 filePara.numberSamples = total; 216 filePara.numberSamples = total;
230 if(filePara.SecondsToRecord !=0) 217
218 if( filePara.SecondsToRecord != 0)
231 timeSlider->setValue( total); 219 timeSlider->setValue( total);
232// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); 220// printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total);
233// fflush(stdout); 221// fflush(stdout);
234 222
235 ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); 223 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels;
236// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2);
237 224
238 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
239 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
240 timeLabel->setText( timeString + " seconds");
241 qApp->processEvents(); 225 qApp->processEvents();
242 if( total >= filePara.samplesToRecord) 226
227 if( total >= filePara.samplesToRecord) {
228 stopped = true;
243 break; 229 break;
244 } 230 }
231 }
245 } //end main loop 232 } //end main loop
246 233
247 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 234 } else { // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
248 unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; 235 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
249 memset( unsigned_inbuffer, 0, BUFSIZE); 236 memset( unsigned_inbuffer, 0, BUFSIZE);
250 memset( unsigned_outbuffer, 0, BUFSIZE); 237 memset( unsigned_outbuffer, 0, BUFSIZE);
251 238
252 for(;;) { 239 for(;;) {
253 if (stopped) { 240 if ( stopped) {
254 // qDebug("quickRec:: stopped"); 241 qDebug("quickRec:: stopped");
255 break; // stop if playing was set to false 242 break; // stop if playing was set to false
256 } 243 }
257 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 244
258//-------------<<<< in from device 245 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
259// val = (data ^ 0x80) << 8;
260
261//unsigned_outbuffer = (unsigned_inbuffer ^ 0x80) << 8;
262
263// if(number <= 0) {
264// perror("recording error ");
265// qDebug(filePara.fileName);
266// // errorStop();
267// QMessageBox::message("Note","error recording");
268// return;// false;
269// }
270// for (int i=0;i< number;i++) { //2*i is left channel
271// unsigned_outbuffer[i]=unsigned_inbuffer[i]>>1; // no clippy, please
272// }
273
274 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 246 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
275 247
276//------------->>>> out to file
277 if(bytesWritten < 0) { 248 if(bytesWritten < 0) {
278 recording=stopped=false; 249 stopped = true;
279 // errorStop();
280 QMessageBox::message("Note","There was a problem\nwriting to the file"); 250 QMessageBox::message("Note","There was a problem\nwriting to the file");
281 perror("File writing error "); 251 perror("File writing error ");
282 return;// false; 252 return;
283 } 253 }
254
284 total += bytesWritten; 255 total += bytesWritten;
285 filePara.numberSamples = total; 256 filePara.numberSamples = total;
286 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); 257 // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total);
287 // fflush(stdout); 258 // fflush(stdout);
288 if(filePara.SecondsToRecord !=0) 259 if( filePara.SecondsToRecord !=0)
289 timeSlider->setValue( total); 260 timeSlider->setValue( total);
290 261
291 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 262 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
292 263
293 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
294 timeLabel->setText( timeString + " seconds");
295
296 qApp->processEvents(); 264 qApp->processEvents();
297 if( total >= filePara.samplesToRecord) 265 if( total >= filePara.samplesToRecord) {
266 stopped = true;
298 break; 267 break;
268 }
299 } //end main loop 269 } //end main loop
300 } 270 }
301// qDebug("Final %d, %d", filePara.samplesToRecord , filePara.numberOfRecordedSeconds);
302} /// END quickRec() 271} /// END quickRec()
303 272
304// threaded play
305void playIt() {
306 273
274void playIt()
275{
276 int bytesWritten, number;
277 int total = 0; // Total number of bytes read in so far.
278 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
279 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
280 char abuf[ BUFSIZE / 2 ];
281 short sbuf[ BUFSIZE ];
282 short sbuf2[ BUFSIZE * 2 ];
283 memset( abuf, 0, BUFSIZE / 2);
284 memset( sbuf, 0, BUFSIZE);
285 memset( sbuf2, 0, BUFSIZE * 2);
286// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
287 for(;;) { // play loop
288 if ( stopped) {
289 break;
290 return;
291 }// stop if playing was set to false
292
293 number = ::read( filePara.fd, abuf, BUFSIZE / 2);
294 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
295
296// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
297// sbuf2[i+1]=sbuf2[i]=sbuf[i];
298// }
299 bytesWritten = write ( filePara.sd, sbuf, number * 4);
300 waveform->newSamples( (const short *)sbuf, number );
301 // if(filePara.channels==1)
302 // total += bytesWritten/2; //mono
303 // else
304 total += bytesWritten;
305 filePara.numberSamples = total/4;
306 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
307
308 timeSlider->setValue( total/4);
309// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
310// if(filePara.numberOfRecordedSeconds>1)
311// timeLabel->setText( timeString+ tr(" seconds"));
312 printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
313 fflush(stdout);
314
315 qApp->processEvents();
316
317 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
318// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
319 stopped = true;
320 break;
321 }
322 }
323 } else {
324 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
325 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
326 memset( inbuffer, 0, BUFSIZE);
327 memset( outbuffer, 0, BUFSIZE);
328
329 for(;;) { // play loop
330 if ( stopped) {
331 break;
332 return;
333 }
334// stop if playing was set to false
335 number = ::read( filePara.fd, inbuffer, BUFSIZE);
336// 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
338// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
339// }
340 bytesWritten = ::write( filePara.sd, inbuffer, number);
341 waveform->newSamples( inbuffer, bytesWritten );
342 //-------------->>>> out to device
343 // total+=bytesWritten;
344 // if(filePara.channels==1)
345 // total += bytesWritten/2; //mono
346 // else
347 total += bytesWritten;
348 timeSlider->setValue( total);
349
350 filePara.numberSamples = total;
351 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
352
353// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
354// timeLabel->setText( timeString + tr(" seconds"));
355
356 qApp->processEvents();
357
358 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
359 qWarning("Jane! Stop this crazy thing!");
360 stopped = true;
361// playing = false;
362 break;
363 }
364 }
365 printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
366 fflush(stdout);
367 } //end loop
368 } else {
369/////////////////////////////// format = AFMT_U8;
370 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
371 memset( unsigned_inbuffer, 0, BUFSIZE);
372 for(;;) {
373// main loop
374 if (stopped) {
375 break; // stop if playing was set to false
376 return;
377 }
378 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
379//data = (val >> 8) ^ 0x80;
380 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
381 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
382 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
383 total += bytesWritten;
384
385 timeSlider->setValue( total);
386 filePara.numberSamples = total;
387
388 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
389// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
390// timeLabel->setText( timeString + tr(" seconds"));
391 qApp->processEvents();
392
393 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
394// if( total >= filePara.numberSamples ) {
395 stopped = true;
396 break;
397 }
398 printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
399 fflush(stdout);
400 }
401 }
307} 402}
308 403
309/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> 404/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
310QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
311 : QWidget( parent, name, fl ) {
312 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
313 // autoMute=TRUE;
314// QPEApplication::grabKeyboard();
315 405
406QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
407 : QWidget( parent, name, fl )
408{
316 if ( !name ) 409 if ( !name )
317 setName( "OpieRec" ); 410 setName( "OpieRec" );
@@ -331,17 +424,17 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
331 getOutVol(); 424 getOutVol();
332 425
333 soundDevice->closeDevice( true); 426 soundDevice->closeDevice( true);
334 soundDevice->sd=-1; 427 soundDevice->sd = -1;
335 soundDevice=0; 428 soundDevice = 0;
336 wavFile=0; 429 wavFile = 0;
337 430
338 if(soundDevice) delete soundDevice; 431 if( soundDevice) delete soundDevice;
339 432
340 initIconView(); 433 initIconView();
341 434
342 if(autoMute) 435 if( autoMute)
343 doMute(true); 436 doMute( true);
344 ListView1->setFocus(); 437 ListView1->setFocus();
345 playing=false; 438 playing = false;
346} 439}
347 440
@@ -352,6 +445,6 @@ QtRec::~QtRec() {
352void QtRec::cleanUp() { 445void QtRec::cleanUp() {
353 446
354 if(!stopped) { 447 if( !stopped) {
355 stopped=true; 448 stopped = true;
356 endRecording(); 449 endRecording();
357 } 450 }
@@ -359,21 +452,19 @@ void QtRec::cleanUp() {
359 ListView1->clear(); 452 ListView1->clear();
360 453
361 if(autoMute) 454 if( autoMute)
362 doMute(false); 455 doMute(false);
363 456
364 if(wavFile) delete wavFile; 457 if( wavFile) delete wavFile;
365// if(soundDevice) delete soundDevice; 458// if(soundDevice) delete soundDevice;
366// QPEApplication::grabKeyboard();
367// QPEApplication::ungrabKeyboard();
368} 459}
369 460
370void QtRec::init() { 461void QtRec::init() {
371 462
372 needsStereoOut=false; 463 needsStereoOut = false;
373 QPixmap image3( ( const char** ) image3_data ); 464 QPixmap image3( ( const char** ) image3_data );
374 QPixmap image4( ( const char** ) image4_data ); 465 QPixmap image4( ( const char** ) image4_data );
375 QPixmap image6( ( const char** ) image6_data ); 466 QPixmap image6( ( const char** ) image6_data );
376 467
377 stopped=true; 468 stopped = true;
378 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 469 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
379 QGridLayout *layout = new QGridLayout( this ); 470 QGridLayout *layout = new QGridLayout( this );
@@ -383,5 +474,5 @@ void QtRec::init() {
383 TabWidget = new QTabWidget( this, "TabWidget" ); 474 TabWidget = new QTabWidget( this, "TabWidget" );
384 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); 475 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7);
385 // TabWidget->setTabShape(QTabWidget::Triangular); 476// TabWidget->setTabShape(QTabWidget::Triangular);
386 477
387 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 478 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
@@ -393,7 +484,5 @@ void QtRec::init() {
393 484
394 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 485 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
395 // timeSlider->setFixedWidth(150);
396 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 486 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
397// timeSlider->setTickmarks(QSlider::Above);
398 487
399 timeLabel = new QLabel( tab, "TimeLabel" ); 488 timeLabel = new QLabel( tab, "TimeLabel" );
@@ -402,20 +491,20 @@ void QtRec::init() {
402 playLabel2 = new QLabel(tab, "PlayLabel2" ); 491 playLabel2 = new QLabel(tab, "PlayLabel2" );
403 playLabel2->setText(tr("Play") ); 492 playLabel2->setText(tr("Play") );
404 playLabel2->setFixedHeight(18); 493 playLabel2->setFixedHeight( 18);
405 layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 494 layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
406 495
407 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 496 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
408 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 497 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
409 Stop_PushButton->setFixedSize(22,22); 498 Stop_PushButton->setFixedSize( 22, 22);
410 Stop_PushButton->setPixmap( image4 ); 499 Stop_PushButton->setPixmap( image4 );
411 500
412 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 501 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
413 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 502 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
414 toBeginningButton->setFixedSize(22,22); 503 toBeginningButton->setFixedSize( 22, 22);
415 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 504 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") );
416 505
417 toEndButton = new QPushButton( tab, "End_PushButton" ); 506 toEndButton = new QPushButton( tab, "End_PushButton" );
418 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 507 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
419 toEndButton->setFixedSize(22,22); 508 toEndButton->setFixedSize( 22, 22);
420 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 509 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) );
421 510
@@ -423,10 +512,10 @@ void QtRec::init() {
423 recLabel2 = new QLabel( tab, "recLabel2" ); 512 recLabel2 = new QLabel( tab, "recLabel2" );
424 recLabel2->setText(tr("Rec")); 513 recLabel2->setText(tr("Rec"));
425 recLabel2->setFixedHeight(18); 514 recLabel2->setFixedHeight( 18);
426 layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 515 layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
427 516
428 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 517 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
429 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 518 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
430 Rec_PushButton->setFixedSize(22,22); 519 Rec_PushButton->setFixedSize( 22, 22);
431 Rec_PushButton->setPixmap( image6 ); 520 Rec_PushButton->setPixmap( image6 );
432 521
@@ -435,8 +524,10 @@ void QtRec::init() {
435 524
436 rewindTimer = new QTimer( this ); 525 rewindTimer = new QTimer( this );
437 connect( rewindTimer, SIGNAL( timeout() ), SLOT( rewindTimerTimeout() ) ); 526 connect( rewindTimer, SIGNAL( timeout() ),
527 this, SLOT( rewindTimerTimeout() ) );
438 528
439 forwardTimer = new QTimer( this ); 529 forwardTimer = new QTimer( this );
440 connect( forwardTimer, SIGNAL( timeout() ), SLOT( forwardTimerTimeout() ) ); 530 connect( forwardTimer, SIGNAL( timeout() ),
531 this, SLOT( forwardTimerTimeout() ) );
441 532
442 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 533 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
@@ -448,19 +539,19 @@ void QtRec::init() {
448 539
449 ListView1->addColumn( tr( "Name" ) ); 540 ListView1->addColumn( tr( "Name" ) );
450 ListView1->setColumnWidth(0,140); 541 ListView1->setColumnWidth( 0, 140);
451 ListView1->setSorting( 1, false); 542 ListView1->setSorting( 1, false);
452 ListView1->addColumn( tr( "Time" ) ); //in seconds 543 ListView1->addColumn( tr( "Time" ) ); //in seconds
453 ListView1->setColumnWidth(1,50); 544 ListView1->setColumnWidth( 1, 50);
454 ListView1->addColumn( tr("Location") ); 545 ListView1->addColumn( tr("Location") );
455 ListView1->setColumnWidth(2,50); 546 ListView1->setColumnWidth( 2, 50);
456 ListView1->addColumn( tr("Date") ); 547 ListView1->addColumn( tr("Date") );
457 ListView1->setColumnWidth(3,63); 548 ListView1->setColumnWidth( 3, 63);
458 549
459 ListView1->setColumnWidthMode(0,QListView::Manual); 550 ListView1->setColumnWidthMode( 0, QListView::Manual);
460 ListView1->setColumnAlignment(1,QListView::AlignCenter); 551 ListView1->setColumnAlignment( 1, QListView::AlignCenter);
461 ListView1->setColumnAlignment(2,QListView::AlignRight); 552 ListView1->setColumnAlignment( 2, QListView::AlignRight);
462 ListView1->setColumnAlignment(3,QListView::AlignLeft); 553 ListView1->setColumnAlignment( 3, QListView::AlignLeft);
463 ListView1->setAllColumnsShowFocus( true ); 554 ListView1->setAllColumnsShowFocus( true );
464 QPEApplication::setStylusOperation( ListView1->viewport(),QPEApplication::RightOnHold); 555 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold);
465 556
466 TabWidget->insertTab( tab, tr( "Files" ) ); 557 TabWidget->insertTab( tab, tr( "Files" ) );
@@ -468,18 +559,8 @@ void QtRec::init() {
468 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 559 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
469 tab_3 = new QWidget( TabWidget, "tab_3" ); 560 tab_3 = new QWidget( TabWidget, "tab_3" );
561 QGridLayout *glayout3 = new QGridLayout( tab_3 );
562 glayout3->setSpacing( 2);
563 glayout3->setMargin( 2);
470 //////////////////////////////////// 564 ////////////////////////////////////
471
472 Layout19 = new QHBoxLayout( tab_3);
473 Layout19->setSpacing( 2 );
474 Layout19->setMargin( 0 );
475
476 Layout18 = new QVBoxLayout(this);
477 Layout18->setSpacing( 2 );
478 Layout18->setMargin( 0 );
479
480 Layout17 = new QHBoxLayout(this);
481 Layout17->setSpacing( 2 );
482 Layout17->setMargin( 0 );
483
484 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 565 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
485 sampleGroup->setTitle( tr( "Sample Rate" ) ); 566 sampleGroup->setTitle( tr( "Sample Rate" ) );
@@ -499,43 +580,32 @@ void QtRec::init() {
499 //#endif 580 //#endif
500 581
501 Layout17->addWidget( sampleGroup ); 582 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
502 583
503 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 584 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
504 sizeGroup->setTitle( tr( "Limit Size" ) ); 585 sizeGroup->setTitle( tr( "Limit Size" ) );
505 sizeGroup->setFixedSize(80,50); 586 sizeGroup->setFixedSize( 80, 50);
506 587
507 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 588 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
508 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 589 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
509 sizeLimitCombo->insertItem(tr("Unlimited")); 590 sizeLimitCombo->insertItem(tr("Unlimited"));
591
510 for(int i=1;i<13; i++) { 592 for(int i=1;i<13; i++) {
511 sizeLimitCombo->insertItem( QString::number(i*5)); 593 sizeLimitCombo->insertItem( QString::number( i * 5));
512 } 594 }
513 595
514// sizeLimitCombo->insertItem(tr("5 secs"));
515// sizeLimitCombo->insertItem(tr("10 secs"));
516// sizeLimitCombo->insertItem(tr("15 secs"));
517// sizeLimitCombo->insertItem(tr("20 secs"));
518
519 // Layout18->addWidget( sizeGroup );
520 Layout17->addWidget( sizeGroup );
521
522 Layout18->addLayout( Layout17 );
523
524 Layout16 = new QHBoxLayout(this);
525 Layout16->setSpacing( 2 );
526 Layout16->setMargin( 0 );
527 596
597 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1);
528 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 598 dirGroup = new QGroupBox( tab_3, "dirGroup" );
529 dirGroup->setTitle( tr( "File Directory" ) ); 599 dirGroup->setTitle( tr( "File Directory" ) );
530 dirGroup->setFixedSize(130,50); 600 dirGroup->setFixedSize( 130, 50);
531 601
532 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 602 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
533 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 603 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
534 604
535 Layout18->addWidget( dirGroup ); 605 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
536 606
537 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 607 bitGroup = new QGroupBox( tab_3, "bitGroup" );
538 bitGroup->setTitle( tr( "Bit Depth" ) ); 608 bitGroup->setTitle( tr( "Bit Depth" ) );
539 bitGroup->setFixedSize(65,50); 609 bitGroup->setFixedSize( 65, 50);
540 610
541 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 611 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
@@ -544,19 +614,18 @@ void QtRec::init() {
544 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 614 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
545 615
546 Layout18->addWidget( bitGroup ); 616 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
547 617
548 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); 618 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
549 Layout18->addWidget( compressionCheckBox );
550 619
551 autoMuteCheckBox= new QCheckBox ( tr("auto Mute"), tab_3 ); 620 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
552 Layout18->addWidget( autoMuteCheckBox ); 621 stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 );
553 622
554 Layout19->addLayout( Layout18 ); 623 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
624 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
625 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
555 626
556 QWidget *d = QApplication::desktop(); 627 QWidget *d = QApplication::desktop();
557 int width=d->width(); 628 int width = d->width();
558 int height=d->height(); 629 int height = d->height();
559
560
561 630
562 if( width < height) { 631 if( width < height) {
@@ -569,10 +638,9 @@ void QtRec::init() {
569 Layout19a->setMargin( 0 ); 638 Layout19a->setMargin( 0 );
570 639
571 640 Layout15 = new QVBoxLayout( this);
572 Layout15 = new QVBoxLayout(this);
573 Layout15->setSpacing( 2 ); 641 Layout15->setSpacing( 2 );
574 Layout15->setMargin( 0 ); 642 Layout15->setMargin( 0 );
575 643
576 Layout15b = new QVBoxLayout(this); 644 Layout15b = new QVBoxLayout( this);
577 Layout15b->setSpacing( 2 ); 645 Layout15b->setSpacing( 2 );
578 Layout15b->setMargin( 0 ); 646 Layout15b->setMargin( 0 );
@@ -580,5 +648,5 @@ void QtRec::init() {
580 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 648 TextLabel2 = new QLabel( tab_5, "InputLabel" );
581 TextLabel2->setText( tr( "In")); 649 TextLabel2->setText( tr( "In"));
582 TextLabel2->setFixedWidth(35); 650 TextLabel2->setFixedWidth( 35);
583 Layout15->addWidget( TextLabel2 ); 651 Layout15->addWidget( TextLabel2 );
584 652
@@ -588,9 +656,9 @@ void QtRec::init() {
588 656
589 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 657 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
590 InputSlider->setTickmarks(QSlider::Both); 658 InputSlider->setTickmarks( QSlider::Both);
591 Layout15->addWidget( InputSlider); 659 Layout15->addWidget( InputSlider);
592 660
593 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 661 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
594 OutputSlider->setTickmarks(QSlider::Both); 662 OutputSlider->setTickmarks( QSlider::Both);
595 663
596 Layout15b->addWidget( OutputSlider ); 664 Layout15b->addWidget( OutputSlider );
@@ -635,9 +703,9 @@ void QtRec::init() {
635 703
636 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" ); 704 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_3, (const char *) "InputSlider" );
637 // InputSlider->setTickmarks(QSlider::Both); 705 InputSlider->setTickmarks(QSlider::Both);
638 Layout15->addWidget( InputSlider); 706 Layout15->addWidget( InputSlider);
639 707
640 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" ); 708 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_3,(const char *) "OutputSlider" );
641 // OutputSlider->setTickmarks(QSlider::Both); 709 OutputSlider->setTickmarks(QSlider::Both);
642 710
643 Layout15b->addWidget( OutputSlider ); 711 Layout15b->addWidget( OutputSlider );
@@ -660,33 +728,10 @@ void QtRec::init() {
660 } 728 }
661 729
730 waveform = new Waveform( this, "waveform" );
731// waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) );
732 waveform->setMinimumSize( QSize( 0, 50 ) );
662 733
663 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 734 layout->addMultiCellWidget( waveform, 8, 8, 0, 7 );
664 735 waveform->setBackgroundColor ( black );
665// tab_4 = new QWidget( TabWidget, "tab_4" );
666// QGridLayout *layout4 = new QGridLayout( tab_4);
667// layout4->setSpacing( 2);
668// layout4->setMargin( 2);
669// TabWidget->insertTab( tab_4, tr( "Help"));
670
671// ///////////////////////////////////////////// FIXME change to a real helpfile path
672// QString url="/index.html";
673// HelpWindow *help = new HelpWindow( url, ".", tab_4, "opierec_help");
674// layout4->addMultiCellWidget( help, 0, 1, 0, 1);
675// if( !QFile(url).exists()) {
676// help->hide();
677// //help->showMaximized();
678// QLabel *helpLabel;
679// helpLabel = new QLabel( tab_4, "TimeLabel" );
680// layout4->addMultiCellWidget( helpLabel, 0, 3, 0, 4 );
681// helpLabel->setText( "<B>OpieRec</B><br>"
682// "Records files in standard wav format<br>"
683// "or a compressed version<br>"
684// "For help, please email the author<br>"
685// "<B>OpieRec</B> is copyright&copy; 2002 by"
686// " L.J. Potter<br>llornkcor@handhelds.org<BR>"
687// "and is licensed under the <B>QPL</B>");
688// }
689 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
690
691} 736}
692 737
@@ -699,6 +744,7 @@ void QtRec::initIconView() {
699 QPixmap image0( ( const char** ) image0_data ); 744 QPixmap image0( ( const char** ) image0_data );
700 745
701
702 int nFiles = cfg.readNumEntry("NumberofFiles",0); 746 int nFiles = cfg.readNumEntry("NumberofFiles",0);
747 qDebug("init number of files %d", nFiles);
748
703 for(int i=1;i<= nFiles;i++) { 749 for(int i=1;i<= nFiles;i++) {
704 750
@@ -706,8 +752,7 @@ void QtRec::initIconView() {
706 QString fileS, mediaLocation, fileDate, filePath; 752 QString fileS, mediaLocation, fileDate, filePath;
707 753
708 temp.sprintf("%d",i); 754 temp.sprintf( "%d",i);
709 temp=cfg.readEntry(temp,""); //reads currentFile 755 temp = cfg.readEntry( temp,""); //reads currentFile
710 filePath = cfg.readEntry(temp,""); //currentFileName 756 filePath = cfg.readEntry( temp,""); //currentFileName
711 // qDebug(filePath);
712 757
713 QFileInfo info(filePath); 758 QFileInfo info(filePath);
@@ -715,9 +760,9 @@ void QtRec::initIconView() {
715 760
716 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 761 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
717 mediaLocation=getStorage( filePath); 762 mediaLocation = getStorage( filePath);
718 if(info.exists()) { 763 if( info.exists()) {
719 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); 764 item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate);
720 item->setPixmap( 0, image0); 765 item->setPixmap( 0, image0);
721 if(currentFileName == filePath) 766 if( currentFileName == filePath)
722 ListView1->setSelected( item, true); 767 ListView1->setSelected( item, true);
723 } 768 }
@@ -728,32 +773,57 @@ void QtRec::initConnections() {
728 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 773 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
729 774
730 connect( toBeginningButton, SIGNAL( pressed()), this, SLOT( rewindPressed() )); 775 connect( toBeginningButton, SIGNAL( pressed()),
731 connect( toBeginningButton, SIGNAL( released()), this, SLOT( rewindReleased() )); 776 this, SLOT( rewindPressed() ));
732 connect( toEndButton, SIGNAL( pressed()), this, SLOT( FastforwardPressed() )); 777 connect( toBeginningButton, SIGNAL( released()),
733 connect( toEndButton, SIGNAL( released()), this, SLOT( FastforwardReleased() )); 778 this, SLOT( rewindReleased() ));
734 connect( deleteSoundButton, SIGNAL(released()), this, SLOT( deleteSound() )); 779 connect( toEndButton, SIGNAL( pressed()),
735 connect( Stop_PushButton, SIGNAL(released()), this, SLOT( doPlayBtn() )); 780 this, SLOT( FastforwardPressed() ));
736 connect( Rec_PushButton, SIGNAL(released()), this, SLOT( newSound() ) ); 781 connect( toEndButton, SIGNAL( released()),
737 connect( TabWidget, SIGNAL( currentChanged( QWidget*)),this, SLOT(thisTab(QWidget*) )); 782 this, SLOT( FastforwardReleased() ));
738 connect( OutputSlider, SIGNAL(sliderReleased()), this, SLOT( changedOutVolume()) ); 783 connect( deleteSoundButton, SIGNAL(released()),
739 connect( InputSlider, SIGNAL(sliderReleased()), this, SLOT( changedInVolume()) ); 784 this, SLOT( deleteSound() ));
740 785 connect( Stop_PushButton, SIGNAL(released()),
741 // connect( OutputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedOutVolume(int)) ); 786 this, SLOT( doPlayBtn() ));
742 // connect( InputSlider, SIGNAL(valueChanged( int)), this, SLOT(changedInVolume(int)) ); 787 connect( Rec_PushButton, SIGNAL(released()),
743 788 this, SLOT( newSound() ) );
744 connect( sampleRateComboBox, SIGNAL(activated( int)), this, SLOT( changesamplerateCombo(int)) ); 789 connect( TabWidget, SIGNAL( currentChanged( QWidget*)),
745 connect( bitRateComboBox, SIGNAL(activated( int)), this, SLOT( changebitrateCombo(int)) ); 790 this, SLOT(thisTab(QWidget*) ));
746 connect( directoryComboBox, SIGNAL(activated( int)), this, SLOT( changeDirCombo(int)) ); 791 connect( OutputSlider, SIGNAL(sliderReleased()),
747 connect( sizeLimitCombo, SIGNAL(activated( int)), this, SLOT( changeSizeLimitCombo(int)) ); 792 this, SLOT( changedOutVolume()) );
748 connect( outMuteCheckBox, SIGNAL(toggled( bool)), this, SLOT( doVolMuting(bool)) ); 793 connect( InputSlider, SIGNAL(sliderReleased()),
749 connect( inMuteCheckBox , SIGNAL(toggled( bool)), this, SLOT( doMicMuting(bool)) ); 794 this, SLOT( changedInVolume()) );
750 connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)),this,SLOT( itClick(QListViewItem*))); 795
796 connect( sampleRateComboBox, SIGNAL(activated( int)),
797 this, SLOT( changesamplerateCombo(int)) );
798 connect( bitRateComboBox, SIGNAL(activated( int)),
799 this, SLOT( changebitrateCombo(int)) );
800
801 connect( directoryComboBox, SIGNAL(activated( int)),
802 this, SLOT( changeDirCombo(int)) );
803 connect( sizeLimitCombo, SIGNAL(activated( int)),
804 this, SLOT( changeSizeLimitCombo(int)) );
805
806 connect( stereoCheckBox, SIGNAL(toggled( bool)),
807 this, SLOT( changeStereoCheck(bool)) );
808
809 connect( outMuteCheckBox, SIGNAL(toggled( bool)),
810 this, SLOT( doVolMuting(bool)) );
811 connect( inMuteCheckBox , SIGNAL(toggled( bool)),
812 this, SLOT( doMicMuting(bool)) );
813
814 connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)),
815 this,SLOT( itClick(QListViewItem*)));
751 connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 816 connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
752 this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); 817 this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) );
753 connect( timeSlider, SIGNAL( sliderMoved( int)), this, SLOT( changeTimeSlider(int) )); 818 connect( timeSlider, SIGNAL( sliderMoved( int)),
754 connect( timeSlider, SIGNAL( sliderPressed( )), this, SLOT( timeSliderPressed() )); 819 this, SLOT( changeTimeSlider(int) ));
755 connect( timeSlider, SIGNAL( sliderReleased( )), this, SLOT( timeSliderReleased() )); 820 connect( timeSlider, SIGNAL( sliderPressed( )),
756 connect( compressionCheckBox, SIGNAL( toggled(bool)),this, SLOT( compressionSelected(bool))); 821 this, SLOT( timeSliderPressed() ));
757 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),this, SLOT( slotAutoMute(bool))); 822 connect( timeSlider, SIGNAL( sliderReleased( )),
823 this, SLOT( timeSliderReleased() ));
824 connect( compressionCheckBox, SIGNAL( toggled(bool)),
825 this, SLOT( compressionSelected(bool)));
826 connect( autoMuteCheckBox, SIGNAL( toggled(bool)),
827 this, SLOT( slotAutoMute(bool)));
758} 828}
759 829
@@ -768,5 +838,5 @@ void QtRec::initConfig() {
768 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 838 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
769 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 839 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
770 if(index == fred) { 840 if( index == fred) {
771 filePara.sampleRate = fred; 841 filePara.sampleRate = fred;
772 sampleRateComboBox->setCurrentItem(ws); 842 sampleRateComboBox->setCurrentItem(ws);
@@ -774,5 +844,5 @@ void QtRec::initConfig() {
774 } 844 }
775 845
776 i=cfg.readNumEntry("bitrate",16); 846 i = cfg.readNumEntry("bitrate",16);
777 if(i == 16) 847 if(i == 16)
778 bitRateComboBox->setCurrentItem( 0); 848 bitRateComboBox->setCurrentItem( 0);
@@ -781,13 +851,15 @@ void QtRec::initConfig() {
781 filePara.resolution = i; 851 filePara.resolution = i;
782 852
783 i=cfg.readNumEntry("sizeLimit", 5 ); 853 i = cfg.readNumEntry("sizeLimit", 5 );
784 QString temp; 854 QString temp;
785// for(int i=1;i<13; i++) {
786// temp = sizeLimitCombo->text(i);
787
788// sizeLimitCombo->insertItem( QString::number(i*5)+tr(" secs"));
789// }
790 sizeLimitCombo->setCurrentItem((i/5)); 855 sizeLimitCombo->setCurrentItem((i/5));
791 856
857 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1));
858 if( stereoCheckBox->isChecked()) {
859 filePara.channels = 2;
860 } else {
861 filePara.channels = 1;
862 }
863
792 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 864 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
793 if( compressionCheckBox->isChecked()) { 865 if( compressionCheckBox->isChecked()) {
@@ -809,11 +881,7 @@ void QtRec::initConfig() {
809} 881}
810 882
811//================
812
813void QtRec::stop() { 883void QtRec::stop() {
814 // qDebug("<<<<<<<<<stop()"); 884 qWarning("STOP");
815 setRecordButton(false); 885 setRecordButton(false);
816 monitoring=false;
817 stopped=true;
818 886
819 if( !recording) 887 if( !recording)
@@ -822,5 +890,4 @@ void QtRec::stop() {
822 endRecording(); 890 endRecording();
823 timeSlider->setValue(0); 891 timeSlider->setValue(0);
824 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
825} 892}
826 893
@@ -839,11 +906,11 @@ void QtRec::doPlayBtn() {
839 906
840void QtRec::start() { //play 907void QtRec::start() { //play
841 if(stopped) { 908 if( stopped) {
842 QPixmap image3( ( const char** ) image3_data ); 909 QPixmap image3( ( const char** ) image3_data );
843 Stop_PushButton->setPixmap( image3 ); 910 Stop_PushButton->setPixmap( image3 );
844 Stop_PushButton->setDown(true); 911 Stop_PushButton->setDown( true);
845 stopped=false; 912 stopped = false;
846 paused=false; 913 paused = false;
847 secCount=1; 914 secCount = 1;
848 915
849 if( openPlayFile()) 916 if( openPlayFile())
@@ -854,40 +921,56 @@ void QtRec::start() { //play
854 921
855bool QtRec::rec() { //record 922bool QtRec::rec() { //record
923 QString timeString;
924 timeString.sprintf("%.0f", 0.0);
925 timeLabel->setText( timeString+ " seconds");
856 if(!stopped) { 926 if(!stopped) {
857 monitoring=true; 927 monitoring = true;
858 return false; 928 return false;
859 } else { 929 } else {
860 secCount=1; 930 secCount = 1;
861 playLabel2->setText(tr("Stop")); 931 playLabel2->setText(tr("Stop"));
862 monitoring=false; 932 monitoring = false;
863 setRecordButton(true); 933 setRecordButton( true);
864 stopped=false;
865 934
866 if( setupAudio( true)) 935 if( setupAudio( true))
867 if(setUpFile()) { 936 if(setUpFile()) {
868 int fileSize=0; 937 int fileSize = 0;
869 Config cfg("OpieRec"); 938 Config cfg("OpieRec");
870 cfg.setGroup("Settings"); 939 cfg.setGroup("Settings");
940// qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d",
941// soundDevice->getDeviceBits(),
942// soundDevice->getDeviceRate(),
943// soundDevice->getDeviceChannels());
944
871 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 945 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
872 // qDebug("sample rate is %d", filePara.sampleRate); 946// qDebug("sample rate is %d", filePara.sampleRate);
873 filePara.SecondsToRecord = getCurrentSizeLimit(); 947 filePara.SecondsToRecord = getCurrentSizeLimit();
874 948
949// qDebug("size limit %d sec", filePara.SecondsToRecord);
875 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 950 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
876 951
877 if( filePara.SecondsToRecord == 0) { 952 if( filePara.SecondsToRecord == 0) {
878 fileSize = diskSize; 953 fileSize = diskSize;
879 } else if( filePara.format==WAVE_FORMAT_PCM) { 954 } else if( filePara.format == WAVE_FORMAT_PCM) {
955// qDebug("WAVE_FORMAT_PCM");
880 fileSize = (filePara.SecondsToRecord ) * filePara.channels 956 fileSize = (filePara.SecondsToRecord ) * filePara.channels
881 * filePara.sampleRate *(filePara.resolution/8)+1000; 957 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
882 } else { 958 } else {
959// qDebug("WAVE_FORMAT_DVI_ADPCM");
883 fileSize = ((filePara.SecondsToRecord) * filePara.channels 960 fileSize = ((filePara.SecondsToRecord) * filePara.channels
884 * filePara.sampleRate *(filePara.resolution/8) )/4+250; 961 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
885 } 962 }
886 963
887 filePara.samplesToRecord = fileSize; 964 filePara.samplesToRecord = fileSize;
888 if(paused) { 965 qDebug("filesize should be %d, bits %d, rate %d",
966 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
967 if( paused) {
889 paused = false; 968 paused = false;
890 } 969 }
970 // else {
971 qDebug("Setting timeslider %d", filePara.samplesToRecord);
972 // if(fileSize != 0)
891 timeSlider->setRange(0, filePara.samplesToRecord); 973 timeSlider->setRange(0, filePara.samplesToRecord);
974 // }
892 975
893 if( diskSize < fileSize/1024) { 976 if( diskSize < fileSize/1024) {
@@ -905,33 +988,17 @@ bool QtRec::rec() { //record
905#endif 988#endif
906 filePara.fileName=currentFile.latin1(); 989 filePara.fileName=currentFile.latin1();
990// qDebug("Start recording thread");
991 stopped = false;
907 992
908 pthread_t thread1; 993 pthread_t thread1;
909 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 994 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
910 toBeginningButton->setEnabled(false); 995 toBeginningButton->setEnabled( false);
911 toEndButton->setEnabled(false); 996 toEndButton->setEnabled( false);
912 997
913 startTimer(1000); 998 startTimer(1000);
999// quickRec();
914 } 1000 }
915 } //end setUpFile 1001 } //end setUpFile
916 } //end setupAudio 1002 } //end setupAudio
917 // _exit( 0);
918
919 // ///* default:
920// // /* pid greater than zero is parent getting the child's pid */
921// /* printf("Child's pid is %d\n",pid);
922// waitpid( pid, &status, 0);
923// printf("Child[%d] exited with status %d\n", pid, status);*/
924 // while (wait(NULL) != pid)
925// ;
926// printf("child %ld terminated normally, return status is zero\n", (long) pid);
927 // endRecording();
928/* else { //device was not opened
929 qDebug("Audio device open failed");
930 return false;
931 }
932 }*/
933// } //end fork
934// }
935// }
936 return true; 1003 return true;
937} 1004}
@@ -940,10 +1007,10 @@ bool QtRec::rec() { //record
940void QtRec::thisTab(QWidget* widg) { 1007void QtRec::thisTab(QWidget* widg) {
941 if(widg != NULL) { 1008 if(widg != NULL) {
942 int index=TabWidget->currentPageIndex(); 1009 int index = TabWidget->currentPageIndex();
943 1010
944// if(index==0) { //file page 1011 if(index == 0) { //file page
945// } 1012 }
946 1013
947 if(index ==1) { //control page 1014 if(index == 1) { //control page
948 fillDirectoryCombo(); 1015 fillDirectoryCombo();
949// soundDevice->getOutVol(); 1016// soundDevice->getOutVol();
@@ -951,6 +1018,7 @@ void QtRec::thisTab(QWidget* widg) {
951 } 1018 }
952 1019
953// if(index==2) { //help page 1020 if( index==2) { //help page
954// } 1021 }
1022
955 qApp->processEvents(); 1023 qApp->processEvents();
956 update(); 1024 update();
@@ -960,4 +1028,5 @@ void QtRec::thisTab(QWidget* widg) {
960void QtRec::getOutVol( ) { 1028void QtRec::getOutVol( ) {
961 filePara.outVol = soundDevice->getOutVolume(); 1029 filePara.outVol = soundDevice->getOutVolume();
1030// qDebug("out vol %d", filePara.outVol);
962 OutputSlider->setValue( -filePara.outVol); 1031 OutputSlider->setValue( -filePara.outVol);
963} 1032}
@@ -965,9 +1034,10 @@ void QtRec::getOutVol( ) {
965void QtRec::getInVol() { 1034void QtRec::getInVol() {
966 filePara.inVol = soundDevice->getInVolume(); 1035 filePara.inVol = soundDevice->getInVolume();
1036// qDebug("in vol %d", filePara.inVol);
967 InputSlider->setValue( -filePara.inVol); 1037 InputSlider->setValue( -filePara.inVol);
968} 1038}
969 1039
970void QtRec::changedOutVolume() { 1040void QtRec::changedOutVolume() {
971 soundDevice->changedOutVolume(-OutputSlider->value()); 1041 soundDevice->changedOutVolume( -OutputSlider->value());
972} 1042}
973 1043
@@ -984,5 +1054,6 @@ bool QtRec::setupAudio( bool b) {
984 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 1054 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
985 1055
986 if( !b){ // we want to play 1056 if( !b) {
1057// we want to play
987 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1058 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
988 sampleformat = AFMT_S16_LE; 1059 sampleformat = AFMT_S16_LE;
@@ -990,11 +1061,12 @@ bool QtRec::setupAudio( bool b) {
990 } else { 1061 } else {
991 sampleformat = AFMT_U8; 1062 sampleformat = AFMT_U8;
992 filePara.resolution=8; 1063 filePara.resolution = 8;
993 } 1064 }
994 1065
995 stereo = filePara.channels = 1; 1066 stereo = filePara.channels;
996 flags= O_WRONLY; 1067 flags = O_WRONLY;
997 dspString = DSPSTROUT; 1068 dspString = DSPSTROUT;
998 mixerString = DSPSTRMIXEROUT; 1069 mixerString = DSPSTRMIXEROUT;
1070 recording = false;
999 } else { // we want to record 1071 } else { // we want to record
1000 1072
@@ -1005,21 +1077,33 @@ bool QtRec::setupAudio( bool b) {
1005 1077
1006 if( !compressionCheckBox->isChecked()) { 1078 if( !compressionCheckBox->isChecked()) {
1007 filePara.format=WAVE_FORMAT_PCM; 1079 filePara.format = WAVE_FORMAT_PCM;
1080// qDebug("WAVE_FORMAT_PCM");
1008 } else { 1081 } else {
1009 filePara.format=WAVE_FORMAT_DVI_ADPCM; 1082 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1010 sampleformat=AFMT_S16_LE; 1083 sampleformat = AFMT_S16_LE;
1084// qDebug("WAVE_FORMAT_DVI_ADPCM");
1011 } 1085 }
1012 1086
1013 stereo = filePara.channels = 1; 1087 stereo = filePara.channels;
1088// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1014 flags= O_RDWR; 1089 flags= O_RDWR;
1090// flags= O_RDONLY;
1015 dspString = DSPSTRIN; 1091 dspString = DSPSTRIN;
1016 mixerString = DSPSTRMIXEROUT; 1092 mixerString = DSPSTRMIXEROUT;
1093 recording = true;
1017 } 1094 }
1018 1095
1019 // if(soundDevice) delete soundDevice; 1096 // if(soundDevice) delete soundDevice;
1097 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat);
1098 qWarning("change waveform settings");
1099 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1100
1020 soundDevice = new Device( this, dspString, mixerString, b); 1101 soundDevice = new Device( this, dspString, mixerString, b);
1021// soundDevice->openDsp(); 1102// soundDevice->openDsp();
1022 soundDevice->reset(); 1103 soundDevice->reset();
1023 1104
1105 qDebug("device has been made %d", soundDevice->sd);
1106
1107 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1024 soundDevice->setDeviceFormat( sampleformat); 1108 soundDevice->setDeviceFormat( sampleformat);
1025 soundDevice->setDeviceChannels( filePara.channels); 1109 soundDevice->setDeviceChannels( filePara.channels);
@@ -1031,13 +1115,13 @@ bool QtRec::setupAudio( bool b) {
1031 soundDevice->getDeviceFragSize(); 1115 soundDevice->getDeviceFragSize();
1032#endif 1116#endif
1033 1117 /////////////////
1034 filePara.sd = soundDevice->sd; 1118 filePara.sd = soundDevice->sd;
1035 1119
1036 if ( filePara.sd == -1) { 1120 if ( filePara.sd == -1) {
1037 monitoring=false; 1121
1038 stopped=true; 1122 monitoring = false;
1123 stopped = true;
1039 update(); 1124 update();
1040 setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ ); 1125 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
1041 stopped=true;
1042 return false; 1126 return false;
1043 } 1127 }
@@ -1050,5 +1134,5 @@ bool QtRec::setupAudio( bool b) {
1050 1134
1051bool QtRec::setUpFile() { //setup file for recording 1135bool QtRec::setUpFile() { //setup file for recording
1052 // qDebug("Setting up wavfile"); 1136// qDebug("Setting up wavfile");
1053// if(wavFile) delete wavFile; 1137// if(wavFile) delete wavFile;
1054 wavFile = new WavFile( this, (const QString &)"", 1138 wavFile = new WavFile( this, (const QString &)"",
@@ -1063,5 +1147,5 @@ bool QtRec::setUpFile() { //setup file for recording
1063 return false; 1147 return false;
1064 } else { 1148 } else {
1065 filePara.channels=1; 1149// filePara.channels=1;
1066 } 1150 }
1067 return true; 1151 return true;
@@ -1071,15 +1155,6 @@ bool QtRec::setUpFile() { //setup file for recording
1071bool QtRec::doPlay() { 1155bool QtRec::doPlay() {
1072 1156
1073// pthread_t thread2;
1074// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1075
1076 // qDebug("doPlay file %d", filePara.fd);
1077 int bytesWritten, number;
1078 recording = false;
1079// int number=0;
1080 if( !paused) { 1157 if( !paused) {
1081 // qDebug("new"); 1158 total = 0;
1082 total=0;
1083 bytesWritten=0;
1084 filePara.numberOfRecordedSeconds = 0; 1159 filePara.numberOfRecordedSeconds = 0;
1085 } else { 1160 } else {
@@ -1087,145 +1162,32 @@ bool QtRec::doPlay() {
1087 secCount = (int)filePara.numberOfRecordedSeconds; 1162 secCount = (int)filePara.numberOfRecordedSeconds;
1088 } 1163 }
1089 playing=true; 1164 playing = true;
1090 number=0; 1165 stopped = false;
1166 recording = false;
1091 1167
1092 QString num; 1168 QString num;
1093// block=BUFSIZE; 1169 qDebug( "Play number of samples %d", filePara.numberSamples);
1094 timeSlider->setRange(0, filePara.numberSamples); 1170
1095 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1171// timeSlider->setRange( 0, filePara.numberSamples);
1172
1173 timeString.sprintf("%d", filePara.numberOfRecordedSeconds);
1096 timeLabel->setText( timeString+ tr(" seconds")); 1174 timeLabel->setText( timeString+ tr(" seconds"));
1097 1175
1098// if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
1099// // qDebug("WAVE_FORMAT_DVI_ADPCM");
1100// } else {
1101// // qDebug("WAVE_FORMAT_PCM");
1102// }
1103 QString msg; 1176 QString msg;
1104 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1177 msg.sprintf("%d, %d, %d",
1178 filePara.sampleRate,
1179 filePara.channels,
1180 filePara.resolution);
1105#ifdef DEV_VERSION 1181#ifdef DEV_VERSION
1106 setCaption( msg); 1182 setCaption( msg);
1107#endif 1183#endif
1108 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
1109 // qDebug("16 bit");
1110
1111 startTimer(1000);
1112
1113 if( filePara.format==WAVE_FORMAT_DVI_ADPCM) {
1114 char abuf[BUFSIZE/2];
1115 short sbuf[BUFSIZE];
1116 short sbuf2[BUFSIZE*2];
1117 memset( abuf, 0, BUFSIZE / 2);
1118 memset( sbuf, 0, BUFSIZE);
1119 memset( sbuf2, 0, BUFSIZE * 2);
1120// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
1121 for(;;) { // play loop
1122 if (stopped)
1123 break; // stop if playing was set to false
1124
1125
1126 number=::read( filePara.fd, abuf, BUFSIZE/2);
1127 adpcm_decoder( abuf, sbuf, number*2, &decoder_state);
1128
1129// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
1130// sbuf2[i+1]=sbuf2[i]=sbuf[i];
1131// }
1132
1133 bytesWritten = write ( filePara.sd, sbuf, number*4);
1134 // if(filePara.channels==1)
1135 // total += bytesWritten/2; //mono
1136 // else
1137 total += bytesWritten;
1138 timeSlider->setValue( total / 4);
1139
1140 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
1141
1142 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1143// if(filePara.numberOfRecordedSeconds>1)
1144 timeLabel->setText( timeString+ tr(" seconds"));
1145// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
1146// printf("playing number %d, bytes %d, total %d totalsamples %d number recorded seconds %.2f\r",
1147// number, bytesWritten, total/4, filePara.numberSamples, filePara.numberOfRecordedSeconds);
1148// fflush(stdout);
1149
1150 qApp->processEvents();
1151
1152 if( bytesWritten <= 0 ){//|| secCount > filePara.numberOfRecordedSeconds ) {
1153 stopped = true;
1154 endPlaying();
1155 }
1156 }
1157 } else {
1158 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
1159 short inbuffer[BUFSIZE], outbuffer[BUFSIZE];
1160 memset( inbuffer, 0, BUFSIZE);
1161 memset( outbuffer, 0, BUFSIZE);
1162
1163 for(;;) { // play loop
1164 if (stopped)
1165 break; // stop if playing was set to false
1166 number=::read( filePara.fd, inbuffer, BUFSIZE);
1167// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
1168// // for (int i=0;i< number ; i++) { //2*i is left channel
1169// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
1170// }
1171
1172 bytesWritten = ::write( filePara.sd, inbuffer, number);
1173 //-------------->>>> out to device
1174 // total+=bytesWritten;
1175 // if(filePara.channels==1)
1176 // total += bytesWritten/2; //mono
1177 // else
1178 total += bytesWritten;
1179
1180 timeSlider->setValue( total);
1181 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
1182
1183 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
1184 timeLabel->setText( timeString + tr(" seconds"));
1185
1186 qApp->processEvents();
1187 1184
1188 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) { 1185 startTimer( 1000);
1189 stopped = true; 1186 pthread_t thread2;
1190 endPlaying(); 1187 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1191 }
1192 }
1193// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
1194// fflush(stdout);
1195 } //end loop
1196 } else { /////////////////////////////// format = AFMT_U8;
1197 unsigned char unsigned_inbuffer[BUFSIZE];//, unsigned_outbuffer[BUFSIZE];
1198 memset( unsigned_inbuffer,0,BUFSIZE);
1199 for(;;) { // main loop
1200 if (stopped)
1201 break; // stop if playing was set to false
1202 number=::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
1203//data = (val >> 8) ^ 0x80;
1204 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
1205 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
1206 total+=bytesWritten;
1207 1188
1208 timeSlider->setValue( total); 1189 toBeginningButton->setEnabled( false);
1190 toEndButton->setEnabled( false);
1209 1191
1210 filePara.numberOfRecordedSeconds=(float)total/(float)filePara.sampleRate;
1211 timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
1212 timeLabel->setText( timeString + tr(" seconds"));
1213 qApp->processEvents();
1214
1215 if( bytesWritten <= 0 && secCount > filePara.numberOfRecordedSeconds ) {
1216 stopped = true;
1217 endPlaying();
1218 }
1219 // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
1220 // fflush(stdout);
1221 }
1222 }
1223
1224// qDebug("\nstopped or paused %d", total/4);
1225 if(!paused && !stopped) {
1226 stopped = true;
1227// endPlaying();
1228 endPlaying();
1229 }
1230 return true; 1192 return true;
1231} 1193}
@@ -1235,9 +1197,9 @@ void QtRec::changebitrateCombo(int i) {
1235 Config cfg("OpieRec"); 1197 Config cfg("OpieRec");
1236 cfg.setGroup("Settings"); 1198 cfg.setGroup("Settings");
1237 int bits=0; 1199 int bits = 0;
1238 if(i==0) { bits=16; } 1200 if( i == 0) { bits = 16; }
1239 else { bits=8; } 1201 else { bits=8; }
1240 cfg.writeEntry("bitrate", bits); 1202 cfg.writeEntry("bitrate", bits);
1241 filePara.resolution=bits; 1203 filePara.resolution = bits;
1242 cfg.write(); 1204 cfg.write();
1243} 1205}
@@ -1249,19 +1211,8 @@ void QtRec::changesamplerateCombo(int i) {
1249 bool ok; 1211 bool ok;
1250 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1212 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1251 cfg.writeEntry("samplerate",rate); 1213 cfg.writeEntry( "samplerate",rate);
1252 filePara.sampleRate=rate; 1214 filePara.sampleRate=rate;
1253/* soundDevice = new Device( this, DSPSTROUT, DSPSTRMIXER, false); 1215 qDebug( "Change sample rate %d", rate);
1254 soundDevice->openDsp();*/
1255//
1256// soundDevice->setDeviceFormat(AFMT_S16_LE);
1257// soundDevice->setDeviceChannels(filePara.channels);
1258// soundDevice->setDeviceRate(filePara.sampleRate);
1259//
1260// soundDevice->closeDevice( true);
1261// soundDevice=0;
1262// delete soundDevice;
1263 // qDebug("Change sample rate %d", rate);
1264 cfg.write(); 1216 cfg.write();
1265
1266} 1217}
1267 1218
@@ -1280,7 +1231,7 @@ void QtRec::changeDirCombo(int index) {
1280 (*it)->name() == sName ) { 1231 (*it)->name() == sName ) {
1281 const QString path = (*it)->path(); 1232 const QString path = (*it)->path();
1282 recDir = path; 1233 recDir = path;
1283 cfg.writeEntry("directory", recDir); 1234 cfg.writeEntry("directory", recDir);
1284 // qDebug("new rec dir "+recDir); 1235 qDebug("new rec dir "+recDir);
1285 } 1236 }
1286 } 1237 }
@@ -1297,16 +1248,12 @@ void QtRec::changeSizeLimitCombo(int) {
1297 1248
1298void QtRec::newSound() { 1249void QtRec::newSound() {
1299 // qDebug("<<<<<<<<<new sound");
1300
1301 if( !rec()) { 1250 if( !rec()) {
1302 // qDebug("rec() failed");
1303 endRecording(); 1251 endRecording();
1304 deleteSound(); 1252 deleteSound();
1305 } 1253 }
1306
1307} 1254}
1308 1255
1309void QtRec::itClick(QListViewItem *item) { 1256void QtRec::itClick(QListViewItem *item) {
1310 currentFile=item->text(0); 1257 currentFile = item->text(0);
1311 setCaption("OpieRecord "+currentFile); 1258 setCaption("OpieRecord "+currentFile);
1312} 1259}
@@ -1315,5 +1262,5 @@ void QtRec::deleteSound() {
1315 Config cfg("OpieRec"); 1262 Config cfg("OpieRec");
1316 cfg.setGroup("Sounds"); 1263 cfg.setGroup("Sounds");
1317 if( ListView1->currentItem() == NULL) 1264 if( ListView1->currentItem() == NULL)
1318 return; 1265 return;
1319#ifndef DEV_VERSION 1266#ifndef DEV_VERSION
@@ -1325,21 +1272,17 @@ void QtRec::deleteSound() {
1325 { 1272 {
1326 QString file = ListView1->currentItem()->text(0); 1273 QString file = ListView1->currentItem()->text(0);
1327 // qDebug("Filename to find is "+file);
1328 QString fileName; 1274 QString fileName;
1329 fileName = cfg.readEntry( file, ""); 1275 fileName = cfg.readEntry( file, "");
1330 QFile f(fileName); 1276 QFile f( fileName);
1331 // qDebug("fileName is "+fileName); 1277 if( f.exists())
1332 if(f.exists())
1333 if( !f.remove()) 1278 if( !f.remove())
1334 QMessageBox::message(tr("Error"),tr("Could not remove file.")); 1279 QMessageBox::message( tr("Error"), tr("Could not remove file."));
1335 1280
1336 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1281 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1337 bool found=false; 1282 bool found = false;
1338 for(int i=0;i<nFiles+1;i++) { 1283 for(int i=0;i<nFiles+1;i++) {
1339 // qDebug(cfg.readEntry(QString::number(i)));
1340 1284
1341 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1285 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1342 found = true; 1286 found = true;
1343// qDebug( cfg.readEntry(QString::number(i))+"\n" +cfg.readEntry(QString::number(i+1)) );
1344 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1287 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1345 } 1288 }
@@ -1348,16 +1291,14 @@ void QtRec::deleteSound() {
1348 } 1291 }
1349 1292
1350 cfg.removeEntry(cfg.readEntry(file)); 1293 cfg.removeEntry( cfg.readEntry( file));
1351 cfg.removeEntry( file); 1294 cfg.removeEntry( file);
1352 // cfg.removeEntry( QString::number(nFiles)); 1295 cfg.writeEntry( "NumberofFiles", nFiles-1);
1353 cfg.writeEntry("NumberofFiles", nFiles-1);
1354 cfg.write(); 1296 cfg.write();
1355 1297
1356 ListView1->takeItem( ListView1->currentItem() ); 1298 ListView1->takeItem( ListView1->currentItem() );
1357 // ListView1->takeItem( ListView1->itemAt(nFiles) );
1358 delete ListView1->currentItem(); 1299 delete ListView1->currentItem();
1359 1300
1360 ListView1->clear(); 1301 ListView1->clear();
1361 ListView1->setSelected(ListView1->firstChild(), true); 1302 ListView1->setSelected( ListView1->firstChild(), true);
1362 initIconView(); 1303 initIconView();
1363 update(); 1304 update();
@@ -1366,5 +1307,5 @@ void QtRec::deleteSound() {
1366 }; 1307 };
1367#endif 1308#endif
1368 setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ ); 1309 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1369 1310
1370} 1311}
@@ -1373,23 +1314,4 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
1373 1314
1374 switch ( e->key() ) { 1315 switch ( e->key() ) {
1375 /*
1376 vercel keys->
1377 right side
1378 0
1379 1 0x1030 Key_F1
1380 2 0x1031 Key_F2
1381 3 0x1032 Key_F3
1382 4 0x1016 Key_PageUp
1383 5 0x1017 Key_PageDown
1384 6
1385 ---------------
1386 left side
1387 Up 0x1013 Key_Up
1388 Down 0x1015 Key_Down
1389 Left 0x1012 Key_Left
1390 Right 0x1014 Key_Right
1391 0x1010 Key_Home
1392
1393 */
1394 // case Key_F1: 1316 // case Key_F1:
1395 // if(stopped && !recording) 1317 // if(stopped && !recording)
@@ -1431,5 +1353,5 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
1431 break; 1353 break;
1432 case Key_Left: { 1354 case Key_Left: {
1433 // qDebug("rewinding"); 1355 qDebug("rewinding");
1434 if( !e->isAutoRepeat()) 1356 if( !e->isAutoRepeat())
1435 rewindPressed(); 1357 rewindPressed();
@@ -1485,5 +1407,5 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1485 case Key_Up: 1407 case Key_Up:
1486 // stop(); 1408 // stop();
1487 // qDebug("Up"); 1409 qDebug("Up");
1488 break; 1410 break;
1489 case Key_Down: 1411 case Key_Down:
@@ -1493,9 +1415,9 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1493 break; 1415 break;
1494 case Key_Left: 1416 case Key_Left:
1495 // qDebug("Left"); 1417 qDebug("Left");
1496 rewindReleased(); 1418 rewindReleased();
1497 break; 1419 break;
1498 case Key_Right: 1420 case Key_Right:
1499 // qDebug("Right"); 1421 qDebug("Right");
1500 FastforwardReleased(); 1422 FastforwardReleased();
1501 break; 1423 break;
@@ -1504,40 +1426,37 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1504 1426
1505void QtRec::endRecording() { 1427void QtRec::endRecording() {
1506 // qDebug("endRecording"); 1428 monitoring = false;
1507 setRecordButton(false); 1429 recording = false;
1508 timeSlider->setValue(0); 1430 stopped = true;
1509 toBeginningButton->setEnabled(true); 1431 waveform->reset();
1510 toEndButton->setEnabled(true); 1432 setRecordButton( false);
1511 1433
1512 monitoring=false; 1434 toBeginningButton->setEnabled( true);
1435 toEndButton->setEnabled( true);
1513 1436
1514 killTimers(); 1437 killTimers();
1515 1438
1516 if(autoMute) 1439 if(autoMute)
1517 doMute(true); 1440 doMute( true);
1518 1441
1519 soundDevice->closeDevice( true); 1442 soundDevice->closeDevice( true);
1520 1443
1521 recording = false;
1522 stopped=true;
1523 t->stop();
1524
1525 if( wavFile->track.isOpen()) { 1444 if( wavFile->track.isOpen()) {
1526 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1445 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1527 // soundDevice->sd=-1; 1446 // soundDevice->sd=-1;
1528 filePara.numberSamples=0; 1447 filePara.numberSamples = 0;
1529 // filePara.sd=-1; 1448 // filePara.sd=-1;
1530 wavFile->closeFile(); 1449 wavFile->closeFile();
1531 filePara.fd=0; 1450 filePara.fd=0;
1532 1451
1533 if(wavFile->isTempFile()) { 1452 if( wavFile->isTempFile()) {
1534// move tmp file to regular file 1453// move tmp file to regular file
1535 QString cmd; 1454 QString cmd;
1536 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1455 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1537 // qDebug("moving tmp file to "+currentFileName); 1456// qDebug("moving tmp file to "+currentFileName);
1538 system(cmd.latin1()); 1457 system( cmd.latin1());
1539 } 1458 }
1540 1459
1541 // qDebug("Just moved "+wavFile->currentFileName); 1460 qDebug("Just moved " + wavFile->currentFileName);
1542 Config cfg("OpieRec"); 1461 Config cfg("OpieRec");
1543 cfg.setGroup("Sounds"); 1462 cfg.setGroup("Sounds");
@@ -1545,9 +1464,9 @@ void QtRec::endRecording() {
1545 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1464 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1546 1465
1547 currentFile = QFileInfo(wavFile->currentFileName).fileName(); 1466 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1548 currentFile=currentFile.left(currentFile.length()-4); 1467 currentFile = currentFile.left( currentFile.length() - 4);
1549 1468
1550 cfg.writeEntry( "NumberofFiles",nFiles+1); 1469 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1551 cfg.writeEntry( QString::number( nFiles+1), currentFile); 1470 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1552 cfg.writeEntry( currentFile, wavFile->currentFileName); 1471 cfg.writeEntry( currentFile, wavFile->currentFileName);
1553 1472
@@ -1555,8 +1474,8 @@ void QtRec::endRecording() {
1555 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1474 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1556 cfg.writeEntry( wavFile->currentFileName, time ); 1475 cfg.writeEntry( wavFile->currentFileName, time );
1557 // qDebug("writing config numberOfRecordedSeconds "+time); 1476// qDebug("writing config numberOfRecordedSeconds "+time);
1558 1477
1559 cfg.write(); 1478 cfg.write();
1560 // qDebug("finished recording"); 1479 qDebug("finished recording");
1561 timeLabel->setText(""); 1480 timeLabel->setText("");
1562 } 1481 }
@@ -1564,36 +1483,40 @@ void QtRec::endRecording() {
1564 if(soundDevice) delete soundDevice; 1483 if(soundDevice) delete soundDevice;
1565 1484
1485 timeSlider->setValue(0);
1566 initIconView(); 1486 initIconView();
1567 selectItemByName(currentFile); 1487 selectItemByName( currentFile);
1568} 1488}
1569 1489
1570void QtRec::endPlaying() { 1490void QtRec::endPlaying() {
1491 monitoring = false;
1492 recording = false;
1493 playing = false;
1494 stopped = true;
1495 waveform->reset();
1496// errorStop();
1497// qDebug("end playing");
1498 setRecordButton( false);
1571 1499
1572 // qDebug("end playing"); 1500 toBeginningButton->setEnabled( true);
1573 setRecordButton(false); 1501 toEndButton->setEnabled( true);
1574
1575 toBeginningButton->setEnabled(true);
1576 toEndButton->setEnabled(true);
1577 1502
1578 if(autoMute) 1503 if(autoMute)
1579 doMute(true); 1504 doMute( true);
1580 1505
1581 soundDevice->closeDevice( false); 1506 soundDevice->closeDevice( false);
1582 soundDevice->sd=-1; 1507 soundDevice->sd = -1;
1583 // if(soundDevice) delete soundDevice; 1508 // if(soundDevice) delete soundDevice;
1584 // qDebug("file and sound device closed"); 1509// qDebug("file and sound device closed");
1585 stopped=true;
1586 recording=false;
1587 playing=false;
1588 timeLabel->setText(""); 1510 timeLabel->setText("");
1589 monitoring=false;
1590 total = 0; 1511 total = 0;
1591 filePara.numberSamples=0; 1512 filePara.numberSamples = 0;
1592 filePara.sd=-1; 1513 filePara.sd = -1;
1593 wavFile->closeFile(); 1514// wavFile->closeFile();
1594 filePara.fd=0; 1515 filePara.fd = 0;
1595// if(wavFile) delete wavFile; //this crashes 1516// if(wavFile) delete wavFile; //this crashes
1596 1517
1597 // qDebug("track closed"); 1518// qDebug("track closed");
1519 killTimers();
1520 qWarning("reset slider");
1598 timeSlider->setValue(0); 1521 timeSlider->setValue(0);
1599 1522
@@ -1613,9 +1536,9 @@ bool QtRec::openPlayFile() {
1613 Config cfg("OpieRec"); 1536 Config cfg("OpieRec");
1614 cfg.setGroup("Sounds"); 1537 cfg.setGroup("Sounds");
1615 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1538 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1616 for(int i=0;i<nFiles+1;i++) { //look for file 1539 for(int i=0;i<nFiles+1;i++) { //look for file
1617 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1540 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1618 currentFileName=cfg.readEntry( currentFile, "" ); 1541 currentFileName = cfg.readEntry( currentFile, "" );
1619 // qDebug("opening for play: "+currentFileName); 1542 qDebug("opening for play: " + currentFileName);
1620 } 1543 }
1621 } 1544 }
@@ -1626,20 +1549,26 @@ bool QtRec::openPlayFile() {
1626 if(filePara.fd == -1) { 1549 if(filePara.fd == -1) {
1627 // if(!track.open(IO_ReadOnly)) { 1550 // if(!track.open(IO_ReadOnly)) {
1628 QString errorMsg=(QString)strerror(errno); 1551 QString errorMsg = (QString)strerror(errno);
1629 monitoring=false; 1552 monitoring = false;
1630 setCaption( tr( "OpieRecord " )/* + QString::number(VERSION)*/ ); 1553 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
1631 QMessageBox::message(tr("Note"),tr("Could not open audio file.\n") 1554 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
1632 +errorMsg+"\n"+currentFile); 1555 + errorMsg + "\n" + currentFile);
1633 return false; 1556 return false;
1634 } else { 1557 } else {
1635 filePara.numberSamples=wavFile->getNumberSamples(); 1558
1559 filePara.numberSamples = wavFile->getNumberSamples();
1636 filePara.format = wavFile->getFormat(); 1560 filePara.format = wavFile->getFormat();
1637 // qDebug("file %d, samples %f", filePara.fd, filePara.numberSamples); 1561 filePara.sampleRate = wavFile->getSampleRate();
1638 filePara.sampleRate= wavFile->getSampleRate(); 1562 filePara.resolution = wavFile->getResolution();
1639 filePara.resolution=wavFile->getResolution(); 1563 filePara.channels = wavFile->getChannels();
1640 timeSlider->setPageStep(1); 1564 timeSlider->setPageStep(1);
1641 monitoring=true; 1565 monitoring = true;
1566
1567 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));
1569
1570 qWarning("seconds %d", sec);
1571
1642 timeSlider->setRange(0, filePara.numberSamples ); 1572 timeSlider->setRange(0, filePara.numberSamples );
1643 filePara.numberOfRecordedSeconds=(float) filePara.numberSamples / (float)filePara.sampleRate * (float)2;
1644 } 1573 }
1645 1574
@@ -1652,9 +1581,9 @@ void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1652 switch (mouse) { 1581 switch (mouse) {
1653 case 1: { 1582 case 1: {
1654 if( renameBox !=0 ) //tricky 1583 if( renameBox != 0 ) //tricky
1655 cancelRename(); 1584 cancelRename();
1656 1585
1657 currentFile=item->text(0); 1586 currentFile = item->text(0);
1658 setCaption( "OpieRecord "+currentFile); 1587 setCaption( "OpieRecord " + currentFile);
1659 } 1588 }
1660 break; 1589 break;
@@ -1701,9 +1630,10 @@ void QtRec::doBeam() {
1701 1630
1702 for(int i=0;i<nFiles+1;i++) { 1631 for(int i=0;i<nFiles+1;i++) {
1703 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1632 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) {
1704 QString filePath = cfg.readEntry(file,""); 1633 QString filePath = cfg.readEntry(file,"");
1705 Ir *file = new Ir(this, "IR"); 1634 Ir *file = new Ir(this, "IR");
1706 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 1635 connect( file, SIGNAL( done(Ir*)),
1707 file->send( filePath, "OPieRec audio file\n"+filePath ); 1636 this, SLOT( fileBeamFinished( Ir * )));
1637 file->send( filePath, "OPieRec audio file\n" + filePath );
1708 } 1638 }
1709 } 1639 }
@@ -1739,6 +1669,5 @@ void QtRec::doRename() {
1739 1669
1740void QtRec::okRename() { 1670void QtRec::okRename() {
1741 // qDebug("okRename"); 1671 qDebug(renameBox->text());
1742 // qDebug(renameBox->text());
1743 QString filename = renameBox->text(); 1672 QString filename = renameBox->text();
1744 cancelRename(); 1673 cancelRename();
@@ -1752,5 +1681,5 @@ void QtRec::okRename() {
1752 QString file = ListView1->currentItem()->text(0); 1681 QString file = ListView1->currentItem()->text(0);
1753 1682
1754 // qDebug("filename is " + filename); 1683 qDebug("filename is " + filename);
1755 1684
1756 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1685 int nFiles = cfg.readNumEntry("NumberofFiles",0);
@@ -1763,5 +1692,5 @@ void QtRec::okRename() {
1763 cfg.writeEntry( QString::number(i), filename ); 1692 cfg.writeEntry( QString::number(i), filename );
1764 cfg.writeEntry( filename, filePath ); 1693 cfg.writeEntry( filename, filePath );
1765 cfg.removeEntry(file); 1694 cfg.removeEntry( file);
1766 cfg.write(); 1695 cfg.write();
1767 } 1696 }
@@ -1776,5 +1705,4 @@ void QtRec::okRename() {
1776 1705
1777void QtRec::cancelRename() { 1706void QtRec::cancelRename() {
1778 // qDebug("cancel rename");
1779 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1707 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1780 delete renameBox; 1708 delete renameBox;
@@ -1812,6 +1740,5 @@ int QtRec::getCurrentSizeLimit() {
1812 1740
1813void QtRec::timerBreak() { 1741void QtRec::timerBreak() {
1814 // qDebug("timer break"); 1742 endPlaying();
1815 stop();
1816} 1743}
1817 1744
@@ -1837,13 +1764,14 @@ void QtRec::compressionSelected(bool b) {
1837 cfg.setGroup("Settings"); 1764 cfg.setGroup("Settings");
1838 cfg.writeEntry("wavCompression", b); 1765 cfg.writeEntry("wavCompression", b);
1839 cfg.writeEntry("bitrate",16); filePara.resolution=16; 1766 cfg.writeEntry("bitrate", 16);
1767 filePara.resolution = 16;
1840 cfg.write(); 1768 cfg.write();
1841 1769
1842 if(b) { 1770 if(b) {
1843 bitRateComboBox->setEnabled(false); 1771 bitRateComboBox->setEnabled( false);
1844 bitRateComboBox->setCurrentItem(0); 1772 bitRateComboBox->setCurrentItem( 0);
1845 filePara.resolution=16; 1773 filePara.resolution = 16;
1846 } else{ 1774 } else{
1847 bitRateComboBox->setEnabled(true); 1775 bitRateComboBox->setEnabled( true);
1848 } 1776 }
1849} 1777}
@@ -1879,6 +1807,6 @@ long QtRec::checkDiskSpace(const QString &path) {
1879// char f_fpack[6]; /* Pack name */ 1807// char f_fpack[6]; /* Pack name */
1880 1808
1881void QtRec::receive( const QCString &/* msg*/, const QByteArray & ) { 1809void QtRec::receive( const QCString &msg, const QByteArray & ) {
1882 // qDebug("Voicerecord received message "+msg); 1810 qDebug("Voicerecord received message "+msg);
1883 1811
1884} 1812}
@@ -1887,5 +1815,24 @@ void QtRec::receive( const QCString &/* msg*/, const QByteArray & ) {
1887///////////////////////////// timerEvent 1815///////////////////////////// timerEvent
1888void QtRec::timerEvent( QTimerEvent *e ) { 1816void QtRec::timerEvent( QTimerEvent *e ) {
1889// qDebug( "%d", secCount ); 1817
1818// if(!recording)
1819// timeSlider->setValue( secCount);
1820// else
1821// timeSlider->setValue( filePara.numberOfRecordedSeconds);
1822
1823 if( stopped && playing) {
1824 stop();
1825 }
1826
1827 if( stopped && recording ){
1828 stop();
1829 }
1830
1831 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
1832 stop();
1833 }
1834
1835 qDebug( "%d", secCount );
1836 QString timeString;
1890#ifdef DEV_VERSION 1837#ifdef DEV_VERSION
1891 QString msg; 1838 QString msg;
@@ -1894,31 +1841,12 @@ void QtRec::timerEvent( QTimerEvent *e ) {
1894#endif 1841#endif
1895 1842
1896 if( !playing ) { 1843 timeString.sprintf("%d", secCount);
1897 if(!recording ){ 1844 timeLabel->setText( timeString + " seconds");
1898 killTimer(e->timerId()); 1845
1899///* stopped=true;
1900// recording=false;
1901///*/
1902// _exit( 0);
1903 }
1904 if(filePara.SecondsToRecord < secCount && filePara.SecondsToRecord !=0) {
1905 killTimer(e->timerId());
1906 stop();
1907 }
1908 }
1909// if( stopped && !paused) {
1910// if( filePara.numberOfRecordedSeconds < secCount) {
1911// stopped = true;
1912// // playing=false;
1913// killTimer(e->timerId());
1914// endPlaying();
1915// }
1916// }
1917// qApp->processEvents();
1918 secCount++; 1846 secCount++;
1919} 1847}
1920 1848
1921void QtRec::changeTimeSlider(int index) { 1849void QtRec::changeTimeSlider(int index) {
1922 if(ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1850 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
1923 // qDebug("Slider moved to %d",index); 1851 // qDebug("Slider moved to %d",index);
1924 paused = true; 1852 paused = true;
@@ -1928,12 +1856,12 @@ void QtRec::changeTimeSlider(int index) {
1928 1856
1929 QString timeString; 1857 QString timeString;
1930 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 1858 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1931 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1859 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1932 secCount = (int)filePara.numberOfRecordedSeconds; 1860 secCount = (int)filePara.numberOfRecordedSeconds;
1933 timeLabel->setText( timeString+ tr(" seconds")); 1861 timeLabel->setText( timeString + tr(" seconds"));
1934} 1862}
1935 1863
1936void QtRec::timeSliderPressed() { 1864void QtRec::timeSliderPressed() {
1937 if(ListView1->currentItem() == 0) return; 1865 if( ListView1->currentItem() == 0) return;
1938 // qDebug("slider pressed"); 1866 // qDebug("slider pressed");
1939 paused = true; 1867 paused = true;
@@ -1942,6 +1870,6 @@ void QtRec::timeSliderPressed() {
1942 1870
1943void QtRec::timeSliderReleased() { 1871void QtRec::timeSliderReleased() {
1944 if(ListView1->currentItem() == 0) return; 1872 if( ListView1->currentItem() == 0) return;
1945 sliderPos=timeSlider->value(); 1873 sliderPos = timeSlider->value();
1946 1874
1947 // qDebug("slider released %d", sliderPos); 1875 // qDebug("slider released %d", sliderPos);
@@ -1949,5 +1877,5 @@ void QtRec::timeSliderReleased() {
1949 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1877 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1950 total = newPos*4; 1878 total = newPos*4;
1951 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 1879 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1952 1880
1953 doPlay(); 1881 doPlay();
@@ -1955,5 +1883,5 @@ void QtRec::timeSliderReleased() {
1955 1883
1956void QtRec::rewindPressed() { 1884void QtRec::rewindPressed() {
1957 if(ListView1->currentItem() == 0) return; 1885 if( ListView1->currentItem() == 0) return;
1958 if( !wavFile->track.isOpen()) { 1886 if( !wavFile->track.isOpen()) {
1959 if( !openPlayFile() ) 1887 if( !openPlayFile() )
@@ -1966,5 +1894,5 @@ void QtRec::rewindPressed() {
1966 paused = true; 1894 paused = true;
1967 stopped = true; 1895 stopped = true;
1968 rewindTimer->start(50, false); 1896 rewindTimer->start( 50, false);
1969 } 1897 }
1970} 1898}
@@ -1972,10 +1900,10 @@ void QtRec::rewindPressed() {
1972void QtRec::rewindTimerTimeout() { 1900void QtRec::rewindTimerTimeout() {
1973 int sliderValue = timeSlider->value(); 1901 int sliderValue = timeSlider->value();
1974 sliderValue = sliderValue-(filePara.numberSamples/100); 1902 sliderValue = sliderValue - ( filePara.numberSamples / 100);
1975 // if(toBeginningButton->isDown()) 1903 // if(toBeginningButton->isDown())
1976 timeSlider->setValue( sliderValue ) ; 1904 timeSlider->setValue( sliderValue ) ;
1977 // qDebug("%d", sliderValue); 1905 // qDebug("%d", sliderValue);
1978 QString timeString; 1906 QString timeString;
1979 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2; 1907 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1980 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1908 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1981 timeLabel->setText( timeString+ tr(" seconds")); 1909 timeLabel->setText( timeString+ tr(" seconds"));
@@ -1988,7 +1916,7 @@ void QtRec::rewindReleased() {
1988 stopped = false; 1916 stopped = false;
1989 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1917 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1990 total = newPos*4; 1918 total = newPos * 4;
1991 // qDebug("rewind released %d", total); 1919 // qDebug("rewind released %d", total);
1992 startTimer(1000); 1920 startTimer( 1000);
1993 doPlay(); 1921 doPlay();
1994 } 1922 }
@@ -1996,5 +1924,5 @@ void QtRec::rewindReleased() {
1996 1924
1997void QtRec::FastforwardPressed() { 1925void QtRec::FastforwardPressed() {
1998 if(ListView1->currentItem() == 0) return; 1926 if( ListView1->currentItem() == 0) return;
1999 if( !wavFile->track.isOpen()) 1927 if( !wavFile->track.isOpen())
2000 if( !openPlayFile() ) 1928 if( !openPlayFile() )
@@ -2013,11 +1941,11 @@ void QtRec::FastforwardPressed() {
2013void QtRec::forwardTimerTimeout() { 1941void QtRec::forwardTimerTimeout() {
2014 int sliderValue = timeSlider->value(); 1942 int sliderValue = timeSlider->value();
2015 sliderValue = sliderValue +(filePara.numberSamples/100); 1943 sliderValue = sliderValue + ( filePara.numberSamples / 100);
2016 1944
2017 // if(toEndButton->isDown()) 1945 // if(toEndButton->isDown())
2018 timeSlider->setValue(sliderValue); 1946 timeSlider->setValue( sliderValue);
2019 1947
2020 QString timeString; 1948 QString timeString;
2021 filePara.numberOfRecordedSeconds=(float)sliderValue/(float)filePara.sampleRate*(float)2; 1949 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
2022 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1950 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
2023 timeLabel->setText( timeString+ tr(" seconds")); 1951 timeLabel->setText( timeString+ tr(" seconds"));
@@ -2030,7 +1958,7 @@ void QtRec::FastforwardReleased() {
2030 stopped = false; 1958 stopped = false;
2031 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1959 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
2032 total = newPos*4; 1960 total = newPos * 4;
2033 filePara.numberOfRecordedSeconds=(float)sliderPos/(float)filePara.sampleRate*(float)2; 1961 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
2034 startTimer(1000); 1962 startTimer( 1000);
2035 doPlay(); 1963 doPlay();
2036 } 1964 }
@@ -2045,9 +1973,9 @@ QString QtRec::getStorage(const QString &fileName) {
2045 QString storage; 1973 QString storage;
2046 for( ; it.current(); ++it ){ 1974 for( ; it.current(); ++it ){
2047 const QString name = (*it)->name(); 1975 const QString name = ( *it)->name();
2048 const QString path = (*it)->path(); 1976 const QString path = ( *it)->path();
2049 const QString disk = (*it)->disk(); 1977 const QString disk = ( *it)->disk();
2050 if( fileName.find(path,0,true) != -1) 1978 if( fileName.find( path,0,true) != -1)
2051 storage=name; 1979 storage = name;
2052 // const QString options = (*it)->options(); 1980 // const QString options = (*it)->options();
2053 // if( name.find( tr("Internal"),0,true) == -1) { 1981 // if( name.find( tr("Internal"),0,true) == -1) {
@@ -2072,10 +2000,10 @@ void QtRec::setRecordButton(bool b) {
2072 if(b) { //about to record or play 2000 if(b) { //about to record or play
2073 2001
2074 Rec_PushButton->setDown(true); 2002 Rec_PushButton->setDown( true);
2075 QPixmap image3( ( const char** ) image3_data ); 2003 QPixmap image3( ( const char** ) image3_data );
2076 Stop_PushButton->setPixmap( image3 ); 2004 Stop_PushButton->setPixmap( image3 );
2077 if(Stop_PushButton->isDown()) 2005 if(Stop_PushButton->isDown())
2078 Stop_PushButton->setDown(true); 2006 Stop_PushButton->setDown( true);
2079 playLabel2->setText(tr("Stop") ); 2007 playLabel2->setText( tr("Stop") );
2080 2008
2081 } else { //about to stop 2009 } else { //about to stop
@@ -2084,6 +2012,6 @@ void QtRec::setRecordButton(bool b) {
2084 Stop_PushButton->setPixmap( image4); 2012 Stop_PushButton->setPixmap( image4);
2085 if(Stop_PushButton->isDown()) 2013 if(Stop_PushButton->isDown())
2086 Stop_PushButton->setDown(false); 2014 Stop_PushButton->setDown( false);
2087 playLabel2->setText(tr("Play") ); 2015 playLabel2->setText( tr("Play") );
2088 if(Rec_PushButton->isDown()) 2016 if(Rec_PushButton->isDown())
2089 Rec_PushButton->setDown( false); 2017 Rec_PushButton->setDown( false);
@@ -2094,8 +2022,8 @@ void QtRec::fillDirectoryCombo() {
2094 if( directoryComboBox->count() > 0) 2022 if( directoryComboBox->count() > 0)
2095 directoryComboBox->clear(); 2023 directoryComboBox->clear();
2096 int index=0; 2024 int index = 0;
2097 Config cfg("OpieRec"); 2025 Config cfg("OpieRec");
2098 cfg.setGroup("Settings"); 2026 cfg.setGroup("Settings");
2099 QString dir= cfg.readEntry("directory", "/"); 2027 QString dir = cfg.readEntry("directory", "/");
2100 StorageInfo storageInfo; 2028 StorageInfo storageInfo;
2101 const QList<FileSystem> &fs = storageInfo.fileSystems(); 2029 const QList<FileSystem> &fs = storageInfo.fileSystems();
@@ -2103,10 +2031,10 @@ void QtRec::fillDirectoryCombo() {
2103 QString storage; 2031 QString storage;
2104 for( ; it.current(); ++it ){ 2032 for( ; it.current(); ++it ){
2105 const QString name = (*it)->name(); 2033 const QString name = ( *it)->name();
2106 const QString path = (*it)->path(); 2034 const QString path = ( *it)->path();
2107 // directoryComboBox->insertItem(name+" "+path); 2035 // directoryComboBox->insertItem(name+" "+path);
2108 directoryComboBox->insertItem(name); 2036 directoryComboBox->insertItem(name);
2109 if(path==dir) 2037 if( path == dir)
2110 directoryComboBox->setCurrentItem(index); 2038 directoryComboBox->setCurrentItem( index);
2111 index++; 2039 index++;
2112 } 2040 }
@@ -2125,9 +2053,9 @@ void QtRec::doMute(bool b) {
2125 2053
2126void QtRec::slotAutoMute(bool b) { 2054void QtRec::slotAutoMute(bool b) {
2127 autoMute=b; 2055 autoMute = b;
2128 Config cfg("OpieRec"); 2056 Config cfg("OpieRec");
2129 cfg.setGroup("Settings"); 2057 cfg.setGroup("Settings");
2130 cfg.writeEntry("useAutoMute",b); 2058 cfg.writeEntry("useAutoMute",b);
2131 doMute(b); 2059 doMute( b);
2132 outMuteCheckBox->setChecked( b); 2060 outMuteCheckBox->setChecked( b);
2133 inMuteCheckBox->setChecked( b); 2061 inMuteCheckBox->setChecked( b);
@@ -2137,32 +2065,45 @@ void QtRec::selectItemByName(const QString & name) {
2137 QListViewItemIterator it( ListView1 ); 2065 QListViewItemIterator it( ListView1 );
2138 for ( ; it.current(); ++it ) 2066 for ( ; it.current(); ++it )
2139 if(name == it.current()->text(0)) 2067 if( name == it.current()->text(0))
2140 ListView1->setCurrentItem(it.current()); 2068 ListView1->setCurrentItem(it.current());
2141} 2069}
2142 2070
2143 2071
2144long findPeak(long input ) { 2072// long findPeak(long input ) {
2145 2073
2146// halfLife = time in seconds for output to decay to half value after an impulse 2074// // halfLife = time in seconds for output to decay to half value after an impulse
2147 float output = 0.0; 2075// static float output = 0.0;
2148 float halfLife = .25; 2076// float halfLife = .0025;
2149 float vsf = .0025; 2077// float vsf = .0025;
2150 float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2078// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2151 if( input < 0.0 ) 2079// if( input < 0.0 )
2152 input = -input; // Absolute value. 2080// input = -input; // Absolute value.
2153 if ( input >= output) { 2081// if ( input >= output ) {
2154 // When we hit a peak, ride the peak to the top. 2082// // When we hit a peak, ride the peak to the top.
2155 output = input; 2083// output = input;
2156 } else { 2084// } else {
2157// Exponential decay of output when signal is low. 2085// // Exponential decay of output when signal is low.
2158 output = output * scalar; 2086// output = output * scalar;
2159// 2087// //
2160// When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2088// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2161// which can cause a severe performance degradation due to a flood 2089// // which can cause a severe performance degradation due to a flood
2162// of interrupts. 2090// // of interrupts.
2163// 2091// //
2164 if( output < vsf ) output = 0.0; 2092// if( output < vsf ) output = 0.0;
2165 } 2093// }
2094
2095// return (long) output;
2096// }
2166 2097
2167 return (long)output; 2098void QtRec::changeStereoCheck(bool b) {
2099 Config cfg("OpieRec");
2100 cfg.setGroup("Settings");
2101 int ch = 0;
2102 if ( !b) { ch = 1;}
2103 else { ch = 2;}
2104 cfg.writeEntry("stereo", b);
2105 filePara.channels = ch;
2106
2107 cfg.write();
2168} 2108}
2109
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h
index ada3270..93b9b5f 100644
--- a/noncore/multimedia/opierec/qtrec.h
+++ b/noncore/multimedia/opierec/qtrec.h
@@ -5,5 +5,5 @@ copyright 2002 by L.J. Potter ljp@llornkcor.com
5#ifndef QTREC_H 5#ifndef QTREC_H
6#define QTREC_H 6#define QTREC_H
7#define VERSION 1.0 7#define VERSION 20030920
8 8
9#include <qpe/ir.h> 9#include <qpe/ir.h>
@@ -56,5 +56,5 @@ class QtRec : public QWidget
56 56
57public: 57public:
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();
@@ -73,5 +73,5 @@ private:
73 QString date, currentFileName, tmpFileName; 73 QString date, currentFileName, tmpFileName;
74 QTimer *t_timer; 74 QTimer *t_timer;
75 bool needsStereoOut, paused, playing; 75 bool needsStereoOut, paused;
76 bool useTmpFile, autoMute; 76 bool useTmpFile, autoMute;
77 77
@@ -99,5 +99,4 @@ private:
99private slots: 99private slots:
100 100
101
102 void FastforwardPressed(); 101 void FastforwardPressed();
103 void FastforwardReleased(); 102 void FastforwardReleased();
@@ -106,4 +105,6 @@ private slots:
106 void changeTimeSlider(int); 105 void changeTimeSlider(int);
107 void changebitrateCombo(int); 106 void changebitrateCombo(int);
107 void changeStereoCheck( bool);
108
108 void changedInVolume(); 109 void changedInVolume();
109 void changedOutVolume(); 110 void changedOutVolume();
@@ -135,9 +136,7 @@ private slots:
135protected: 136protected:
136 137
137 Device *soundDevice;
138 WavFile *wavFile; 138 WavFile *wavFile;
139
140 QButtonGroup *ButtonGroup1; 139 QButtonGroup *ButtonGroup1;
141 QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox; 140 QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox;
142 QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo; 141 QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo;
143 QHBoxLayout* Layout12; 142 QHBoxLayout* Layout12;
@@ -179,5 +178,5 @@ protected:
179 void receive( const QCString &, const QByteArray & ); 178 void receive( const QCString &, const QByteArray & );
180 void showListMenu(QListViewItem * ); 179 void showListMenu(QListViewItem * );
181// void quickRec(); 180// void quickRec();
182 181
183}; 182};
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index b177c91..987fa32 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -150,6 +150,6 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
150 150
151 write( fd,hdr, sizeof(*hdr)); 151 write( fd,hdr, sizeof(*hdr));
152// qDebug("writing header: bitrate%d, samplerate %d, channels %d", 152 qDebug("writing header: bitrate%d, samplerate %d, channels %d",
153// wavResolution, wavSampleRate, wavChannels); 153 wavResolution, wavSampleRate, wavChannels);
154 return true; 154 return true;
155} 155}
@@ -161,10 +161,10 @@ bool WavFile::adjustHeaders(int fd, int total) {
161 lseek( fd, 40, SEEK_SET); 161 lseek( fd, 40, SEEK_SET);
162 write( fd, &total, sizeof(total)); 162 write( fd, &total, sizeof(total));
163// qDebug("adjusting header %d", total); 163 qDebug("adjusting header %d", total);
164 return true; 164 return true;
165} 165}
166 166
167int WavFile::parseWavHeader(int fd) { 167int WavFile::parseWavHeader(int fd) {
168// qDebug("Parsing wav header"); 168 qDebug("Parsing wav header");
169 char string[4]; 169 char string[4];
170 int found; 170 int found;
@@ -295,9 +295,9 @@ return wavResolution;
295 295
296int WavFile::getSampleRate() { 296int WavFile::getSampleRate() {
297return wavSampleRate; 297 return wavSampleRate;
298} 298}
299 299
300int WavFile::getNumberSamples() { 300int WavFile::getNumberSamples() {
301return wavNumberSamples; 301 return wavNumberSamples;
302} 302}
303 303
@@ -305,2 +305,7 @@ bool WavFile::isTempFile() {
305return useTmpFile; 305return useTmpFile;
306} 306}
307
308int WavFile::getChannels() {
309
310 return wavChannels;
311}
diff --git a/noncore/multimedia/opierec/wavFile.h b/noncore/multimedia/opierec/wavFile.h
index b70c09d..e18cfce 100644
--- a/noncore/multimedia/opierec/wavFile.h
+++ b/noncore/multimedia/opierec/wavFile.h
@@ -42,4 +42,5 @@ public:
42 int getSampleRate(); 42 int getSampleRate();
43 int getNumberSamples(); 43 int getNumberSamples();
44 int getChannels();
44 bool isTempFile(); 45 bool isTempFile();
45 int openFile(const QString &); 46 int openFile(const QString &);