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) (side-by-side diff)
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) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp44
-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, 139 insertions, 130 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,50 +1,50 @@
// device.cpp
#include "device.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
+using namespace Opie::Core;
-
+/* STD */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <unistd.h>
#include<sys/wait.h>
-// #include <sys/stat.h>
-// #include <sys/time.h>
-// #include <sys/types.h>
#include <unistd.h>
#include <errno.h>
//extern QtRec *qperec;
Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record )
: QObject( parent)
{
dspstr = (char *)dsp;
mixstr = (char *)mixr;
devForm=-1;
devCh=-1;
devRate=-1;
if( !record){ //playing
- qDebug("setting up DSP for playing");
+ odebug << "setting up DSP for playing" << oendl;
flags = O_WRONLY;
} else { //recording
- qDebug("setting up DSP for recording");
+ odebug << "setting up DSP for recording" << oendl;
flags = O_RDWR;
// flags = O_RDONLY;
// selectMicInput();
}
}
bool Device::openDsp() {
if( openDevice( flags) == -1) {
perror("<<<<<<<<<<<<<<ioctl(\"Open device\")");
return false;
@@ -87,40 +87,40 @@ int Device::getInVolume() {
void Device::changedOutVolume(int vol) {
int level = (vol << 8) + vol;
int fd = 0;
if ((fd = open("/dev/mixer", O_RDWR))>=0) {
if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1)
perror("ioctl(\"MIXER_IN_WRITE\")");
Config cfg("qpe");
cfg.setGroup("Volume");
cfg.writeEntry("VolumePercent", QString::number( vol ));
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
- qWarning("changing output vol %d", vol);
+ owarn << "changing output vol " << vol << "" << oendl;
}
::close(fd);
}
void Device::changedInVolume(int vol ) {
int level = (vol << 8) + vol;
int fd = 0;
if ((fd = open("/dev/mixer", O_RDWR))>=0) {
if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1)
perror("ioctl(\"MIXER_IN_WRITE\")");
Config cfg("qpe");
cfg.setGroup("Volume");
cfg.writeEntry("Mic", QString::number(vol ));
QCopEnvelope( "QPE/System", "micChange(bool)" ) << false;
- qWarning("changing input volume %d", vol);
+ owarn << "changing input volume " << vol << "" << oendl;
}
::close(fd);
}
bool Device::selectMicInput() {
int md=0;
int info=MIXER_WRITE(SOUND_MIXER_MIC);
md = ::open( "/dev/mixer", O_RDWR );
if ( md == -1)
perror("open(\"/dev/mixer\")");
else {
@@ -140,56 +140,56 @@ int Device::openDevice( int flags) {
int pipefd[2];
char message[20];
if (pipe(pipefd) == -1){
perror ("Error creating pipe");
exit(1);
}
switch (pid = fork()) {
case -1:
perror("The fork failed!");
break;
case 0: {
*/
-qDebug("Opening %s",dspstr);
+odebug << "Opening " << dspstr << "" << oendl;
if (( sd = ::open( dspstr, flags)) == -1) {
perror("open(\"/dev/dsp\")");
QString errorMsg="Could not open audio device\n /dev/dsp\n"
+(QString)strerror(errno);
- qDebug("XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg);
+ odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
return -1;
}
-qDebug("Opening mixer");
+odebug << "Opening mixer" << oendl;
int mixerHandle=0;
if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) {
perror("open(\"/dev/mixer\")");
QString errorMsg="Could not open audio device\n /dev/dsp\n"
+(QString)strerror(errno);
- qDebug("XXXXXXXXXXXXXXXXXXXXXX "+errorMsg);
+ odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl;
}
if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){
perror("ioctl RESET");
}
// sprintf(message, "%d", sd);
/* QFile f1("/pid");
f1.open(IO_WriteOnly );
f1.writeBlock(message, strlen(message));
f1.close();
*/
/* close(pipefd[0]);
write(pipefd[1], message, sizeof(message));
close(pipefd[1]);
- // qDebug("%d",soundDevice->sd );
+ // odebug << "" << soundDevice->sd << "" << oendl;
_exit(0);
}
default:
// pid greater than zero is parent getting the child's pid
printf("Child's pid is %d\n",pid);
QString s;
close(pipefd[1]);
read(pipefd[0], message, sizeof(message));
s = message;
close(pipefd[0]);
// while(wait(NULL)!=pid)
@@ -197,74 +197,74 @@ qDebug("Opening mixer");
printf("child %ld terminated normally, return status is zero\n", (long) pid);
*/
// filePara.sd=(long) pid;
/* QFile f2("/pid");
f2.open(IO_ReadOnly);
QTextStream t(&f2);
// for(int f=0; f < t.atEnd() ;f++) {
s = t.readLine();
// }
*/
// bool ok;
// sd = s.toInt(&ok, 10);
-// qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s);
+// odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl;
// f2.close();
// }
::close(mixerHandle );
-// qDebug("open device %s", dspstr);
-// qDebug("success! %d",sd);
+// odebug << "open device " << dspstr << "" << oendl;
+// odebug << "success! " << sd << "" << oendl;
return sd;
}
bool Device::closeDevice( bool) {
// if(b) {//close now
// if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) {
// perror("ioctl(\"SNDCTL_DSP_RESET\")");
// }
// } else { //let play
// if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) {
// perror("ioctl(\"SNDCTL_DSP_SYNC\")");
// }
// }
::close( sd); //close sound device
// sdfd=0;
// sd=0;
-// qDebug("closed dsp");
+// odebug << "closed dsp" << oendl;
return true;
}
bool Device::setDeviceFormat( int form) {
- qDebug("set device res %d %d", form, sd);
+ odebug << "set device res " << form << " " << sd << "" << oendl;
if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format
perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
return false;
}
devRes=form;
return true;
}
bool Device::setDeviceChannels( int ch) {
- qDebug("set channels %d %d", ch, sd);
+ odebug << "set channels " << ch << " " << sd << "" << oendl;
if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) {
perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
return false;
}
devCh=ch;
return true;
}
bool Device::setDeviceRate( int rate) {
- qDebug("set rate %d %d", rate, sd);
+ odebug << "set rate " << rate << " " << sd << "" << oendl;
if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) {
perror("ioctl(\"SNDCTL_DSP_SPEED\")");
return false;
}
devRate=rate;
return true;
}
int Device::getRes() {
return devRes;
@@ -309,27 +309,27 @@ int Device::getDeviceBits() {
int Device::getDeviceChannels() {
int dCh=0;
if (ioctl( sd, SOUND_PCM_READ_CHANNELS, &dCh) == -1) {
perror("ioctl(\"SNDCTL_PCM_READ_CHANNELS\")");
}
return dCh;
}
int Device::getDeviceFragSize() {
int frag_size;
if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
- qDebug("no fragsize");
+ odebug << "no fragsize" << oendl;
} else {
- qDebug("driver says frag size is %d", frag_size);
+ odebug << "driver says frag size is " << frag_size << "" << oendl;
}
return frag_size;
}
bool Device::setFragSize(int frag) {
if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) {
perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
return false;
}
return true;
}
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
@@ -1,40 +1,45 @@
/****************************************************************************
** $Id$
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "helpwindow.h"
-#include <qlayout.h>
-#include <qtoolbar.h>
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/resource.h>
+using namespace Opie::Core;
+/* QT */
+#include <qlayout.h>
+#include <qtoolbar.h>
#include <qaction.h>
#include <qmenubar.h>
+/* STD */
#include <ctype.h>
HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name )
: QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 2);
layout->setMargin( 2);
- qDebug(_path);
+ odebug << _path << oendl;
browser = new QTextBrowser( this );
QStringList Strlist;
Strlist.append( home_);
browser->mimeSourceFactory()->setFilePath( Strlist );
browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) );
if ( !home_.isEmpty() )
browser->setSource( home_ );
QToolBar *toolbar = new QToolBar( this );
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,15 +1,13 @@
-#CONFIG = qt warn_on pdaudio
-CONFIG = qt warn_on opie
-#CONFIG = qt warn_on quick-app
+CONFIG = qt warn_on
HEADERS = adpcm.h \
pixmaps.h \
helpwindow.h \
qtrec.h \
device.h \
wavFile.h \
waveform.h
SOURCES = adpcm.c \
helpwindow.cpp \
main.cpp \
qtrec.cpp \
device.cpp \
@@ -20,22 +18,22 @@ INTERFACES =
contains(CONFIG, pdaudio) {
# LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz
LIBS += -L$(QPEDIR)/lib -lqpe -lpthread -ljpeg -lpng -lz -lopiecore2
INCLUDEPATH += $(QPEDIR)/include
DEPENDPATH += $(QPEDIR)/include
DEFINES += PDAUDIO
DEFINES += THREADED
TARGET = qperec
# DESTDIR=$(QPEDIR)/bin
}
-contains(CONFIG, opie) {
+!contains(CONFIG, pdaudio) {
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
DESTDIR=$(OPIEDIR)/bin
LIBS += -lqpe -lopiecore2 -lpthread
TARGET = opierec
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
@@ -1,68 +1,67 @@
/****************************************************************************
// qtrec.cpp
Created: Thu Jan 17 11:19:58 2002
copyright 2002 by L.J. Potter <ljp@llornkcor.com>
****************************************************************************/
#define DEV_VERSION
#include "pixmaps.h"
#include "qtrec.h"
#include "waveform.h"
-
-#include <pthread.h>
-
extern "C" {
#include "adpcm.h"
}
-#include <sys/soundcard.h>
-
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
+using namespace Opie::Core;
+/* QT */
#include <qcheckbox.h>
#include <qcombobox.h>
-//#include <qdatetime.h>
#include <qdir.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlistview.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qtabwidget.h>
#include <qtimer.h>
+/* STD */
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/vfs.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/signal.h>
-
+#include <pthread.h>
#ifdef PDAUDIO //ALSA
#include <alsa/asoundlib.h>
static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
#else //OSS
static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
static int deviceBitRates[] = { 8, 16, -1 };
#endif
#if defined(QT_QWS_SL5XXX)
///#if defined(QT_QWS_EBX)
@@ -127,55 +126,55 @@ void quickRec()
qDebug("samples %d, rate %d, channels %d",
filePara.numberSamples, filePara.sampleRate, filePara.channels);
int total = 0; // Total number of bytes read in so far.
int bytesWritten, number;
bytesWritten = 0;
number = 0;
QString num;
int level = 0;
int threshold = 0;
// int bits = filePara.resolution;
-// qDebug("bits %d", bits);
+// odebug << "bits " << bits << "" << oendl;
if( filePara.resolution == 16 ) { //AFMT_S16_LE)
-// qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord);
-// qDebug("samples to record %d", filePara.samplesToRecord);
-// qDebug("%d", filePara.sd);
+// odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
+// odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
+// odebug << "" << filePara.sd << "" << oendl;
level = 7;
threshold = 0;
if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
-// qDebug("start recording WAVE_FORMAT_DVI_ADPCM");
+// odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
char abuf[ BUFSIZE/2 ];
short sbuf[ BUFSIZE ];
short sbuf2[ BUFSIZE ];
memset( abuf, 0, BUFSIZE/2);
memset( sbuf, 0, BUFSIZE);
memset( sbuf2, 0, BUFSIZE);
for(;;) {
if ( stopped) {
-// qDebug("quickRec:: stopped");
+// odebug << "quickRec:: stopped" << oendl;
break;
}
// number=::read( filePara.sd, sbuf, BUFSIZE);
number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE);
if(number <= 0) {
perror("recording error ");
- qDebug( "%s %d", filePara.fileName, number);
+ odebug << "" << filePara.fileName << " " << number << "" << oendl;
stopped = true;
return;
}
//if(stereo == 2) {
// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
adpcm_coder( sbuf, abuf, number/2, &encoder_state);
bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
waveform->newSamples( (const short *)abuf, bytesWritten );
total += bytesWritten;
@@ -183,43 +182,43 @@ void quickRec()
timeSlider->setValue( total);
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
qApp->processEvents();
if( total >= filePara.samplesToRecord) {
stopped = true;
break;
}
}
} else {
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
- qDebug("start recording WAVE_FORMAT_PCM");
+ odebug << "start recording WAVE_FORMAT_PCM" << oendl;
short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
memset( inbuffer, 0, BUFSIZE);
memset( outbuffer, 0, BUFSIZE);
for(;;) {
if ( stopped) {
- qDebug("quickRec:: stopped");
+ odebug << "quickRec:: stopped" << oendl;
stopped = true;
break; // stop if playing was set to false
return;
}
number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE);
waveform->newSamples( inbuffer, number );
if( number <= 0) {
perror( "recording error ");
- qDebug( filePara.fileName);
+ odebug << filePara.fileName << oendl;
stopped = true;
return;
}
bytesWritten = ::write( filePara.fd , inbuffer, number);
if( bytesWritten < 0) {
perror("File writing error ");
stopped = true;
return;
}
@@ -241,25 +240,25 @@ void quickRec()
}
}
} //end main loop
} else {
// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
memset( unsigned_inbuffer, 0, BUFSIZE);
memset( unsigned_outbuffer, 0, BUFSIZE);
for(;;) {
if ( stopped) {
- qDebug("quickRec:: stopped");
+ odebug << "quickRec:: stopped" << oendl;
break; // stop if playing was set to false
}
number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
if(bytesWritten < 0) {
stopped = true;
QMessageBox::message("Note","There was a problem\nwriting to the file");
perror("File writing error ");
return;
}
@@ -364,25 +363,25 @@ void playIt()
total += bytesWritten;
timeSlider->setValue( total);
filePara.numberSamples = total;
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
// timeLabel->setText( timeString + tr(" seconds"));
qApp->processEvents();
if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
- qWarning("Jane! Stop this crazy thing!");
+ owarn << "Jane! Stop this crazy thing!" << oendl;
stopped = true;
// playing = false;
break;
}
}
printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
fflush(stdout);
} //end loop
} else {
/////////////////////////////// format = AFMT_U8;
unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
memset( unsigned_inbuffer, 0, BUFSIZE);
@@ -709,25 +708,25 @@ void QtRec::init() {
waveform->setBackgroundColor ( black );
}
void QtRec::initIconView() {
ListView1->clear();
Config cfg("OpieRec");
cfg.setGroup("Sounds");
QString temp;
QPixmap image0( ( const char** ) image0_data );
int nFiles = cfg.readNumEntry("NumberofFiles",0);
-// qDebug("init number of files %d", nFiles);
+// odebug << "init number of files " << nFiles << "" << oendl;
for(int i=1;i<= nFiles;i++) {
QListViewItem * item;
QString fileS, mediaLocation, fileDate, filePath;
temp.sprintf( "%d",i);
temp = cfg.readEntry( temp,""); //reads currentFile
filePath = cfg.readEntry( temp,""); //currentFileName
QFileInfo info(filePath);
fileDate = info.lastModified().toString();
@@ -851,25 +850,25 @@ void QtRec::initConfig() {
if( autoMuteCheckBox->isChecked())
slotAutoMute(true);
else
slotAutoMute(false);
Config cofg( "qpe");
cofg.setGroup( "Volume");
outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
}
void QtRec::stop() {
- qWarning("STOP");
+ owarn << "STOP" << oendl;
setRecordButton(false);
if( !recording)
endPlaying();
else
endRecording();
timeSlider->setValue(0);
}
void QtRec::doPlayBtn() {
if(!stopped) {
@@ -913,69 +912,69 @@ bool QtRec::rec() { //record
if( setupAudio( true))
if(setUpFile()) {
int fileSize = 0;
Config cfg("OpieRec");
cfg.setGroup("Settings");
// qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d",
// soundDevice->getDeviceBits(),
// soundDevice->getDeviceRate(),
// soundDevice->getDeviceChannels());
//filePara.sampleRate = cfg.readNumEntry("samplerate", 22050);
-// qDebug("sample rate is %d", filePara.sampleRate);
+// odebug << "sample rate is " << filePara.sampleRate << "" << oendl;
filePara.SecondsToRecord = getCurrentSizeLimit();
-// qDebug("size limit %d sec", filePara.SecondsToRecord);
+// odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl;
int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
if( filePara.SecondsToRecord == 0) {
fileSize = diskSize;
} else if( filePara.format == WAVE_FORMAT_PCM) {
-// qDebug("WAVE_FORMAT_PCM");
+// odebug << "WAVE_FORMAT_PCM" << oendl;
fileSize = (filePara.SecondsToRecord ) * filePara.channels
* filePara.sampleRate * ( filePara.resolution / 8) + 1000;
} else {
-// qDebug("WAVE_FORMAT_DVI_ADPCM");
+// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
fileSize = ((filePara.SecondsToRecord) * filePara.channels
* filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
}
filePara.samplesToRecord = fileSize;
qDebug("filesize should be %d, bits %d, rate %d",
filePara.samplesToRecord, filePara.resolution, filePara.sampleRate);
if( paused) {
paused = false;
}
// else {
- qDebug("Setting timeslider %d", filePara.samplesToRecord);
+ odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
// if(fileSize != 0)
timeSlider->setRange(0, filePara.samplesToRecord);
// }
if( diskSize < fileSize/1024) {
QMessageBox::warning(this,
tr("Low Disk Space"),
tr("You are running low of\nrecording space\n"
"or a card isn't being recognized"));
stopped = true; //we need to be stopped
stop();
} else {
QString msg;
msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
#ifdef DEV_VERSION
setCaption( msg);
#endif
filePara.fileName=currentFile.latin1();
- qDebug("Start recording thread");
+ odebug << "Start recording thread" << oendl;
stopped = false;
#ifdef THREADED
pthread_t thread1;
pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
#endif
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
startTimer(1000);
#ifndef THREADED
quickRec();
@@ -1001,31 +1000,31 @@ void QtRec::thisTab(QWidget* widg) {
}
if( index==2) { //help page
}
qApp->processEvents();
update();
}
}
void QtRec::getOutVol( ) {
filePara.outVol = soundDevice->getOutVolume();
-// qDebug("out vol %d", filePara.outVol);
+// odebug << "out vol " << filePara.outVol << "" << oendl;
OutputSlider->setValue( -filePara.outVol);
}
void QtRec::getInVol() {
filePara.inVol = soundDevice->getInVolume();
-// qDebug("in vol %d", filePara.inVol);
+// odebug << "in vol " << filePara.inVol << "" << oendl;
InputSlider->setValue( -filePara.inVol);
}
void QtRec::changedOutVolume() {
soundDevice->changedOutVolume( -OutputSlider->value());
}
void QtRec::changedInVolume( ) {
soundDevice->changedInVolume( -InputSlider->value());
}
@@ -1081,53 +1080,53 @@ bool QtRec::setupAudio( bool b) {
sampleformat = SND_PCM_FORMAT_S32;
else
sampleformat = SND_PCM_FORMAT_U8;
#else
if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
sampleformat = AFMT_S16_LE;
else
sampleformat = AFMT_U8;
if( !compressionCheckBox->isChecked()) {
filePara.format = WAVE_FORMAT_PCM;
-// qDebug("WAVE_FORMAT_PCM");
+// odebug << "WAVE_FORMAT_PCM" << oendl;
} else {
filePara.format = WAVE_FORMAT_DVI_ADPCM;
sampleformat = AFMT_S16_LE;
-// qDebug("WAVE_FORMAT_DVI_ADPCM");
+// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
}
#endif
stereo = filePara.channels;
// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
flags= O_RDWR;
// flags= O_RDONLY;
Config hwcfg("OpieRec");
hwcfg.setGroup("Hardware");
dspString = hwcfg.readEntry( "Audio", DSPSTRIN);
mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN);
recording = true;
}
// if(soundDevice) delete soundDevice;
- qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat);
- qWarning("change waveform settings");
+ odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
+ owarn << "change waveform settings" << oendl;
waveform->changeSettings( filePara.sampleRate, filePara.channels );
soundDevice = new Device( this, dspString, mixerString, b);
// soundDevice->openDsp();
soundDevice->reset();
- qDebug("device has been made %d", soundDevice->sd);
+ odebug << "device has been made " << soundDevice->sd << "" << oendl;
////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
soundDevice->setDeviceFormat( sampleformat);
soundDevice->setDeviceChannels( filePara.channels);
soundDevice->setDeviceRate( filePara.sampleRate);
soundDevice->getDeviceFragSize();
#ifdef QT_QWS_EBX
int frag = FRAGSIZE;
soundDevice->setFragSize( frag);
soundDevice->getDeviceFragSize();
#endif
/////////////////
@@ -1140,25 +1139,25 @@ bool QtRec::setupAudio( bool b) {
update();
setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
return false;
}
if(autoMute)
doMute(false);
return true;
}
bool QtRec::setUpFile() { //setup file for recording
-// qDebug("Setting up wavfile");
+// odebug << "Setting up wavfile" << oendl;
// if(wavFile) delete wavFile;
wavFile = new WavFile( this, (const QString &)"",
true,
filePara.sampleRate,
filePara.channels,
filePara.resolution,
filePara.format);
filePara.fd = wavFile->wavHandle();
if(filePara.fd == -1) {
return false;
} else {
@@ -1173,25 +1172,25 @@ bool QtRec::doPlay() {
if( !paused) {
total = 0;
filePara.numberOfRecordedSeconds = 0;
} else {
paused = false;
secCount = (int)filePara.numberOfRecordedSeconds;
}
playing = true;
stopped = false;
recording = false;
QString num;
- qDebug( "Play number of samples %d", filePara.numberSamples);
+ odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
// timeSlider->setRange( 0, filePara.numberSamples);
timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
timeLabel->setText( timeString+ tr(" seconds"));
QString msg;
msg.sprintf("%d, %d, %d",
filePara.sampleRate,
filePara.channels,
filePara.resolution);
#ifdef DEV_VERSION
@@ -1225,45 +1224,45 @@ void QtRec::changebitrateCombo(int i) {
filePara.resolution = bits;
cfg.write();
}
void QtRec::changesamplerateCombo(int i) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
int rate=0;
bool ok;
rate = sampleRateComboBox->text(i).toInt(&ok, 10);
cfg.writeEntry( "samplerate",rate);
filePara.sampleRate=rate;
- qDebug( "Change sample rate %d", rate);
+ odebug << "Change sample rate " << rate << "" << oendl;
cfg.write();
}
void QtRec::changeDirCombo(int index) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
QString sName = directoryComboBox->text(index);
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
QListIterator<FileSystem> it ( fs );
QString storage;
for( ; it.current(); ++it ){
if( sName == (*it)->name()+" "+ (*it)->path() ||
(*it)->name() == sName ) {
const QString path = (*it)->path();
recDir = path;
cfg.writeEntry("directory", recDir);
- qDebug("new rec dir "+recDir);
+ odebug << "new rec dir "+recDir << oendl;
}
}
cfg.write();
}
void QtRec::changeSizeLimitCombo(int) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
cfg.write();
}
@@ -1365,25 +1364,25 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
break;
case Key_Space:
break;
case Key_Delete:
break;
case Key_Up:
// stop();
break;
case Key_Down:
// newSound();
break;
case Key_Left: {
- qDebug("rewinding");
+ odebug << "rewinding" << oendl;
if( !e->isAutoRepeat())
rewindPressed();
}
break;
case Key_Right: {
if( !e->isAutoRepeat())
FastforwardPressed();
}
break;
}
}
@@ -1419,37 +1418,37 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
break;
case Key_Space:
if(stopped && !recording)
newSound();
else
stop();
break;
case Key_Delete:
deleteSound();
break;
case Key_Up:
// stop();
- qDebug("Up");
+ odebug << "Up" << oendl;
break;
case Key_Down:
// start();
- // qDebug("Down");
+ // odebug << "Down" << oendl;
// newSound();
break;
case Key_Left:
- qDebug("Left");
+ odebug << "Left" << oendl;
rewindReleased();
break;
case Key_Right:
- qDebug("Right");
+ odebug << "Right" << oendl;
FastforwardReleased();
break;
}
}
void QtRec::endRecording() {
monitoring = false;
recording = false;
stopped = true;
waveform->reset();
setRecordButton( false);
@@ -1466,139 +1465,139 @@ void QtRec::endRecording() {
if( wavFile->track.isOpen()) {
wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
// soundDevice->sd=-1;
filePara.numberSamples = 0;
// filePara.sd=-1;
wavFile->closeFile();
filePara.fd=0;
if( wavFile->isTempFile()) {
// move tmp file to regular file
QString cmd;
cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
-// qDebug("moving tmp file to "+currentFileName);
+// odebug << "moving tmp file to "+currentFileName << oendl;
system( cmd.latin1());
}
- qDebug("Just moved " + wavFile->currentFileName);
+ odebug << "Just moved " + wavFile->currentFileName << oendl;
Config cfg("OpieRec");
cfg.setGroup("Sounds");
int nFiles = cfg.readNumEntry( "NumberofFiles",0);
currentFile = QFileInfo( wavFile->currentFileName).fileName();
currentFile = currentFile.left( currentFile.length() - 4);
cfg.writeEntry( "NumberofFiles", nFiles + 1);
cfg.writeEntry( QString::number( nFiles + 1), currentFile);
cfg.writeEntry( currentFile, wavFile->currentFileName);
QString time;
time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
cfg.writeEntry( wavFile->currentFileName, time );
-// qDebug("writing config numberOfRecordedSeconds "+time);
+// odebug << "writing config numberOfRecordedSeconds "+time << oendl;
cfg.write();
- qDebug("finished recording");
+ odebug << "finished recording" << oendl;
timeLabel->setText("");
}
if(soundDevice) delete soundDevice;
timeSlider->setValue(0);
initIconView();
selectItemByName( currentFile);
}
void QtRec::endPlaying() {
monitoring = false;
recording = false;
playing = false;
stopped = true;
waveform->reset();
// errorStop();
-// qDebug("end playing");
+// odebug << "end playing" << oendl;
setRecordButton( false);
toBeginningButton->setEnabled( true);
toEndButton->setEnabled( true);
if(autoMute)
doMute( true);
soundDevice->closeDevice( false);
soundDevice->sd = -1;
// if(soundDevice) delete soundDevice;
-// qDebug("file and sound device closed");
+// odebug << "file and sound device closed" << oendl;
timeLabel->setText("");
total = 0;
filePara.numberSamples = 0;
filePara.sd = -1;
// wavFile->closeFile();
filePara.fd = 0;
// if(wavFile) delete wavFile; //this crashes
-// qDebug("track closed");
+// odebug << "track closed" << oendl;
killTimers();
- qWarning("reset slider");
+ owarn << "reset slider" << oendl;
timeSlider->setValue(0);
if(soundDevice) delete soundDevice;
}
bool QtRec::openPlayFile() {
qApp->processEvents();
if( currentFile.isEmpty()) {
QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
endPlaying();
return false;
}
QString currentFileName;
Config cfg("OpieRec");
cfg.setGroup("Sounds");
int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
for(int i=0;i<nFiles+1;i++) { //look for file
if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
currentFileName = cfg.readEntry( currentFile, "" );
- qDebug("opening for play: " + currentFileName);
+ odebug << "opening for play: " + currentFileName << oendl;
}
}
wavFile = new WavFile(this,
currentFileName,
false);
filePara.fd = wavFile->wavHandle();
if(filePara.fd == -1) {
// if(!track.open(IO_ReadOnly)) {
QString errorMsg = (QString)strerror(errno);
monitoring = false;
setCaption( tr( "OpieRecord " ) + QString::number(VERSION) );
QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
+ errorMsg + "\n" + currentFile);
return false;
} else {
filePara.numberSamples = wavFile->getNumberSamples();
filePara.format = wavFile->getFormat();
filePara.sampleRate = wavFile->getSampleRate();
filePara.resolution = wavFile->getResolution();
filePara.channels = wavFile->getChannels();
timeSlider->setPageStep(1);
monitoring = true;
- qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate);
+ odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
- qWarning("seconds %d", sec);
+ owarn << "seconds " << sec << "" << oendl;
timeSlider->setRange(0, filePara.numberSamples );
}
return true;
}
void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
if(item == NULL )
return;
switch (mouse) {
case 1: {
@@ -1681,37 +1680,37 @@ void QtRec::doRename() {
renameBox->selectAll();
renameBox->installEventFilter( this );
ListView1->addChild( renameBox, r.x(), r.y() );
renameBox->resize( r.size() );
ListView1->viewport()->setFocusProxy( renameBox );
renameBox->setFocus();
renameBox->show();
}
void QtRec::okRename() {
- qDebug(renameBox->text());
+ odebug << renameBox->text() << oendl;
QString filename = renameBox->text();
cancelRename();
if( ListView1->currentItem() == NULL)
return;
Config cfg("OpieRec");
cfg.setGroup("Sounds");
QString file = ListView1->currentItem()->text(0);
- qDebug("filename is " + filename);
+ odebug << "filename is " + filename << oendl;
int nFiles = cfg.readNumEntry("NumberofFiles",0);
for(int i=0;i<nFiles+1;i++) { //look for file
if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
QString filePath = cfg.readEntry(file,"");
cfg.writeEntry( QString::number(i), filename );
cfg.writeEntry( filename, filePath );
cfg.removeEntry( file);
cfg.write();
@@ -1764,25 +1763,25 @@ void QtRec::timerBreak() {
endPlaying();
}
void QtRec::doVolMuting(bool b) {
Config cfg( "qpe" );
cfg. setGroup( "Volume" );
cfg.writeEntry( "Mute",b);
cfg.write();
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
}
void QtRec::doMicMuting(bool b) {
- // qDebug("mic mute");
+ // odebug << "mic mute" << oendl;
Config cfg( "qpe" );
cfg. setGroup( "Volume" );
cfg.writeEntry( "MicMute",b);
cfg.write();
QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
}
void QtRec::compressionSelected(bool b) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
cfg.writeEntry("wavCompression", b);
cfg.writeEntry("bitrate", 16);
@@ -1820,90 +1819,90 @@ long QtRec::checkDiskSpace(const QString &path) {
// short f_fstyp; /* File system type */
// long f_bsize; /* Block size */
// long f_frsize; /* Fragment size */
// long f_blocks; /* Total number of blocks*/
// long f_bfree; /* Count of free blocks */
// long f_files; /* Total number of file nodes */
// long f_ffree; /* Count of free file nodes */
// char f_fname[6]; /* Volumename */
// char f_fpack[6]; /* Pack name */
void QtRec::receive( const QCString &msg, const QByteArray & ) {
- qDebug("Voicerecord received message "+msg);
+ odebug << "Voicerecord received message "+msg << oendl;
}
///////////////////////////// timerEvent
void QtRec::timerEvent( QTimerEvent * ) {
// if(!recording)
// timeSlider->setValue( secCount);
// else
// timeSlider->setValue( filePara.numberOfRecordedSeconds);
if( stopped && playing) {
stop();
}
if( stopped && recording ){
stop();
}
if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
stop();
}
- qDebug( "%d", secCount );
+ odebug << "" << secCount << "" << oendl;
QString timeString;
#ifdef DEV_VERSION
QString msg;
msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
setCaption( msg +" :: "+QString::number(secCount));
#endif
timeString.sprintf("%d", secCount);
timeLabel->setText( timeString + " seconds");
secCount++;
}
void QtRec::changeTimeSlider(int index) {
if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
- // qDebug("Slider moved to %d",index);
+ // odebug << "Slider moved to " << index << "" << oendl;
paused = true;
stopped = true;
sliderPos=index;
QString timeString;
filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
secCount = (int)filePara.numberOfRecordedSeconds;
timeLabel->setText( timeString + tr(" seconds"));
}
void QtRec::timeSliderPressed() {
if( ListView1->currentItem() == 0) return;
- // qDebug("slider pressed");
+ // odebug << "slider pressed" << oendl;
paused = true;
stopped = true;
}
void QtRec::timeSliderReleased() {
if( ListView1->currentItem() == 0) return;
sliderPos = timeSlider->value();
- // qDebug("slider released %d", sliderPos);
+ // odebug << "slider released " << sliderPos << "" << oendl;
stopped = false;
int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
total = newPos*4;
filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
doPlay();
}
void QtRec::rewindPressed() {
if( ListView1->currentItem() == 0) return;
if( !wavFile->track.isOpen()) {
if( !openPlayFile() )
@@ -1915,39 +1914,39 @@ void QtRec::rewindPressed() {
killTimers();
paused = true;
stopped = true;
rewindTimer->start( 50, false);
}
}
void QtRec::rewindTimerTimeout() {
int sliderValue = timeSlider->value();
sliderValue = sliderValue - ( filePara.numberSamples / 100);
// if(toBeginningButton->isDown())
timeSlider->setValue( sliderValue ) ;
- // qDebug("%d", sliderValue);
+ // odebug << "" << sliderValue << "" << oendl;
QString timeString;
filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
timeLabel->setText( timeString+ tr(" seconds"));
}
void QtRec::rewindReleased() {
rewindTimer->stop();
if( wavFile->track.isOpen()) {
sliderPos=timeSlider->value();
stopped = false;
int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
total = newPos * 4;
- // qDebug("rewind released %d", total);
+ // odebug << "rewind released " << total << "" << oendl;
startTimer( 1000);
doPlay();
}
}
void QtRec::FastforwardPressed() {
if( ListView1->currentItem() == 0) return;
if( !wavFile->track.isOpen())
if( !openPlayFile() )
return;
else
if( !setupAudio( false))
@@ -1993,25 +1992,25 @@ QString QtRec::getStorage(const QString &fileName) {
const QList<FileSystem> &fs = storageInfo.fileSystems();
QListIterator<FileSystem> it ( fs );
QString storage;
for( ; it.current(); ++it ){
const QString name = ( *it)->name();
const QString path = ( *it)->path();
const QString disk = ( *it)->disk();
if( fileName.find( path,0,true) != -1)
storage = name;
// const QString options = (*it)->options();
// if( name.find( tr("Internal"),0,true) == -1) {
// storageComboBox->insertItem( name +" -> "+disk);
- // qDebug(name);
+ // odebug << name << oendl;
}
return storage;
// struct mntent *me;
// // if(fileName == "/etc/mtab") {
// FILE *mntfp = setmntent( fileName.latin1(), "r" );
// if ( mntfp ) {
// while ( (me = getmntent( mntfp )) != 0 ) {
// QString filesystemType = me->mnt_type;
// }
// }
// endmntent( 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,274 +1,277 @@
//wavFile.cpp
#include "wavFile.h"
#include "qtrec.h"
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/config.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qmessagebox.h>
#include <qdir.h>
-#include <qpe/config.h>
-
+/* STD */
#include <errno.h>
-
#include <sys/time.h>
#include <sys/types.h>
#include <sys/vfs.h>
-
#include <fcntl.h>
#include <math.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate,
int channels, int resolution, int format )
: QObject( parent)
{
-//qDebug("new wave file");
+//odebug << "new wave file" << oendl;
bool b = makeNwFile;
wavSampleRate=sampleRate;
wavFormat=format;
wavChannels=channels;
wavResolution=resolution;
useTmpFile=false;
if( b) {
newFile();
} else {
openFile(fileName);
}
}
bool WavFile::newFile() {
-// qDebug("Set up new file");
+// odebug << "Set up new file" << oendl;
Config cfg("OpieRec");
cfg.setGroup("Settings");
currentFileName=cfg.readEntry("directory",QDir::homeDirPath());
QString date;
QDateTime dt = QDateTime::currentDateTime();
date = dt.toString();//TimeString::dateString( QDateTime::currentDateTime(),false,true);
date.replace(QRegExp("'"),"");
date.replace(QRegExp(" "),"_");
date.replace(QRegExp(":"),".");
date.replace(QRegExp(","),"");
QString currentFile=date;
if(currentFileName.right(1).find("/",0,true) == -1)
currentFileName += "/" + date;
else
currentFileName += date;
currentFileName+=".wav";
-// qDebug("set up file for recording: "+currentFileName);
+// odebug << "set up file for recording: "+currentFileName << oendl;
char pointer[] = "/tmp/opierec-XXXXXX";
int fd = 0;
if( currentFileName.find("/mnt",0,true) == -1
&& currentFileName.find("/tmp",0,true) == -1 ) {
// if destination file is most likely in flash (assuming jffs2)
// we have to write to a different filesystem first
useTmpFile = true;
if(( fd = mkstemp( pointer)) < 0 ) {
perror("mkstemp failed");
return false;
}
-// qDebug("Opening tmp file %s",pointer);
+// odebug << "Opening tmp file " << pointer << "" << oendl;
track.setName( pointer);
} else { //just use regular file.. no moving
useTmpFile = false;
track.setName( currentFileName);
}
if(!track.open( IO_ReadWrite | IO_Truncate)) {
QString errorMsg=(QString)strerror(errno);
- qDebug(errorMsg);
+ odebug << errorMsg << oendl;
QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
return false;
} else {
setWavHeader( track.handle() , &hdr);
}
return true;
}
WavFile::~WavFile() {
closeFile();
}
void WavFile::closeFile() {
if(track.isOpen())
track.close();
}
int WavFile::openFile(const QString &currentFileName) {
-// qDebug("open play file "+currentFileName);
+// odebug << "open play file "+currentFileName << oendl;
closeFile();
track.setName(currentFileName);
if(!track.open(IO_ReadOnly)) {
QString errorMsg=(QString)strerror(errno);
- qDebug("<<<<<<<<<<< "+errorMsg+currentFileName);
+ odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl;
QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
return -1;
} else {
parseWavHeader( track.handle());
}
return track.handle();
}
bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
strncpy((*hdr).riffID, "RIFF", 4); // RIFF
strncpy((*hdr).wavID, "WAVE", 4); //WAVE
strncpy((*hdr).fmtID, "fmt ", 4); // fmt
(*hdr).fmtLen = 16; // format length = 16
if( wavFormat == WAVE_FORMAT_PCM) {
(*hdr).fmtTag = 1; // PCM
-// qDebug("set header WAVE_FORMAT_PCM");
+// odebug << "set header WAVE_FORMAT_PCM" << oendl;
}
else {
(*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM
- // qDebug("set header WAVE_FORMAT_DVI_ADPCM");
+ // odebug << "set header WAVE_FORMAT_DVI_ADPCM" << oendl;
}
// (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels
(*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels
(*hdr).sampleRate = wavSampleRate; //samples per second
(*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second
(*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align
(*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16
strncpy((*hdr).dataID, "data", 4);
write( fd,hdr, sizeof(*hdr));
qDebug("writing header: bitrate%d, samplerate %d, channels %d",
wavResolution, wavSampleRate, wavChannels);
return true;
}
bool WavFile::adjustHeaders(int fd, int total) {
lseek(fd, 4, SEEK_SET);
int i = total + 36;
write( fd, &i, sizeof(i));
lseek( fd, 40, SEEK_SET);
write( fd, &total, sizeof(total));
- qDebug("adjusting header %d", total);
+ odebug << "adjusting header " << total << "" << oendl;
return true;
}
int WavFile::parseWavHeader(int fd) {
- qDebug("Parsing wav header");
+ odebug << "Parsing wav header" << oendl;
char string[4];
int found;
short fmt;
unsigned short ch, bitrate;
unsigned long samplerrate, longdata;
if (read(fd, string, 4) < 4) {
- qDebug(" Could not read from sound file.\n");
+ odebug << " Could not read from sound file.\n" << oendl;
return -1;
}
if (strncmp(string, "RIFF", 4)) {
- qDebug(" not a valid WAV file.\n");
+ odebug << " not a valid WAV file.\n" << oendl;
return -1;
}
lseek(fd, 4, SEEK_CUR);
if (read(fd, string, 4) < 4) {
- qDebug("Could not read from sound file.\n");
+ odebug << "Could not read from sound file.\n" << oendl;
return -1;
}
if (strncmp(string, "WAVE", 4)) {
- qDebug("not a valid WAV file.\n");
+ odebug << "not a valid WAV file.\n" << oendl;
return -1;
}
found = 0;
while (!found) {
if (read(fd, string, 4) < 4) {
- qDebug("Could not read from sound file.\n");
+ odebug << "Could not read from sound file.\n" << oendl;
return -1;
}
if (strncmp(string, "fmt ", 4)) {
if (read(fd, &longdata, 4) < 4) {
- qDebug("Could not read from sound file.\n");
+ odebug << "Could not read from sound file.\n" << oendl;
return -1;
}
lseek(fd, longdata, SEEK_CUR);
} else {
lseek(fd, 4, SEEK_CUR);
if (read(fd, &fmt, 2) < 2) {
- qDebug("Could not read format chunk.\n");
+ odebug << "Could not read format chunk.\n" << oendl;
return -1;
}
if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) {
qDebug("Wave file contains unknown format."
" Unable to continue.\n");
return -1;
}
wavFormat = fmt;
// compressionFormat=fmt;
- qDebug("compressionFormat is %d", fmt);
+ odebug << "compressionFormat is " << fmt << "" << oendl;
if (read(fd, &ch, 2) < 2) {
- qDebug("Could not read format chunk.\n");
+ odebug << "Could not read format chunk.\n" << oendl;
return -1;
} else {
wavChannels = ch;
- qDebug("File has %d channels", ch);
+ odebug << "File has " << ch << " channels" << oendl;
}
if (read(fd, &samplerrate, 4) < 4) {
- qDebug("Could not read from format chunk.\n");
+ odebug << "Could not read from format chunk.\n" << oendl;
return -1;
} else {
wavSampleRate = samplerrate;
// sampleRate = samplerrate;
- qDebug("File has samplerate of %d",(int) samplerrate);
+ odebug << "File has samplerate of " << (int) samplerrate << "" << oendl;
}
lseek(fd, 6, SEEK_CUR);
if (read(fd, &bitrate, 2) < 2) {
- qDebug("Could not read format chunk.\n");
+ odebug << "Could not read format chunk.\n" << oendl;
return -1;
} else {
wavResolution=bitrate;
// resolution = bitrate;
- qDebug("File has bitrate of %d", bitrate);
+ odebug << "File has bitrate of " << bitrate << "" << oendl;
}
found++;
}
}
found = 0;
while (!found) {
if (read(fd, string, 4) < 4) {
- qDebug("Could not read from sound file.\n");
+ odebug << "Could not read from sound file.\n" << oendl;
return -1;
}
if (strncmp(string, "data", 4)) {
if (read(fd, &longdata, 4)<4) {
- qDebug("Could not read from sound file.\n");
+ odebug << "Could not read from sound file.\n" << oendl;
return -1;
}
lseek(fd, longdata, SEEK_CUR);
} else {
if (read(fd, &longdata, 4) < 4) {
- qDebug("Could not read from sound file.\n");
+ odebug << "Could not read from sound file.\n" << oendl;
return -1;
} else {
wavNumberSamples = longdata;
qDebug("file has length of %d \nlasting %d seconds", (int)longdata,
(int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) );
// wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8));
return longdata;
}
}
}
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
@@ -10,46 +10,50 @@
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "waveform.h"
-#include <qpainter.h>
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+/* QT */
+#include <qpainter.h>
Waveform::Waveform( QWidget *parent, const char *name, WFlags fl )
: QWidget( parent, name, fl )
{
pixmap = 0;
windowSize = 100;
samplesPerPixel = 8000 / (5 * windowSize);
currentValue = 0;
numSamples = 0;
windowPosn = 0;
window = 0;
}
void Waveform::changeSettings( int frequency, int channels )
{
makePixmap();
-// qWarning("change waveform %d, %d", frequency, channels);
+// owarn << "change waveform " << frequency << ", " << channels << "" << oendl;
samplesPerPixel = frequency * channels / (5 * windowSize);
- qWarning("Waveform::changeSettings %d", samplesPerPixel);
+ owarn << "Waveform::changeSettings " << samplesPerPixel << "" << oendl;
if ( !samplesPerPixel )
samplesPerPixel = 1;
currentValue = 0;
numSamples = 0;
windowPosn = 0;
draw();
}
Waveform::~Waveform()
{
if ( window )
@@ -87,25 +91,25 @@ void Waveform::newSamples( const short *buf, int len )
window[windowPosn++] = (short)(currentValue / numSamples);
if ( windowPosn >= windowSize ) {
this->windowPosn = windowPosn;
draw();
windowPosn = 0;
}
numSamples = 0;
currentValue = 0;
}
}
// Copy the final state back to the object.
-//qWarning("%d, %d, %d", currentValue, numSamples, windowPosn);
+//owarn << "" << currentValue << ", " << numSamples << ", " << windowPosn << "" << oendl;
this->currentValue = currentValue;
this->numSamples = numSamples;
this->windowPosn = windowPosn;
}
void Waveform::makePixmap()
{
if ( !pixmap ) {
pixmap = new QPixmap( size() );
windowSize = pixmap->width();
window = new short [windowSize];