summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opierec
authormickeyl <mickeyl>2004-04-04 13:54:40 (UTC)
committer mickeyl <mickeyl>2004-04-04 13:54:40 (UTC)
commit16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (unidiff)
tree0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/multimedia/opierec
parent8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff)
downloadopie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip
opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz
opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/multimedia/opierec') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp46
-rw-r--r--noncore/multimedia/opierec/helpwindow.cpp11
-rw-r--r--noncore/multimedia/opierec/opierec.pro6
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp129
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp67
-rw-r--r--noncore/multimedia/opierec/waveform.cpp12
6 files changed, 140 insertions, 131 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index ce49e96..5319d97 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -1,24 +1,24 @@
1// device.cpp 1// device.cpp
2 2
3#include "device.h" 3#include "device.h"
4 4
5/* OPIE */
6#include <opie2/odebug.h>
5#include <qpe/config.h> 7#include <qpe/config.h>
6#include <qpe/qcopenvelope_qws.h> 8#include <qpe/qcopenvelope_qws.h>
9using namespace Opie::Core;
7 10
8 11/* STD */
9#include <fcntl.h> 12#include <fcntl.h>
10#include <stdio.h> 13#include <stdio.h>
11#include <stdlib.h> 14#include <stdlib.h>
12#include <sys/ioctl.h> 15#include <sys/ioctl.h>
13#include <sys/soundcard.h> 16#include <sys/soundcard.h>
14#include <unistd.h> 17#include <unistd.h>
15#include<sys/wait.h> 18#include <sys/wait.h>
16// #include <sys/stat.h>
17// #include <sys/time.h>
18// #include <sys/types.h>
19#include <unistd.h> 19#include <unistd.h>
20#include <errno.h> 20#include <errno.h>
21 21
22//extern QtRec *qperec; 22//extern QtRec *qperec;
23 23
24Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) 24Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record )
@@ -29,16 +29,16 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco
29 29
30 devForm=-1; 30 devForm=-1;
31 devCh=-1; 31 devCh=-1;
32 devRate=-1; 32 devRate=-1;
33 33
34 if( !record){ //playing 34 if( !record){ //playing
35 qDebug("setting up DSP for playing"); 35 odebug << "setting up DSP for playing" << oendl;
36 flags = O_WRONLY; 36 flags = O_WRONLY;
37 } else { //recording 37 } else { //recording
38 qDebug("setting up DSP for recording"); 38 odebug << "setting up DSP for recording" << oendl;
39 flags = O_RDWR; 39 flags = O_RDWR;
40// flags = O_RDONLY; 40// flags = O_RDONLY;
41 41
42// selectMicInput(); 42// selectMicInput();
43 43
44 } 44 }
@@ -93,13 +93,13 @@ void Device::changedOutVolume(int vol) {
93 perror("ioctl(\"MIXER_IN_WRITE\")"); 93 perror("ioctl(\"MIXER_IN_WRITE\")");
94 94
95 Config cfg("qpe"); 95 Config cfg("qpe");
96 cfg.setGroup("Volume"); 96 cfg.setGroup("Volume");
97 cfg.writeEntry("VolumePercent", QString::number( vol )); 97 cfg.writeEntry("VolumePercent", QString::number( vol ));
98 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; 98 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
99 qWarning("changing output vol %d", vol); 99 owarn << "changing output vol " << vol << "" << oendl;
100 } 100 }
101 ::close(fd); 101 ::close(fd);
102} 102}
103 103
104void Device::changedInVolume(int vol ) { 104void Device::changedInVolume(int vol ) {
105 int level = (vol << 8) + vol; 105 int level = (vol << 8) + vol;
@@ -108,13 +108,13 @@ void Device::changedInVolume(int vol ) {
108 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) 108 if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1)
109 perror("ioctl(\"MIXER_IN_WRITE\")"); 109 perror("ioctl(\"MIXER_IN_WRITE\")");
110 Config cfg("qpe"); 110 Config cfg("qpe");
111 cfg.setGroup("Volume"); 111 cfg.setGroup("Volume");
112 cfg.writeEntry("Mic", QString::number(vol )); 112 cfg.writeEntry("Mic", QString::number(vol ));
113 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; 113 QCopEnvelope( "QPE/System", "micChange(bool)" ) << false;
114 qWarning("changing input volume %d", vol); 114 owarn << "changing input volume " << vol << "" << oendl;
115 } 115 }
116 ::close(fd); 116 ::close(fd);
117} 117}
118 118
119bool Device::selectMicInput() { 119bool Device::selectMicInput() {
120 120
@@ -146,28 +146,28 @@ exit(1);
146 switch (pid = fork()) { 146 switch (pid = fork()) {
147 case -1: 147 case -1:
148 perror("The fork failed!"); 148 perror("The fork failed!");
149 break; 149 break;
150 case 0: { 150 case 0: {
151 */ 151 */
152qDebug("Opening %s",dspstr); 152odebug << "Opening " << dspstr << "" << oendl;
153 if (( sd = ::open( dspstr, flags)) == -1) { 153 if (( sd = ::open( dspstr, flags)) == -1) {
154 perror("open(\"/dev/dsp\")"); 154 perror("open(\"/dev/dsp\")");
155 QString errorMsg="Could not open audio device\n /dev/dsp\n" 155 QString errorMsg="Could not open audio device\n /dev/dsp\n"
156 +(QString)strerror(errno); 156 +(QString)strerror(errno);
157 qDebug("XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg); 157 odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
158 return -1; 158 return -1;
159 } 159 }
160 160
161qDebug("Opening mixer"); 161odebug << "Opening mixer" << oendl;
162 int mixerHandle=0; 162 int mixerHandle=0;
163 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { 163 if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) {
164 perror("open(\"/dev/mixer\")"); 164 perror("open(\"/dev/mixer\")");
165 QString errorMsg="Could not open audio device\n /dev/dsp\n" 165 QString errorMsg="Could not open audio device\n /dev/dsp\n"
166 +(QString)strerror(errno); 166 +(QString)strerror(errno);
167 qDebug("XXXXXXXXXXXXXXXXXXXXXX "+errorMsg); 167 odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
168 } 168 }
169 169
170 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ 170 if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
171 perror("ioctl RESET"); 171 perror("ioctl RESET");
172 } 172 }
173// sprintf(message, "%d", sd); 173// sprintf(message, "%d", sd);
@@ -177,13 +177,13 @@ qDebug("Opening mixer");
177 f1.writeBlock(message, strlen(message)); 177 f1.writeBlock(message, strlen(message));
178 f1.close(); 178 f1.close();
179 */ 179 */
180 /* close(pipefd[0]); 180 /* close(pipefd[0]);
181 write(pipefd[1], message, sizeof(message)); 181 write(pipefd[1], message, sizeof(message));
182 close(pipefd[1]); 182 close(pipefd[1]);
183 // qDebug("%d",soundDevice->sd ); 183 // odebug << "" << soundDevice->sd << "" << oendl;
184 _exit(0); 184 _exit(0);
185 } 185 }
186 default: 186 default:
187 // pid greater than zero is parent getting the child's pid 187 // pid greater than zero is parent getting the child's pid
188 printf("Child's pid is %d\n",pid); 188 printf("Child's pid is %d\n",pid);
189 QString s; 189 QString s;
@@ -203,19 +203,19 @@ qDebug("Opening mixer");
203 // for(int f=0; f < t.atEnd() ;f++) { 203 // for(int f=0; f < t.atEnd() ;f++) {
204 s = t.readLine(); 204 s = t.readLine();
205 // } 205 // }
206 */ 206 */
207// bool ok; 207// bool ok;
208// sd = s.toInt(&ok, 10); 208// sd = s.toInt(&ok, 10);
209// qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s); 209// odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl;
210 210
211// f2.close(); 211// f2.close();
212// } 212// }
213::close(mixerHandle ); 213::close(mixerHandle );
214// qDebug("open device %s", dspstr); 214// odebug << "open device " << dspstr << "" << oendl;
215// qDebug("success! %d",sd); 215// odebug << "success! " << sd << "" << oendl;
216 return sd; 216 return sd;
217} 217}
218 218
219bool Device::closeDevice( bool) { 219bool Device::closeDevice( bool) {
220// if(b) {//close now 220// if(b) {//close now
221// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { 221// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
@@ -227,38 +227,38 @@ bool Device::closeDevice( bool) {
227// } 227// }
228// } 228// }
229 229
230 ::close( sd); //close sound device 230 ::close( sd); //close sound device
231// sdfd=0; 231// sdfd=0;
232 // sd=0; 232 // sd=0;
233// qDebug("closed dsp"); 233// odebug << "closed dsp" << oendl;
234 return true; 234 return true;
235} 235}
236 236
237bool Device::setDeviceFormat( int form) { 237bool Device::setDeviceFormat( int form) {
238 qDebug("set device res %d %d", form, sd); 238 odebug << "set device res " << form << " " << sd << "" << oendl;
239 if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format 239 if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format
240 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 240 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
241 return false; 241 return false;
242 } 242 }
243 devRes=form; 243 devRes=form;
244 return true; 244 return true;
245} 245}
246 246
247bool Device::setDeviceChannels( int ch) { 247bool Device::setDeviceChannels( int ch) {
248 qDebug("set channels %d %d", ch, sd); 248 odebug << "set channels " << ch << " " << sd << "" << oendl;
249 if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { 249 if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) {
250 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 250 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
251 return false; 251 return false;
252 } 252 }
253 devCh=ch; 253 devCh=ch;
254 return true; 254 return true;
255} 255}
256 256
257bool Device::setDeviceRate( int rate) { 257bool Device::setDeviceRate( int rate) {
258 qDebug("set rate %d %d", rate, sd); 258 odebug << "set rate " << rate << " " << sd << "" << oendl;
259 if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { 259 if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) {
260 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 260 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
261 return false; 261 return false;
262 } 262 }
263 263
264 devRate=rate; 264 devRate=rate;
@@ -315,15 +315,15 @@ int Device::getDeviceChannels() {
315} 315}
316 316
317int Device::getDeviceFragSize() { 317int Device::getDeviceFragSize() {
318 int frag_size; 318 int frag_size;
319 319
320 if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { 320 if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
321 qDebug("no fragsize"); 321 odebug << "no fragsize" << oendl;
322 } else { 322 } else {
323 qDebug("driver says frag size is %d", frag_size); 323 odebug << "driver says frag size is " << frag_size << "" << oendl;
324 } 324 }
325 return frag_size; 325 return frag_size;
326} 326}
327 327
328bool Device::setFragSize(int frag) { 328bool Device::setFragSize(int frag) {
329 if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) { 329 if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) {
diff --git a/noncore/multimedia/opierec/helpwindow.cpp b/noncore/multimedia/opierec/helpwindow.cpp
index 6aebaa1..7f984c3 100644
--- a/noncore/multimedia/opierec/helpwindow.cpp
+++ b/noncore/multimedia/opierec/helpwindow.cpp
@@ -6,29 +6,34 @@
6** This file is part of an example program for Qt. This example 6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation. 7** program may be used, distributed and modified without limitation.
8** 8**
9*****************************************************************************/ 9*****************************************************************************/
10 10
11#include "helpwindow.h" 11#include "helpwindow.h"
12#include <qlayout.h>
13 12
14#include <qtoolbar.h> 13/* OPIE */
14#include <opie2/odebug.h>
15#include <qpe/resource.h> 15#include <qpe/resource.h>
16using namespace Opie::Core;
16 17
18/* QT */
19#include <qlayout.h>
20#include <qtoolbar.h>
17#include <qaction.h> 21#include <qaction.h>
18#include <qmenubar.h> 22#include <qmenubar.h>
19 23
24/* STD */
20#include <ctype.h> 25#include <ctype.h>
21 26
22HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) 27HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name )
23 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() 28 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
24{ 29{
25 QGridLayout *layout = new QGridLayout( this ); 30 QGridLayout *layout = new QGridLayout( this );
26 layout->setSpacing( 2); 31 layout->setSpacing( 2);
27 layout->setMargin( 2); 32 layout->setMargin( 2);
28 qDebug(_path); 33 odebug << _path << oendl;
29 browser = new QTextBrowser( this ); 34 browser = new QTextBrowser( this );
30 QStringList Strlist; 35 QStringList Strlist;
31 Strlist.append( home_); 36 Strlist.append( home_);
32 browser->mimeSourceFactory()->setFilePath( Strlist ); 37 browser->mimeSourceFactory()->setFilePath( Strlist );
33 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 38 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
34 39
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro
index 7b08f0e..ea1bae3 100644
--- a/noncore/multimedia/opierec/opierec.pro
+++ b/noncore/multimedia/opierec/opierec.pro
@@ -1,9 +1,7 @@
1#CONFIG = qt warn_on pdaudio 1CONFIG = qt warn_on
2CONFIG = qt warn_on opie
3#CONFIG = qt warn_on quick-app
4HEADERS = adpcm.h \ 2HEADERS = adpcm.h \
5 pixmaps.h \ 3 pixmaps.h \
6 helpwindow.h \ 4 helpwindow.h \
7 qtrec.h \ 5 qtrec.h \
8 device.h \ 6 device.h \
9 wavFile.h \ 7 wavFile.h \
@@ -26,13 +24,13 @@ contains(CONFIG, pdaudio) {
26 DEFINES += THREADED 24 DEFINES += THREADED
27 TARGET = qperec 25 TARGET = qperec
28 26
29# DESTDIR=$(QPEDIR)/bin 27# DESTDIR=$(QPEDIR)/bin
30} 28}
31 29
32contains(CONFIG, opie) { 30!contains(CONFIG, pdaudio) {
33 INCLUDEPATH += $(OPIEDIR)/include 31 INCLUDEPATH += $(OPIEDIR)/include
34 DEPENDPATH += $(OPIEDIR)/include 32 DEPENDPATH += $(OPIEDIR)/include
35 DESTDIR=$(OPIEDIR)/bin 33 DESTDIR=$(OPIEDIR)/bin
36 LIBS += -lqpe -lopiecore2 -lpthread 34 LIBS += -lqpe -lopiecore2 -lpthread
37 TARGET = opierec 35 TARGET = opierec
38 include ( $(OPIEDIR)/include.pro ) 36 include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 1c64ab1..2187d5a 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -5,42 +5,41 @@
5****************************************************************************/ 5****************************************************************************/
6#define DEV_VERSION 6#define DEV_VERSION
7 7
8#include "pixmaps.h" 8#include "pixmaps.h"
9#include "qtrec.h" 9#include "qtrec.h"
10#include "waveform.h" 10#include "waveform.h"
11
12#include <pthread.h>
13
14extern "C" { 11extern "C" {
15#include "adpcm.h" 12#include "adpcm.h"
16} 13}
17 14
18#include <sys/soundcard.h> 15/* OPIE */
19 16#include <opie2/odebug.h>
20#include <qpe/config.h> 17#include <qpe/config.h>
21#include <qpe/qcopenvelope_qws.h> 18#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
23#include <qpe/resource.h> 20#include <qpe/resource.h>
24#include <qpe/storage.h> 21#include <qpe/storage.h>
22using namespace Opie::Core;
25 23
24/* QT */
26#include <qcheckbox.h> 25#include <qcheckbox.h>
27#include <qcombobox.h> 26#include <qcombobox.h>
28//#include <qdatetime.h>
29#include <qdir.h> 27#include <qdir.h>
30#include <qgroupbox.h> 28#include <qgroupbox.h>
31#include <qlabel.h> 29#include <qlabel.h>
32#include <qlayout.h> 30#include <qlayout.h>
33#include <qlistview.h> 31#include <qlistview.h>
34#include <qmessagebox.h> 32#include <qmessagebox.h>
35#include <qpopupmenu.h> 33#include <qpopupmenu.h>
36#include <qpushbutton.h> 34#include <qpushbutton.h>
37#include <qslider.h> 35#include <qslider.h>
38#include <qtabwidget.h> 36#include <qtabwidget.h>
39#include <qtimer.h> 37#include <qtimer.h>
40 38
39/* STD */
41#include <errno.h> 40#include <errno.h>
42#include <fcntl.h> 41#include <fcntl.h>
43#include <math.h> 42#include <math.h>
44#include <mntent.h> 43#include <mntent.h>
45#include <stdio.h> 44#include <stdio.h>
46#include <stdlib.h> 45#include <stdlib.h>
@@ -50,13 +49,13 @@ extern "C" {
50#include <sys/time.h> 49#include <sys/time.h>
51#include <sys/types.h> 50#include <sys/types.h>
52#include <sys/vfs.h> 51#include <sys/vfs.h>
53#include <unistd.h> 52#include <unistd.h>
54#include <sys/wait.h> 53#include <sys/wait.h>
55#include <sys/signal.h> 54#include <sys/signal.h>
56 55#include <pthread.h>
57 56
58#ifdef PDAUDIO //ALSA 57#ifdef PDAUDIO //ALSA
59#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
60static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
61static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
62#else //OSS 61#else //OSS
@@ -133,43 +132,43 @@ void quickRec()
133 bytesWritten = 0; 132 bytesWritten = 0;
134 number = 0; 133 number = 0;
135 QString num; 134 QString num;
136 int level = 0; 135 int level = 0;
137 int threshold = 0; 136 int threshold = 0;
138// int bits = filePara.resolution; 137// int bits = filePara.resolution;
139// qDebug("bits %d", bits); 138// odebug << "bits " << bits << "" << oendl;
140 139
141 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 140 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
142// qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); 141// odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
143// qDebug("samples to record %d", filePara.samplesToRecord); 142// odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
144// qDebug("%d", filePara.sd); 143// odebug << "" << filePara.sd << "" << oendl;
145 level = 7; 144 level = 7;
146 threshold = 0; 145 threshold = 0;
147 146
148 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 147 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
149// qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); 148// odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
150 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 149 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
151 char abuf[ BUFSIZE/2 ]; 150 char abuf[ BUFSIZE/2 ];
152 short sbuf[ BUFSIZE ]; 151 short sbuf[ BUFSIZE ];
153 short sbuf2[ BUFSIZE ]; 152 short sbuf2[ BUFSIZE ];
154 memset( abuf, 0, BUFSIZE/2); 153 memset( abuf, 0, BUFSIZE/2);
155 memset( sbuf, 0, BUFSIZE); 154 memset( sbuf, 0, BUFSIZE);
156 memset( sbuf2, 0, BUFSIZE); 155 memset( sbuf2, 0, BUFSIZE);
157 156
158 for(;;) { 157 for(;;) {
159 if ( stopped) { 158 if ( stopped) {
160 // qDebug("quickRec:: stopped"); 159 // odebug << "quickRec:: stopped" << oendl;
161 break; 160 break;
162 } 161 }
163 162
164// number=::read( filePara.sd, sbuf, BUFSIZE); 163// number=::read( filePara.sd, sbuf, BUFSIZE);
165 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); 164 number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
166 165
167 if(number <= 0) { 166 if(number <= 0) {
168 perror("recording error "); 167 perror("recording error ");
169 qDebug( "%s %d", filePara.fileName, number); 168 odebug << "" << filePara.fileName << " " << number << "" << oendl;
170 stopped = true; 169 stopped = true;
171 return; 170 return;
172 } 171 }
173 //if(stereo == 2) { 172 //if(stereo == 2) {
174// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 173// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
175 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 174 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
@@ -189,31 +188,31 @@ void quickRec()
189 stopped = true; 188 stopped = true;
190 break; 189 break;
191 } 190 }
192 } 191 }
193 } else { 192 } else {
194 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 193 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
195 qDebug("start recording WAVE_FORMAT_PCM"); 194 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
196 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 195 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
197 memset( inbuffer, 0, BUFSIZE); 196 memset( inbuffer, 0, BUFSIZE);
198 memset( outbuffer, 0, BUFSIZE); 197 memset( outbuffer, 0, BUFSIZE);
199 198
200 for(;;) { 199 for(;;) {
201 if ( stopped) { 200 if ( stopped) {
202 qDebug("quickRec:: stopped"); 201 odebug << "quickRec:: stopped" << oendl;
203 stopped = true; 202 stopped = true;
204 break; // stop if playing was set to false 203 break; // stop if playing was set to false
205 return; 204 return;
206 } 205 }
207 206
208 number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); 207 number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE);
209 waveform->newSamples( inbuffer, number ); 208 waveform->newSamples( inbuffer, number );
210 209
211 if( number <= 0) { 210 if( number <= 0) {
212 perror( "recording error "); 211 perror( "recording error ");
213 qDebug( filePara.fileName); 212 odebug << filePara.fileName << oendl;
214 stopped = true; 213 stopped = true;
215 return; 214 return;
216 } 215 }
217 216
218 bytesWritten = ::write( filePara.fd , inbuffer, number); 217 bytesWritten = ::write( filePara.fd , inbuffer, number);
219 218
@@ -247,13 +246,13 @@ void quickRec()
247 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 246 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
248 memset( unsigned_inbuffer, 0, BUFSIZE); 247 memset( unsigned_inbuffer, 0, BUFSIZE);
249 memset( unsigned_outbuffer, 0, BUFSIZE); 248 memset( unsigned_outbuffer, 0, BUFSIZE);
250 249
251 for(;;) { 250 for(;;) {
252 if ( stopped) { 251 if ( stopped) {
253 qDebug("quickRec:: stopped"); 252 odebug << "quickRec:: stopped" << oendl;
254 break; // stop if playing was set to false 253 break; // stop if playing was set to false
255 } 254 }
256 255
257 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 256 number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
258 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 257 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
259 258
@@ -370,13 +369,13 @@ void playIt()
370// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 369// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
371// timeLabel->setText( timeString + tr(" seconds")); 370// timeLabel->setText( timeString + tr(" seconds"));
372 371
373 qApp->processEvents(); 372 qApp->processEvents();
374 373
375 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 374 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
376 qWarning("Jane! Stop this crazy thing!"); 375 owarn << "Jane! Stop this crazy thing!" << oendl;
377 stopped = true; 376 stopped = true;
378// playing = false; 377// playing = false;
379 break; 378 break;
380 } 379 }
381 } 380 }
382 printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 381 printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
@@ -715,13 +714,13 @@ void QtRec::initIconView() {
715 Config cfg("OpieRec"); 714 Config cfg("OpieRec");
716 cfg.setGroup("Sounds"); 715 cfg.setGroup("Sounds");
717 QString temp; 716 QString temp;
718 QPixmap image0( ( const char** ) image0_data ); 717 QPixmap image0( ( const char** ) image0_data );
719 718
720 int nFiles = cfg.readNumEntry("NumberofFiles",0); 719 int nFiles = cfg.readNumEntry("NumberofFiles",0);
721 // qDebug("init number of files %d", nFiles); 720 // odebug << "init number of files " << nFiles << "" << oendl;
722 721
723 for(int i=1;i<= nFiles;i++) { 722 for(int i=1;i<= nFiles;i++) {
724 723
725 QListViewItem * item; 724 QListViewItem * item;
726 QString fileS, mediaLocation, fileDate, filePath; 725 QString fileS, mediaLocation, fileDate, filePath;
727 726
@@ -857,13 +856,13 @@ void QtRec::initConfig() {
857 cofg.setGroup( "Volume"); 856 cofg.setGroup( "Volume");
858 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 857 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
859 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 858 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
860} 859}
861 860
862void QtRec::stop() { 861void QtRec::stop() {
863 qWarning("STOP"); 862 owarn << "STOP" << oendl;
864 setRecordButton(false); 863 setRecordButton(false);
865 864
866 if( !recording) 865 if( !recording)
867 endPlaying(); 866 endPlaying();
868 else 867 else
869 endRecording(); 868 endRecording();
@@ -919,38 +918,38 @@ bool QtRec::rec() { //record
919// qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", 918// qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d",
920// soundDevice->getDeviceBits(), 919// soundDevice->getDeviceBits(),
921// soundDevice->getDeviceRate(), 920// soundDevice->getDeviceRate(),
922// soundDevice->getDeviceChannels()); 921// soundDevice->getDeviceChannels());
923 922
924 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); 923 //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
925// qDebug("sample rate is %d", filePara.sampleRate); 924// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
926 filePara.SecondsToRecord = getCurrentSizeLimit(); 925 filePara.SecondsToRecord = getCurrentSizeLimit();
927 926
928// qDebug("size limit %d sec", filePara.SecondsToRecord); 927// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
929 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 928 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
930 929
931 if( filePara.SecondsToRecord == 0) { 930 if( filePara.SecondsToRecord == 0) {
932 fileSize = diskSize; 931 fileSize = diskSize;
933 } else if( filePara.format == WAVE_FORMAT_PCM) { 932 } else if( filePara.format == WAVE_FORMAT_PCM) {
934// qDebug("WAVE_FORMAT_PCM"); 933// odebug << "WAVE_FORMAT_PCM" << oendl;
935 fileSize = (filePara.SecondsToRecord ) * filePara.channels 934 fileSize = (filePara.SecondsToRecord ) * filePara.channels
936 * filePara.sampleRate * ( filePara.resolution / 8) + 1000; 935 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
937 } else { 936 } else {
938// qDebug("WAVE_FORMAT_DVI_ADPCM"); 937// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
939 fileSize = ((filePara.SecondsToRecord) * filePara.channels 938 fileSize = ((filePara.SecondsToRecord) * filePara.channels
940 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; 939 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
941 } 940 }
942 941
943 filePara.samplesToRecord = fileSize; 942 filePara.samplesToRecord = fileSize;
944 qDebug("filesize should be %d, bits %d, rate %d", 943 qDebug("filesize should be %d, bits %d, rate %d",
945 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); 944 filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
946 if( paused) { 945 if( paused) {
947 paused = false; 946 paused = false;
948 } 947 }
949 // else { 948 // else {
950 qDebug("Setting timeslider %d", filePara.samplesToRecord); 949 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
951 // if(fileSize != 0) 950 // if(fileSize != 0)
952 timeSlider->setRange(0, filePara.samplesToRecord); 951 timeSlider->setRange(0, filePara.samplesToRecord);
953 // } 952 // }
954 953
955 if( diskSize < fileSize/1024) { 954 if( diskSize < fileSize/1024) {
956 QMessageBox::warning(this, 955 QMessageBox::warning(this,
@@ -963,13 +962,13 @@ bool QtRec::rec() { //record
963 QString msg; 962 QString msg;
964 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 963 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
965#ifdef DEV_VERSION 964#ifdef DEV_VERSION
966 setCaption( msg); 965 setCaption( msg);
967#endif 966#endif
968 filePara.fileName=currentFile.latin1(); 967 filePara.fileName=currentFile.latin1();
969 qDebug("Start recording thread"); 968 odebug << "Start recording thread" << oendl;
970 stopped = false; 969 stopped = false;
971 970
972#ifdef THREADED 971#ifdef THREADED
973 pthread_t thread1; 972 pthread_t thread1;
974 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 973 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
975#endif 974#endif
@@ -1007,19 +1006,19 @@ void QtRec::thisTab(QWidget* widg) {
1007 update(); 1006 update();
1008 } 1007 }
1009} 1008}
1010 1009
1011void QtRec::getOutVol( ) { 1010void QtRec::getOutVol( ) {
1012 filePara.outVol = soundDevice->getOutVolume(); 1011 filePara.outVol = soundDevice->getOutVolume();
1013// qDebug("out vol %d", filePara.outVol); 1012// odebug << "out vol " << filePara.outVol << "" << oendl;
1014 OutputSlider->setValue( -filePara.outVol); 1013 OutputSlider->setValue( -filePara.outVol);
1015} 1014}
1016 1015
1017void QtRec::getInVol() { 1016void QtRec::getInVol() {
1018 filePara.inVol = soundDevice->getInVolume(); 1017 filePara.inVol = soundDevice->getInVolume();
1019// qDebug("in vol %d", filePara.inVol); 1018// odebug << "in vol " << filePara.inVol << "" << oendl;
1020 InputSlider->setValue( -filePara.inVol); 1019 InputSlider->setValue( -filePara.inVol);
1021} 1020}
1022 1021
1023void QtRec::changedOutVolume() { 1022void QtRec::changedOutVolume() {
1024 soundDevice->changedOutVolume( -OutputSlider->value()); 1023 soundDevice->changedOutVolume( -OutputSlider->value());
1025} 1024}
@@ -1087,17 +1086,17 @@ bool QtRec::setupAudio( bool b) {
1087 sampleformat = AFMT_S16_LE; 1086 sampleformat = AFMT_S16_LE;
1088 else 1087 else
1089 sampleformat = AFMT_U8; 1088 sampleformat = AFMT_U8;
1090 1089
1091 if( !compressionCheckBox->isChecked()) { 1090 if( !compressionCheckBox->isChecked()) {
1092 filePara.format = WAVE_FORMAT_PCM; 1091 filePara.format = WAVE_FORMAT_PCM;
1093// qDebug("WAVE_FORMAT_PCM"); 1092// odebug << "WAVE_FORMAT_PCM" << oendl;
1094 } else { 1093 } else {
1095 filePara.format = WAVE_FORMAT_DVI_ADPCM; 1094 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1096 sampleformat = AFMT_S16_LE; 1095 sampleformat = AFMT_S16_LE;
1097// qDebug("WAVE_FORMAT_DVI_ADPCM"); 1096// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
1098 } 1097 }
1099#endif 1098#endif
1100 1099
1101 stereo = filePara.channels; 1100 stereo = filePara.channels;
1102// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1101// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1103 flags= O_RDWR; 1102 flags= O_RDWR;
@@ -1107,21 +1106,21 @@ bool QtRec::setupAudio( bool b) {
1107 dspString = hwcfg.readEntry( "Audio", DSPSTRIN); 1106 dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
1108 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); 1107 mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
1109 recording = true; 1108 recording = true;
1110 } 1109 }
1111 1110
1112 // if(soundDevice) delete soundDevice; 1111 // if(soundDevice) delete soundDevice;
1113 qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); 1112 odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
1114 qWarning("change waveform settings"); 1113 owarn << "change waveform settings" << oendl;
1115 waveform->changeSettings( filePara.sampleRate, filePara.channels ); 1114 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1116 1115
1117 soundDevice = new Device( this, dspString, mixerString, b); 1116 soundDevice = new Device( this, dspString, mixerString, b);
1118// soundDevice->openDsp(); 1117// soundDevice->openDsp();
1119 soundDevice->reset(); 1118 soundDevice->reset();
1120 1119
1121 qDebug("device has been made %d", soundDevice->sd); 1120 odebug << "device has been made " << soundDevice->sd << "" << oendl;
1122 1121
1123 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> 1122 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1124 soundDevice->setDeviceFormat( sampleformat); 1123 soundDevice->setDeviceFormat( sampleformat);
1125 soundDevice->setDeviceChannels( filePara.channels); 1124 soundDevice->setDeviceChannels( filePara.channels);
1126 soundDevice->setDeviceRate( filePara.sampleRate); 1125 soundDevice->setDeviceRate( filePara.sampleRate);
1127 soundDevice->getDeviceFragSize(); 1126 soundDevice->getDeviceFragSize();
@@ -1146,13 +1145,13 @@ bool QtRec::setupAudio( bool b) {
1146 1145
1147 return true; 1146 return true;
1148} 1147}
1149 1148
1150 1149
1151bool QtRec::setUpFile() { //setup file for recording 1150bool QtRec::setUpFile() { //setup file for recording
1152// qDebug("Setting up wavfile"); 1151// odebug << "Setting up wavfile" << oendl;
1153// if(wavFile) delete wavFile; 1152// if(wavFile) delete wavFile;
1154 wavFile = new WavFile( this, (const QString &)"", 1153 wavFile = new WavFile( this, (const QString &)"",
1155 true, 1154 true,
1156 filePara.sampleRate, 1155 filePara.sampleRate,
1157 filePara.channels, 1156 filePara.channels,
1158 filePara.resolution, 1157 filePara.resolution,
@@ -1179,13 +1178,13 @@ bool QtRec::doPlay() {
1179 } 1178 }
1180 playing = true; 1179 playing = true;
1181 stopped = false; 1180 stopped = false;
1182 recording = false; 1181 recording = false;
1183 1182
1184 QString num; 1183 QString num;
1185 qDebug( "Play number of samples %d", filePara.numberSamples); 1184 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
1186 1185
1187// timeSlider->setRange( 0, filePara.numberSamples); 1186// timeSlider->setRange( 0, filePara.numberSamples);
1188 1187
1189 timeString.sprintf("%f", filePara.numberOfRecordedSeconds); 1188 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1190 timeLabel->setText( timeString+ tr(" seconds")); 1189 timeLabel->setText( timeString+ tr(" seconds"));
1191 1190
@@ -1231,13 +1230,13 @@ void QtRec::changesamplerateCombo(int i) {
1231 cfg.setGroup("Settings"); 1230 cfg.setGroup("Settings");
1232 int rate=0; 1231 int rate=0;
1233 bool ok; 1232 bool ok;
1234 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1233 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1235 cfg.writeEntry( "samplerate",rate); 1234 cfg.writeEntry( "samplerate",rate);
1236 filePara.sampleRate=rate; 1235 filePara.sampleRate=rate;
1237 qDebug( "Change sample rate %d", rate); 1236 odebug << "Change sample rate " << rate << "" << oendl;
1238 cfg.write(); 1237 cfg.write();
1239} 1238}
1240 1239
1241 1240
1242void QtRec::changeDirCombo(int index) { 1241void QtRec::changeDirCombo(int index) {
1243 Config cfg("OpieRec"); 1242 Config cfg("OpieRec");
@@ -1251,13 +1250,13 @@ void QtRec::changeDirCombo(int index) {
1251 for( ; it.current(); ++it ){ 1250 for( ; it.current(); ++it ){
1252 if( sName == (*it)->name()+" "+ (*it)->path() || 1251 if( sName == (*it)->name()+" "+ (*it)->path() ||
1253 (*it)->name() == sName ) { 1252 (*it)->name() == sName ) {
1254 const QString path = (*it)->path(); 1253 const QString path = (*it)->path();
1255 recDir = path; 1254 recDir = path;
1256 cfg.writeEntry("directory", recDir); 1255 cfg.writeEntry("directory", recDir);
1257 qDebug("new rec dir "+recDir); 1256 odebug << "new rec dir "+recDir << oendl;
1258 } 1257 }
1259 } 1258 }
1260 cfg.write(); 1259 cfg.write();
1261} 1260}
1262 1261
1263 1262
@@ -1371,13 +1370,13 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
1371 // stop(); 1370 // stop();
1372 break; 1371 break;
1373 case Key_Down: 1372 case Key_Down:
1374 // newSound(); 1373 // newSound();
1375 break; 1374 break;
1376 case Key_Left: { 1375 case Key_Left: {
1377 qDebug("rewinding"); 1376 odebug << "rewinding" << oendl;
1378 if( !e->isAutoRepeat()) 1377 if( !e->isAutoRepeat())
1379 rewindPressed(); 1378 rewindPressed();
1380 } 1379 }
1381 break; 1380 break;
1382 case Key_Right: { 1381 case Key_Right: {
1383 if( !e->isAutoRepeat()) 1382 if( !e->isAutoRepeat())
@@ -1425,25 +1424,25 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1425 break; 1424 break;
1426 case Key_Delete: 1425 case Key_Delete:
1427 deleteSound(); 1426 deleteSound();
1428 break; 1427 break;
1429 case Key_Up: 1428 case Key_Up:
1430 // stop(); 1429 // stop();
1431 qDebug("Up"); 1430 odebug << "Up" << oendl;
1432 break; 1431 break;
1433 case Key_Down: 1432 case Key_Down:
1434 // start(); 1433 // start();
1435 // qDebug("Down"); 1434 // odebug << "Down" << oendl;
1436 // newSound(); 1435 // newSound();
1437 break; 1436 break;
1438 case Key_Left: 1437 case Key_Left:
1439 qDebug("Left"); 1438 odebug << "Left" << oendl;
1440 rewindReleased(); 1439 rewindReleased();
1441 break; 1440 break;
1442 case Key_Right: 1441 case Key_Right:
1443 qDebug("Right"); 1442 odebug << "Right" << oendl;
1444 FastforwardReleased(); 1443 FastforwardReleased();
1445 break; 1444 break;
1446 } 1445 }
1447} 1446}
1448 1447
1449void QtRec::endRecording() { 1448void QtRec::endRecording() {
@@ -1472,17 +1471,17 @@ void QtRec::endRecording() {
1472 filePara.fd=0; 1471 filePara.fd=0;
1473 1472
1474 if( wavFile->isTempFile()) { 1473 if( wavFile->isTempFile()) {
1475// move tmp file to regular file 1474// move tmp file to regular file
1476 QString cmd; 1475 QString cmd;
1477 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1476 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1478// qDebug("moving tmp file to "+currentFileName); 1477// odebug << "moving tmp file to "+currentFileName << oendl;
1479 system( cmd.latin1()); 1478 system( cmd.latin1());
1480 } 1479 }
1481 1480
1482 qDebug("Just moved " + wavFile->currentFileName); 1481 odebug << "Just moved " + wavFile->currentFileName << oendl;
1483 Config cfg("OpieRec"); 1482 Config cfg("OpieRec");
1484 cfg.setGroup("Sounds"); 1483 cfg.setGroup("Sounds");
1485 1484
1486 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1485 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1487 1486
1488 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1487 currentFile = QFileInfo( wavFile->currentFileName).fileName();
@@ -1492,16 +1491,16 @@ void QtRec::endRecording() {
1492 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1491 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1493 cfg.writeEntry( currentFile, wavFile->currentFileName); 1492 cfg.writeEntry( currentFile, wavFile->currentFileName);
1494 1493
1495 QString time; 1494 QString time;
1496 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1495 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1497 cfg.writeEntry( wavFile->currentFileName, time ); 1496 cfg.writeEntry( wavFile->currentFileName, time );
1498// qDebug("writing config numberOfRecordedSeconds "+time); 1497// odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1499 1498
1500 cfg.write(); 1499 cfg.write();
1501 qDebug("finished recording"); 1500 odebug << "finished recording" << oendl;
1502 timeLabel->setText(""); 1501 timeLabel->setText("");
1503 } 1502 }
1504 1503
1505 if(soundDevice) delete soundDevice; 1504 if(soundDevice) delete soundDevice;
1506 1505
1507 timeSlider->setValue(0); 1506 timeSlider->setValue(0);
@@ -1513,36 +1512,36 @@ void QtRec::endPlaying() {
1513 monitoring = false; 1512 monitoring = false;
1514 recording = false; 1513 recording = false;
1515 playing = false; 1514 playing = false;
1516 stopped = true; 1515 stopped = true;
1517 waveform->reset(); 1516 waveform->reset();
1518// errorStop(); 1517// errorStop();
1519// qDebug("end playing"); 1518// odebug << "end playing" << oendl;
1520 setRecordButton( false); 1519 setRecordButton( false);
1521 1520
1522 toBeginningButton->setEnabled( true); 1521 toBeginningButton->setEnabled( true);
1523 toEndButton->setEnabled( true); 1522 toEndButton->setEnabled( true);
1524 1523
1525 if(autoMute) 1524 if(autoMute)
1526 doMute( true); 1525 doMute( true);
1527 1526
1528 soundDevice->closeDevice( false); 1527 soundDevice->closeDevice( false);
1529 soundDevice->sd = -1; 1528 soundDevice->sd = -1;
1530 // if(soundDevice) delete soundDevice; 1529 // if(soundDevice) delete soundDevice;
1531// qDebug("file and sound device closed"); 1530// odebug << "file and sound device closed" << oendl;
1532 timeLabel->setText(""); 1531 timeLabel->setText("");
1533 total = 0; 1532 total = 0;
1534 filePara.numberSamples = 0; 1533 filePara.numberSamples = 0;
1535 filePara.sd = -1; 1534 filePara.sd = -1;
1536// wavFile->closeFile(); 1535// wavFile->closeFile();
1537 filePara.fd = 0; 1536 filePara.fd = 0;
1538// if(wavFile) delete wavFile; //this crashes 1537// if(wavFile) delete wavFile; //this crashes
1539 1538
1540// qDebug("track closed"); 1539// odebug << "track closed" << oendl;
1541 killTimers(); 1540 killTimers();
1542 qWarning("reset slider"); 1541 owarn << "reset slider" << oendl;
1543 timeSlider->setValue(0); 1542 timeSlider->setValue(0);
1544 1543
1545 if(soundDevice) delete soundDevice; 1544 if(soundDevice) delete soundDevice;
1546 1545
1547} 1546}
1548 1547
@@ -1558,13 +1557,13 @@ bool QtRec::openPlayFile() {
1558 Config cfg("OpieRec"); 1557 Config cfg("OpieRec");
1559 cfg.setGroup("Sounds"); 1558 cfg.setGroup("Sounds");
1560 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1559 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1561 for(int i=0;i<nFiles+1;i++) { //look for file 1560 for(int i=0;i<nFiles+1;i++) { //look for file
1562 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1561 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1563 currentFileName = cfg.readEntry( currentFile, "" ); 1562 currentFileName = cfg.readEntry( currentFile, "" );
1564 qDebug("opening for play: " + currentFileName); 1563 odebug << "opening for play: " + currentFileName << oendl;
1565 } 1564 }
1566 } 1565 }
1567 wavFile = new WavFile(this, 1566 wavFile = new WavFile(this,
1568 currentFileName, 1567 currentFileName,
1569 false); 1568 false);
1570 filePara.fd = wavFile->wavHandle(); 1569 filePara.fd = wavFile->wavHandle();
@@ -1583,16 +1582,16 @@ bool QtRec::openPlayFile() {
1583 filePara.sampleRate = wavFile->getSampleRate(); 1582 filePara.sampleRate = wavFile->getSampleRate();
1584 filePara.resolution = wavFile->getResolution(); 1583 filePara.resolution = wavFile->getResolution();
1585 filePara.channels = wavFile->getChannels(); 1584 filePara.channels = wavFile->getChannels();
1586 timeSlider->setPageStep(1); 1585 timeSlider->setPageStep(1);
1587 monitoring = true; 1586 monitoring = true;
1588 1587
1589 qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); 1588 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
1590 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); 1589 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
1591 1590
1592 qWarning("seconds %d", sec); 1591 owarn << "seconds " << sec << "" << oendl;
1593 1592
1594 timeSlider->setRange(0, filePara.numberSamples ); 1593 timeSlider->setRange(0, filePara.numberSamples );
1595 } 1594 }
1596 1595
1597 return true; 1596 return true;
1598} 1597}
@@ -1687,25 +1686,25 @@ void QtRec::doRename() {
1687 renameBox->setFocus(); 1686 renameBox->setFocus();
1688 renameBox->show(); 1687 renameBox->show();
1689 1688
1690} 1689}
1691 1690
1692void QtRec::okRename() { 1691void QtRec::okRename() {
1693 qDebug(renameBox->text()); 1692 odebug << renameBox->text() << oendl;
1694 QString filename = renameBox->text(); 1693 QString filename = renameBox->text();
1695 cancelRename(); 1694 cancelRename();
1696 1695
1697 if( ListView1->currentItem() == NULL) 1696 if( ListView1->currentItem() == NULL)
1698 return; 1697 return;
1699 1698
1700 Config cfg("OpieRec"); 1699 Config cfg("OpieRec");
1701 cfg.setGroup("Sounds"); 1700 cfg.setGroup("Sounds");
1702 1701
1703 QString file = ListView1->currentItem()->text(0); 1702 QString file = ListView1->currentItem()->text(0);
1704 1703
1705 qDebug("filename is " + filename); 1704 odebug << "filename is " + filename << oendl;
1706 1705
1707 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1706 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1708 1707
1709 for(int i=0;i<nFiles+1;i++) { //look for file 1708 for(int i=0;i<nFiles+1;i++) { //look for file
1710 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1709 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1711 1710
@@ -1770,13 +1769,13 @@ void QtRec::doVolMuting(bool b) {
1770 cfg.writeEntry( "Mute",b); 1769 cfg.writeEntry( "Mute",b);
1771 cfg.write(); 1770 cfg.write();
1772 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1771 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1773} 1772}
1774 1773
1775void QtRec::doMicMuting(bool b) { 1774void QtRec::doMicMuting(bool b) {
1776 // qDebug("mic mute"); 1775 // odebug << "mic mute" << oendl;
1777 Config cfg( "qpe" ); 1776 Config cfg( "qpe" );
1778 cfg. setGroup( "Volume" ); 1777 cfg. setGroup( "Volume" );
1779 cfg.writeEntry( "MicMute",b); 1778 cfg.writeEntry( "MicMute",b);
1780 cfg.write(); 1779 cfg.write();
1781 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1780 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1782} 1781}
@@ -1826,13 +1825,13 @@ long QtRec::checkDiskSpace(const QString &path) {
1826// long f_files; /* Total number of file nodes */ 1825// long f_files; /* Total number of file nodes */
1827// long f_ffree; /* Count of free file nodes */ 1826// long f_ffree; /* Count of free file nodes */
1828// char f_fname[6]; /* Volumename */ 1827// char f_fname[6]; /* Volumename */
1829// char f_fpack[6]; /* Pack name */ 1828// char f_fpack[6]; /* Pack name */
1830 1829
1831void QtRec::receive( const QCString &msg, const QByteArray & ) { 1830void QtRec::receive( const QCString &msg, const QByteArray & ) {
1832 qDebug("Voicerecord received message "+msg); 1831 odebug << "Voicerecord received message "+msg << oendl;
1833 1832
1834} 1833}
1835 1834
1836 1835
1837///////////////////////////// timerEvent 1836///////////////////////////// timerEvent
1838void QtRec::timerEvent( QTimerEvent * ) { 1837void QtRec::timerEvent( QTimerEvent * ) {
@@ -1851,13 +1850,13 @@ void QtRec::timerEvent( QTimerEvent * ) {
1851 } 1850 }
1852 1851
1853 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { 1852 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
1854 stop(); 1853 stop();
1855 } 1854 }
1856 1855
1857 qDebug( "%d", secCount ); 1856 odebug << "" << secCount << "" << oendl;
1858 QString timeString; 1857 QString timeString;
1859#ifdef DEV_VERSION 1858#ifdef DEV_VERSION
1860 QString msg; 1859 QString msg;
1861 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 1860 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
1862 setCaption( msg +" :: "+QString::number(secCount)); 1861 setCaption( msg +" :: "+QString::number(secCount));
1863#endif 1862#endif
@@ -1867,13 +1866,13 @@ void QtRec::timerEvent( QTimerEvent * ) {
1867 1866
1868 secCount++; 1867 secCount++;
1869} 1868}
1870 1869
1871void QtRec::changeTimeSlider(int index) { 1870void QtRec::changeTimeSlider(int index) {
1872 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1871 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
1873 // qDebug("Slider moved to %d",index); 1872 // odebug << "Slider moved to " << index << "" << oendl;
1874 paused = true; 1873 paused = true;
1875 stopped = true; 1874 stopped = true;
1876 1875
1877 sliderPos=index; 1876 sliderPos=index;
1878 1877
1879 QString timeString; 1878 QString timeString;
@@ -1882,22 +1881,22 @@ void QtRec::changeTimeSlider(int index) {
1882 secCount = (int)filePara.numberOfRecordedSeconds; 1881 secCount = (int)filePara.numberOfRecordedSeconds;
1883 timeLabel->setText( timeString + tr(" seconds")); 1882 timeLabel->setText( timeString + tr(" seconds"));
1884} 1883}
1885 1884
1886void QtRec::timeSliderPressed() { 1885void QtRec::timeSliderPressed() {
1887 if( ListView1->currentItem() == 0) return; 1886 if( ListView1->currentItem() == 0) return;
1888 // qDebug("slider pressed"); 1887 // odebug << "slider pressed" << oendl;
1889 paused = true; 1888 paused = true;
1890 stopped = true; 1889 stopped = true;
1891} 1890}
1892 1891
1893void QtRec::timeSliderReleased() { 1892void QtRec::timeSliderReleased() {
1894 if( ListView1->currentItem() == 0) return; 1893 if( ListView1->currentItem() == 0) return;
1895 sliderPos = timeSlider->value(); 1894 sliderPos = timeSlider->value();
1896 1895
1897 // qDebug("slider released %d", sliderPos); 1896 // odebug << "slider released " << sliderPos << "" << oendl;
1898 stopped = false; 1897 stopped = false;
1899 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1898 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1900 total = newPos*4; 1899 total = newPos*4;
1901 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1900 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1902 1901
1903 doPlay(); 1902 doPlay();
@@ -1921,13 +1920,13 @@ void QtRec::rewindPressed() {
1921 1920
1922void QtRec::rewindTimerTimeout() { 1921void QtRec::rewindTimerTimeout() {
1923 int sliderValue = timeSlider->value(); 1922 int sliderValue = timeSlider->value();
1924 sliderValue = sliderValue - ( filePara.numberSamples / 100); 1923 sliderValue = sliderValue - ( filePara.numberSamples / 100);
1925 // if(toBeginningButton->isDown()) 1924 // if(toBeginningButton->isDown())
1926 timeSlider->setValue( sliderValue ) ; 1925 timeSlider->setValue( sliderValue ) ;
1927 // qDebug("%d", sliderValue); 1926 // odebug << "" << sliderValue << "" << oendl;
1928 QString timeString; 1927 QString timeString;
1929 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1928 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1930 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1929 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1931 timeLabel->setText( timeString+ tr(" seconds")); 1930 timeLabel->setText( timeString+ tr(" seconds"));
1932} 1931}
1933 1932
@@ -1935,13 +1934,13 @@ void QtRec::rewindReleased() {
1935 rewindTimer->stop(); 1934 rewindTimer->stop();
1936 if( wavFile->track.isOpen()) { 1935 if( wavFile->track.isOpen()) {
1937 sliderPos=timeSlider->value(); 1936 sliderPos=timeSlider->value();
1938 stopped = false; 1937 stopped = false;
1939 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1938 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1940 total = newPos * 4; 1939 total = newPos * 4;
1941 // qDebug("rewind released %d", total); 1940 // odebug << "rewind released " << total << "" << oendl;
1942 startTimer( 1000); 1941 startTimer( 1000);
1943 doPlay(); 1942 doPlay();
1944 } 1943 }
1945} 1944}
1946 1945
1947void QtRec::FastforwardPressed() { 1946void QtRec::FastforwardPressed() {
@@ -1999,13 +1998,13 @@ QString QtRec::getStorage(const QString &fileName) {
1999 const QString disk = ( *it)->disk(); 1998 const QString disk = ( *it)->disk();
2000 if( fileName.find( path,0,true) != -1) 1999 if( fileName.find( path,0,true) != -1)
2001 storage = name; 2000 storage = name;
2002 // const QString options = (*it)->options(); 2001 // const QString options = (*it)->options();
2003 // if( name.find( tr("Internal"),0,true) == -1) { 2002 // if( name.find( tr("Internal"),0,true) == -1) {
2004 // storageComboBox->insertItem( name +" -> "+disk); 2003 // storageComboBox->insertItem( name +" -> "+disk);
2005 // qDebug(name); 2004 // odebug << name << oendl;
2006 } 2005 }
2007 return storage; 2006 return storage;
2008 // struct mntent *me; 2007 // struct mntent *me;
2009 // // if(fileName == "/etc/mtab") { 2008 // // if(fileName == "/etc/mtab") {
2010 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 2009 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
2011 // if ( mntfp ) { 2010 // if ( mntfp ) {
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index 35bc14d..7e9b50f 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -1,33 +1,36 @@
1//wavFile.cpp 1//wavFile.cpp
2#include "wavFile.h" 2#include "wavFile.h"
3#include "qtrec.h" 3#include "qtrec.h"
4 4
5/* OPIE */
6#include <opie2/odebug.h>
7#include <qpe/config.h>
8using namespace Opie::Core;
9
10/* QT */
5#include <qmessagebox.h> 11#include <qmessagebox.h>
6#include <qdir.h> 12#include <qdir.h>
7 13
8#include <qpe/config.h> 14/* STD */
9
10#include <errno.h> 15#include <errno.h>
11
12#include <sys/time.h> 16#include <sys/time.h>
13#include <sys/types.h> 17#include <sys/types.h>
14#include <sys/vfs.h> 18#include <sys/vfs.h>
15
16#include <fcntl.h> 19#include <fcntl.h>
17#include <math.h> 20#include <math.h>
18#include <mntent.h> 21#include <mntent.h>
19#include <stdio.h> 22#include <stdio.h>
20#include <stdlib.h> 23#include <stdlib.h>
21#include <unistd.h> 24#include <unistd.h>
22 25
23WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, 26WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate,
24 int channels, int resolution, int format ) 27 int channels, int resolution, int format )
25 : QObject( parent) 28 : QObject( parent)
26{ 29{
27//qDebug("new wave file"); 30//odebug << "new wave file" << oendl;
28 bool b = makeNwFile; 31 bool b = makeNwFile;
29 wavSampleRate=sampleRate; 32 wavSampleRate=sampleRate;
30 wavFormat=format; 33 wavFormat=format;
31 wavChannels=channels; 34 wavChannels=channels;
32 wavResolution=resolution; 35 wavResolution=resolution;
33 useTmpFile=false; 36 useTmpFile=false;
@@ -37,13 +40,13 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int
37 openFile(fileName); 40 openFile(fileName);
38 } 41 }
39} 42}
40 43
41bool WavFile::newFile() { 44bool WavFile::newFile() {
42 45
43// qDebug("Set up new file"); 46// odebug << "Set up new file" << oendl;
44 Config cfg("OpieRec"); 47 Config cfg("OpieRec");
45 cfg.setGroup("Settings"); 48 cfg.setGroup("Settings");
46 49
47 currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); 50 currentFileName=cfg.readEntry("directory",QDir::homeDirPath());
48 QString date; 51 QString date;
49 QDateTime dt = QDateTime::currentDateTime(); 52 QDateTime dt = QDateTime::currentDateTime();
@@ -57,13 +60,13 @@ bool WavFile::newFile() {
57 if(currentFileName.right(1).find("/",0,true) == -1) 60 if(currentFileName.right(1).find("/",0,true) == -1)
58 currentFileName += "/" + date; 61 currentFileName += "/" + date;
59 else 62 else
60 currentFileName += date; 63 currentFileName += date;
61 currentFileName+=".wav"; 64 currentFileName+=".wav";
62 65
63// qDebug("set up file for recording: "+currentFileName); 66// odebug << "set up file for recording: "+currentFileName << oendl;
64 char pointer[] = "/tmp/opierec-XXXXXX"; 67 char pointer[] = "/tmp/opierec-XXXXXX";
65 int fd = 0; 68 int fd = 0;
66 69
67 if( currentFileName.find("/mnt",0,true) == -1 70 if( currentFileName.find("/mnt",0,true) == -1
68 && currentFileName.find("/tmp",0,true) == -1 ) { 71 && currentFileName.find("/tmp",0,true) == -1 ) {
69 // if destination file is most likely in flash (assuming jffs2) 72 // if destination file is most likely in flash (assuming jffs2)
@@ -72,23 +75,23 @@ bool WavFile::newFile() {
72 useTmpFile = true; 75 useTmpFile = true;
73 if(( fd = mkstemp( pointer)) < 0 ) { 76 if(( fd = mkstemp( pointer)) < 0 ) {
74 perror("mkstemp failed"); 77 perror("mkstemp failed");
75 return false; 78 return false;
76 } 79 }
77 80
78// qDebug("Opening tmp file %s",pointer); 81// odebug << "Opening tmp file " << pointer << "" << oendl;
79 track.setName( pointer); 82 track.setName( pointer);
80 83
81 } else { //just use regular file.. no moving 84 } else { //just use regular file.. no moving
82 85
83 useTmpFile = false; 86 useTmpFile = false;
84 track.setName( currentFileName); 87 track.setName( currentFileName);
85 } 88 }
86 if(!track.open( IO_ReadWrite | IO_Truncate)) { 89 if(!track.open( IO_ReadWrite | IO_Truncate)) {
87 QString errorMsg=(QString)strerror(errno); 90 QString errorMsg=(QString)strerror(errno);
88 qDebug(errorMsg); 91 odebug << errorMsg << oendl;
89 QMessageBox::message("Note", "Error opening file.\n" +errorMsg); 92 QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
90 93
91 return false; 94 return false;
92 } else { 95 } else {
93 setWavHeader( track.handle() , &hdr); 96 setWavHeader( track.handle() , &hdr);
94 } 97 }
@@ -103,20 +106,20 @@ WavFile::~WavFile() {
103void WavFile::closeFile() { 106void WavFile::closeFile() {
104 if(track.isOpen()) 107 if(track.isOpen())
105 track.close(); 108 track.close();
106} 109}
107 110
108int WavFile::openFile(const QString &currentFileName) { 111int WavFile::openFile(const QString &currentFileName) {
109// qDebug("open play file "+currentFileName); 112// odebug << "open play file "+currentFileName << oendl;
110 closeFile(); 113 closeFile();
111 114
112 track.setName(currentFileName); 115 track.setName(currentFileName);
113 116
114 if(!track.open(IO_ReadOnly)) { 117 if(!track.open(IO_ReadOnly)) {
115 QString errorMsg=(QString)strerror(errno); 118 QString errorMsg=(QString)strerror(errno);
116 qDebug("<<<<<<<<<<< "+errorMsg+currentFileName); 119 odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl;
117 QMessageBox::message("Note", "Error opening file.\n" +errorMsg); 120 QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
118 return -1; 121 return -1;
119 } else { 122 } else {
120 parseWavHeader( track.handle()); 123 parseWavHeader( track.handle());
121 } 124 }
122 return track.handle(); 125 return track.handle();
@@ -128,17 +131,17 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
128 strncpy((*hdr).wavID, "WAVE", 4); //WAVE 131 strncpy((*hdr).wavID, "WAVE", 4); //WAVE
129 strncpy((*hdr).fmtID, "fmt ", 4); // fmt 132 strncpy((*hdr).fmtID, "fmt ", 4); // fmt
130 (*hdr).fmtLen = 16; // format length = 16 133 (*hdr).fmtLen = 16; // format length = 16
131 134
132 if( wavFormat == WAVE_FORMAT_PCM) { 135 if( wavFormat == WAVE_FORMAT_PCM) {
133 (*hdr).fmtTag = 1; // PCM 136 (*hdr).fmtTag = 1; // PCM
134// qDebug("set header WAVE_FORMAT_PCM"); 137// odebug << "set header WAVE_FORMAT_PCM" << oendl;
135 } 138 }
136 else { 139 else {
137 (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM 140 (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM
138 // qDebug("set header WAVE_FORMAT_DVI_ADPCM"); 141 // odebug << "set header WAVE_FORMAT_DVI_ADPCM" << oendl;
139 } 142 }
140 143
141 // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels 144 // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels
142 (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels 145 (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels
143 146
144 (*hdr).sampleRate = wavSampleRate; //samples per second 147 (*hdr).sampleRate = wavSampleRate; //samples per second
@@ -157,112 +160,112 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
157bool WavFile::adjustHeaders(int fd, int total) { 160bool WavFile::adjustHeaders(int fd, int total) {
158 lseek(fd, 4, SEEK_SET); 161 lseek(fd, 4, SEEK_SET);
159 int i = total + 36; 162 int i = total + 36;
160 write( fd, &i, sizeof(i)); 163 write( fd, &i, sizeof(i));
161 lseek( fd, 40, SEEK_SET); 164 lseek( fd, 40, SEEK_SET);
162 write( fd, &total, sizeof(total)); 165 write( fd, &total, sizeof(total));
163 qDebug("adjusting header %d", total); 166 odebug << "adjusting header " << total << "" << oendl;
164 return true; 167 return true;
165} 168}
166 169
167int WavFile::parseWavHeader(int fd) { 170int WavFile::parseWavHeader(int fd) {
168 qDebug("Parsing wav header"); 171 odebug << "Parsing wav header" << oendl;
169 char string[4]; 172 char string[4];
170 int found; 173 int found;
171 short fmt; 174 short fmt;
172 unsigned short ch, bitrate; 175 unsigned short ch, bitrate;
173 unsigned long samplerrate, longdata; 176 unsigned long samplerrate, longdata;
174 177
175 if (read(fd, string, 4) < 4) { 178 if (read(fd, string, 4) < 4) {
176 qDebug(" Could not read from sound file.\n"); 179 odebug << " Could not read from sound file.\n" << oendl;
177 return -1; 180 return -1;
178 } 181 }
179 if (strncmp(string, "RIFF", 4)) { 182 if (strncmp(string, "RIFF", 4)) {
180 qDebug(" not a valid WAV file.\n"); 183 odebug << " not a valid WAV file.\n" << oendl;
181 return -1; 184 return -1;
182 } 185 }
183 lseek(fd, 4, SEEK_CUR); 186 lseek(fd, 4, SEEK_CUR);
184 if (read(fd, string, 4) < 4) { 187 if (read(fd, string, 4) < 4) {
185 qDebug("Could not read from sound file.\n"); 188 odebug << "Could not read from sound file.\n" << oendl;
186 return -1; 189 return -1;
187 } 190 }
188 if (strncmp(string, "WAVE", 4)) { 191 if (strncmp(string, "WAVE", 4)) {
189 qDebug("not a valid WAV file.\n"); 192 odebug << "not a valid WAV file.\n" << oendl;
190 return -1; 193 return -1;
191 } 194 }
192 found = 0; 195 found = 0;
193 196
194 while (!found) { 197 while (!found) {
195 if (read(fd, string, 4) < 4) { 198 if (read(fd, string, 4) < 4) {
196 qDebug("Could not read from sound file.\n"); 199 odebug << "Could not read from sound file.\n" << oendl;
197 return -1; 200 return -1;
198 } 201 }
199 if (strncmp(string, "fmt ", 4)) { 202 if (strncmp(string, "fmt ", 4)) {
200 if (read(fd, &longdata, 4) < 4) { 203 if (read(fd, &longdata, 4) < 4) {
201 qDebug("Could not read from sound file.\n"); 204 odebug << "Could not read from sound file.\n" << oendl;
202 return -1; 205 return -1;
203 } 206 }
204 lseek(fd, longdata, SEEK_CUR); 207 lseek(fd, longdata, SEEK_CUR);
205 } else { 208 } else {
206 lseek(fd, 4, SEEK_CUR); 209 lseek(fd, 4, SEEK_CUR);
207 if (read(fd, &fmt, 2) < 2) { 210 if (read(fd, &fmt, 2) < 2) {
208 qDebug("Could not read format chunk.\n"); 211 odebug << "Could not read format chunk.\n" << oendl;
209 return -1; 212 return -1;
210 } 213 }
211 if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { 214 if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) {
212 qDebug("Wave file contains unknown format." 215 qDebug("Wave file contains unknown format."
213 " Unable to continue.\n"); 216 " Unable to continue.\n");
214 return -1; 217 return -1;
215 } 218 }
216 wavFormat = fmt; 219 wavFormat = fmt;
217 // compressionFormat=fmt; 220 // compressionFormat=fmt;
218 qDebug("compressionFormat is %d", fmt); 221 odebug << "compressionFormat is " << fmt << "" << oendl;
219 if (read(fd, &ch, 2) < 2) { 222 if (read(fd, &ch, 2) < 2) {
220 qDebug("Could not read format chunk.\n"); 223 odebug << "Could not read format chunk.\n" << oendl;
221 return -1; 224 return -1;
222 } else { 225 } else {
223 wavChannels = ch; 226 wavChannels = ch;
224 qDebug("File has %d channels", ch); 227 odebug << "File has " << ch << " channels" << oendl;
225 } 228 }
226 if (read(fd, &samplerrate, 4) < 4) { 229 if (read(fd, &samplerrate, 4) < 4) {
227 qDebug("Could not read from format chunk.\n"); 230 odebug << "Could not read from format chunk.\n" << oendl;
228 return -1; 231 return -1;
229 } else { 232 } else {
230 wavSampleRate = samplerrate; 233 wavSampleRate = samplerrate;
231 // sampleRate = samplerrate; 234 // sampleRate = samplerrate;
232 qDebug("File has samplerate of %d",(int) samplerrate); 235 odebug << "File has samplerate of " << (int) samplerrate << "" << oendl;
233 } 236 }
234 lseek(fd, 6, SEEK_CUR); 237 lseek(fd, 6, SEEK_CUR);
235 if (read(fd, &bitrate, 2) < 2) { 238 if (read(fd, &bitrate, 2) < 2) {
236 qDebug("Could not read format chunk.\n"); 239 odebug << "Could not read format chunk.\n" << oendl;
237 return -1; 240 return -1;
238 } else { 241 } else {
239 wavResolution=bitrate; 242 wavResolution=bitrate;
240 // resolution = bitrate; 243 // resolution = bitrate;
241 qDebug("File has bitrate of %d", bitrate); 244 odebug << "File has bitrate of " << bitrate << "" << oendl;
242 } 245 }
243 found++; 246 found++;
244 } 247 }
245 } 248 }
246 found = 0; 249 found = 0;
247 while (!found) { 250 while (!found) {
248 if (read(fd, string, 4) < 4) { 251 if (read(fd, string, 4) < 4) {
249 qDebug("Could not read from sound file.\n"); 252 odebug << "Could not read from sound file.\n" << oendl;
250 return -1; 253 return -1;
251 } 254 }
252 255
253 if (strncmp(string, "data", 4)) { 256 if (strncmp(string, "data", 4)) {
254 if (read(fd, &longdata, 4)<4) { 257 if (read(fd, &longdata, 4)<4) {
255 qDebug("Could not read from sound file.\n"); 258 odebug << "Could not read from sound file.\n" << oendl;
256 return -1; 259 return -1;
257 } 260 }
258 261
259 lseek(fd, longdata, SEEK_CUR); 262 lseek(fd, longdata, SEEK_CUR);
260 } else { 263 } else {
261 if (read(fd, &longdata, 4) < 4) { 264 if (read(fd, &longdata, 4) < 4) {
262 qDebug("Could not read from sound file.\n"); 265 odebug << "Could not read from sound file.\n" << oendl;
263 return -1; 266 return -1;
264 } else { 267 } else {
265 wavNumberSamples = longdata; 268 wavNumberSamples = longdata;
266 qDebug("file has length of %d \nlasting %d seconds", (int)longdata, 269 qDebug("file has length of %d \nlasting %d seconds", (int)longdata,
267 (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) ); 270 (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) );
268// wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); 271// wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8));
diff --git a/noncore/multimedia/opierec/waveform.cpp b/noncore/multimedia/opierec/waveform.cpp
index 9cc40b4..7c9a25f 100644
--- a/noncore/multimedia/opierec/waveform.cpp
+++ b/noncore/multimedia/opierec/waveform.cpp
@@ -16,14 +16,18 @@
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20#include "waveform.h" 20#include "waveform.h"
21 21
22#include <qpainter.h> 22/* OPIE */
23#include <opie2/odebug.h>
24using namespace Opie::Core;
23 25
26/* QT */
27#include <qpainter.h>
24 28
25Waveform::Waveform( QWidget *parent, const char *name, WFlags fl ) 29Waveform::Waveform( QWidget *parent, const char *name, WFlags fl )
26 : QWidget( parent, name, fl ) 30 : QWidget( parent, name, fl )
27{ 31{
28 pixmap = 0; 32 pixmap = 0;
29 windowSize = 100; 33 windowSize = 100;
@@ -35,15 +39,15 @@ Waveform::Waveform( QWidget *parent, const char *name, WFlags fl )
35} 39}
36 40
37 41
38void Waveform::changeSettings( int frequency, int channels ) 42void Waveform::changeSettings( int frequency, int channels )
39{ 43{
40 makePixmap(); 44 makePixmap();
41// qWarning("change waveform %d, %d", frequency, channels); 45// owarn << "change waveform " << frequency << ", " << channels << "" << oendl;
42 samplesPerPixel = frequency * channels / (5 * windowSize); 46 samplesPerPixel = frequency * channels / (5 * windowSize);
43 qWarning("Waveform::changeSettings %d", samplesPerPixel); 47 owarn << "Waveform::changeSettings " << samplesPerPixel << "" << oendl;
44 if ( !samplesPerPixel ) 48 if ( !samplesPerPixel )
45 samplesPerPixel = 1; 49 samplesPerPixel = 1;
46 currentValue = 0; 50 currentValue = 0;
47 numSamples = 0; 51 numSamples = 0;
48 windowPosn = 0; 52 windowPosn = 0;
49 draw(); 53 draw();
@@ -93,13 +97,13 @@ void Waveform::newSamples( const short *buf, int len )
93 numSamples = 0; 97 numSamples = 0;
94 currentValue = 0; 98 currentValue = 0;
95 } 99 }
96 } 100 }
97 101
98 // Copy the final state back to the object. 102 // Copy the final state back to the object.
99//qWarning("%d, %d, %d", currentValue, numSamples, windowPosn); 103//owarn << "" << currentValue << ", " << numSamples << ", " << windowPosn << "" << oendl;
100 this->currentValue = currentValue; 104 this->currentValue = currentValue;
101 this->numSamples = numSamples; 105 this->numSamples = numSamples;
102 this->windowPosn = windowPosn; 106 this->windowPosn = windowPosn;
103} 107}
104 108
105 109