summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-12-31 20:43:51 (UTC)
committer llornkcor <llornkcor>2003-12-31 20:43:51 (UTC)
commitc395fd13c51385f212648c9995361715ffc9e182 (patch) (side-by-side diff)
tree8bc55b345044e3f17bf29a1f62cf620626270bbe
parent9f9deb7648c0b9bc04ee54bc0ceaf8a5b03441fd (diff)
downloadopie-c395fd13c51385f212648c9995361715ffc9e182.zip
opie-c395fd13c51385f212648c9995361715ffc9e182.tar.gz
opie-c395fd13c51385f212648c9995361715ffc9e182.tar.bz2
add pdaudio stuff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opierec/main.cpp13
-rw-r--r--noncore/multimedia/opierec/opierec.pro24
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp103
-rw-r--r--noncore/multimedia/opierec/qtrec.h5
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp3
5 files changed, 114 insertions, 34 deletions
diff --git a/noncore/multimedia/opierec/main.cpp b/noncore/multimedia/opierec/main.cpp
index e36d050..714907c 100644
--- a/noncore/multimedia/opierec/main.cpp
+++ b/noncore/multimedia/opierec/main.cpp
@@ -6,14 +6,25 @@
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "qtrec.h"
#include <qpe/qpeapplication.h>
-#include <opie/oapplicationfactory.h>
+#ifdef PDAUDIO
+int main(int argc, char* argv[]) {
+ QPEApplication a(argc, argv);
+ QtRec qtrec;
+ a.showMainWidget( &qtrec);
+ return a.exec();
+}
+
+
+#else
+#include <opie/oapplicationfactory.h>
OPIE_EXPORT_APP( OApplicationFactory<QtRec> )
+#endif
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro
index b607c09..39fe493 100644
--- a/noncore/multimedia/opierec/opierec.pro
+++ b/noncore/multimedia/opierec/opierec.pro
@@ -1,26 +1,40 @@
-CONFIG = qt warn_on release
+#CONFIG = qt qtopia warn_on release pdaudio
+CONFIG = qt warn_on release opie
#CONFIG = qt warn_on release quick-app
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 \
wavFile.cpp \
waveform.cpp
+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
+ INCLUDEPATH += $(QPEDIR)/include
+ DEPENDPATH += $(QPEDIR)/include
+ DEFINES += PDAUDIO
+ TARGET = qperec
+
+# DESTDIR=$(QPEDIR)/bin
+}
+
+contains(CONFIG, opie) {
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-#LIBS += -L/opt/buildroot-opie/output/staging/target/lib -lqpe -lpthread -ljpeg -lpng -lz
+ DESTDIR=$(OPIEDIR)/bin
LIBS += -lqpe -lpthread
-INTERFACES =
TARGET = opierec
-DESTDIR=$(OPIEDIR)/bin
-
include ( $(OPIEDIR)/include.pro )
+}
+
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index aeab26d..bc6abcc 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -51,16 +51,26 @@ extern "C" {
#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>
+
+#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)
#define DSPSTROUT "/dev/dsp"
#define DSPSTRIN "/dev/dsp1"
#define DSPSTRMIXEROUT "/dev/mixer"
#define DSPSTRMIXERIN "/dev/mixer1"
@@ -103,19 +113,19 @@ QLabel *timeLabel;
QSlider *timeSlider;
int sd;
Waveform* waveform;
Device *soundDevice;
// threaded recording
//fuckin fulgy here
-void quickRec()
-{
-//void QtRec::quickRec() {
+//void quickRec()
+//{
+void QtRec::quickRec() {
qDebug("%d",
filePara.numberSamples/filePara.sampleRate * filePara.channels);
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;
@@ -158,17 +168,19 @@ void quickRec()
perror("recording error ");
qDebug( "%s %d", filePara.fileName, number);
stopped = true;
return;
}
//if(stereo == 2) {
// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
adpcm_coder( sbuf, abuf, number/2, &encoder_state);
- bytesWritten = soundDevice->devWrite( filePara.fd , (short *)abuf, number/4);
+
+ bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
+
waveform->newSamples( (const short *)abuf, bytesWritten );
total += bytesWritten;
filePara.numberSamples = total;
timeSlider->setValue( total);
filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
@@ -198,17 +210,17 @@ void quickRec()
if( number <= 0) {
perror( "recording error ");
qDebug( filePara.fileName);
stopped = true;
return;
}
- bytesWritten = soundDevice->devWrite( filePara.fd , inbuffer, number);
+ bytesWritten = ::write( filePara.fd , inbuffer, number);
if( bytesWritten < 0) {
perror("File writing error ");
stopped = true;
return;
}
total += bytesWritten;
@@ -265,18 +277,19 @@ void quickRec()
if( total >= filePara.samplesToRecord) {
stopped = true;
break;
}
} //end main loop
}
} /// END quickRec()
+void QtRec::playIt()
-void playIt()
+//void playIt()
{
int bytesWritten, number;
int total = 0; // Total number of bytes read in so far.
if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
char abuf[ BUFSIZE / 2 ];
short sbuf[ BUFSIZE ];
short sbuf2[ BUFSIZE * 2 ];
@@ -564,25 +577,23 @@ void QtRec::init() {
////////////////////////////////////
sampleGroup = new QGroupBox( tab_3, "samplegroup" );
sampleGroup->setTitle( tr( "Sample Rate" ) );
sampleGroup->setFixedSize( 95,50);
sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
//#ifndef QT_QWS_EBX
- sampleRateComboBox->insertItem( tr( "44100"));
- sampleRateComboBox->insertItem( tr( "32000"));
-//#endif
- sampleRateComboBox->insertItem( tr( "22050"));
- //#ifndef QT_QWS_VERCEL_IDR
- sampleRateComboBox->insertItem( tr( "16000"));
- sampleRateComboBox->insertItem( tr( "11025"));
- sampleRateComboBox->insertItem( tr( "8000"));
- //#endif
+ QString s;
+ int z = 0;
+ while( deviceSampleRates[z] != -1) {
+ sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
+ z++;
+ }
+
glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
sizeGroup->setTitle( tr( "Limit Size" ) );
sizeGroup->setFixedSize( 80, 50);
sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
@@ -604,18 +615,23 @@ void QtRec::init() {
glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
bitGroup = new QGroupBox( tab_3, "bitGroup" );
bitGroup->setTitle( tr( "Bit Depth" ) );
bitGroup->setFixedSize( 65, 50);
bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
- bitRateComboBox->insertItem( tr( "16" ) );
- bitRateComboBox->insertItem( tr( "8" ) );
+
+ z = 0;
+ while( deviceBitRates[z] != -1) {
+ bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
+ z++;
+ }
+
bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 );
@@ -840,19 +856,24 @@ void QtRec::initConfig() {
if( index == fred) {
filePara.sampleRate = fred;
sampleRateComboBox->setCurrentItem(ws);
}
}
i = cfg.readNumEntry("bitrate",16);
if(i == 16)
- bitRateComboBox->setCurrentItem( 0);
- else
bitRateComboBox->setCurrentItem( 1);
+ else if(i == 24)
+ bitRateComboBox->setCurrentItem( 2);
+ else if(i == 32)
+ bitRateComboBox->setCurrentItem( 3);
+ else
+ bitRateComboBox->setCurrentItem( 0);
+
filePara.resolution = i;
i = cfg.readNumEntry("sizeLimit", 5 );
QString temp;
sizeLimitCombo->setCurrentItem((i/5));
stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1));
if( stereoCheckBox->isChecked()) {
@@ -985,23 +1006,23 @@ bool QtRec::rec() { //record
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");
stopped = false;
- pthread_t thread1;
- pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
+// pthread_t thread1;
+// pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
startTimer(1000);
-// quickRec();
+ quickRec();
}
} //end setUpFile
} //end setupAudio
return true;
}
/*
This happens when a tab is selected*/
void QtRec::thisTab(QWidget* widg) {
@@ -1048,46 +1069,75 @@ void QtRec::changedInVolume( ) {
bool QtRec::setupAudio( bool b) {
bool ok;
int sampleformat, stereo, flags;
char * dspString, *mixerString;
filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
+#ifdef PDAUDIO //ALSA
+ if( !b) { // we want to play
+ if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
+ sampleformat = SND_PCM_FORMAT_S16;
+ filePara.resolution = 16;
+ } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) {
+ sampleformat = SND_PCM_FORMAT_S24;
+ filePara.resolution = 24;
+ } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) {
+ sampleformat = SND_PCM_FORMAT_S32;
+ filePara.resolution = 32;
+ } else {
+ sampleformat = SND_PCM_FORMAT_U8;
+ filePara.resolution = 8;
+ }
+#else
if( !b) {
// we want to play
if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
sampleformat = AFMT_S16_LE;
filePara.resolution = 16;
} else {
sampleformat = AFMT_U8;
filePara.resolution = 8;
}
+#endif
stereo = filePara.channels;
flags = O_WRONLY;
dspString = DSPSTROUT;
mixerString = DSPSTRMIXEROUT;
recording = false;
} else { // we want to record
+#ifdef PDAUDIO //ALSA
+ if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
+ sampleformat = SND_PCM_FORMAT_S16;
+ else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
+ sampleformat = SND_PCM_FORMAT_S24;
+ else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
+ 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");
} else {
filePara.format = WAVE_FORMAT_DVI_ADPCM;
sampleformat = AFMT_S16_LE;
// qDebug("WAVE_FORMAT_DVI_ADPCM");
}
+#endif
stereo = filePara.channels;
// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
flags= O_RDWR;
// flags= O_RDONLY;
dspString = DSPSTRIN;
mixerString = DSPSTRMIXEROUT;
recording = true;
@@ -1178,31 +1228,34 @@ bool QtRec::doPlay() {
filePara.sampleRate,
filePara.channels,
filePara.resolution);
#ifdef DEV_VERSION
setCaption( msg);
#endif
startTimer( 1000);
- pthread_t thread2;
- pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
+// pthread_t thread2;
+// pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
toBeginningButton->setEnabled( false);
toEndButton->setEnabled( false);
+ playIt();
return true;
}
void QtRec::changebitrateCombo(int i) {
Config cfg("OpieRec");
cfg.setGroup("Settings");
int bits = 0;
- if( i == 0) { bits = 16; }
+ if( i == 1) { bits = 16; }
+ else if( i == 2) { bits = 24; }
+ else if( i == 3) { bits = 32; }
else { bits=8; }
cfg.writeEntry("bitrate", bits);
filePara.resolution = bits;
cfg.write();
}
void QtRec::changesamplerateCombo(int i) {
Config cfg("OpieRec");
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h
index 93b9b5f..31cff9e 100644
--- a/noncore/multimedia/opierec/qtrec.h
+++ b/noncore/multimedia/opierec/qtrec.h
@@ -1,15 +1,15 @@
/****************************************************************************
** Created: Thu Jan 17 11:19:45 2002
copyright 2002 by L.J. Potter ljp@llornkcor.com
****************************************************************************/
#ifndef QTREC_H
#define QTREC_H
-#define VERSION 20030920
+#define VERSION 20040101
#include <qpe/ir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlineedit.h>
#include <qpixmap.h>
#include <qvariant.h>
@@ -172,13 +172,14 @@ protected:
void endPlaying();
void endRecording();
void fileBeamFinished( Ir *ir);
void initIconView();
void keyPressEvent( QKeyEvent *e);
void keyReleaseEvent( QKeyEvent *e);
void receive( const QCString &, const QByteArray & );
void showListMenu(QListViewItem * );
-// void quickRec();
+ void quickRec();
+ void playIt();
};
#endif // QTREC_H
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index 987fa32..1d58bb3 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -42,17 +42,18 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int
bool WavFile::newFile() {
// qDebug("Set up new file");
Config cfg("OpieRec");
cfg.setGroup("Settings");
currentFileName=cfg.readEntry("directory",QDir::homeDirPath());
QString date;
- date = TimeString::dateString( QDateTime::currentDateTime(),false,true);
+ 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;