summaryrefslogtreecommitdiff
path: root/noncore/multimedia
authorllornkcor <llornkcor>2005-03-12 01:54:52 (UTC)
committer llornkcor <llornkcor>2005-03-12 01:54:52 (UTC)
commit84af289057291a49a52a60b390bc5320c02b5a55 (patch) (side-by-side diff)
tree523f2d36240efd4f500bfbc35996771bebd7360d /noncore/multimedia
parent6b67c3b2685b2d3f1bc7a787216aa769d4ea257a (diff)
downloadopie-84af289057291a49a52a60b390bc5320c02b5a55.zip
opie-84af289057291a49a52a60b390bc5320c02b5a55.tar.gz
opie-84af289057291a49a52a60b390bc5320c02b5a55.tar.bz2
fix irregularity with adpcm and bits
Diffstat (limited to 'noncore/multimedia') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/device.cpp16
-rw-r--r--noncore/multimedia/opierec/opierec.pro1
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp123
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp62
4 files changed, 105 insertions, 97 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp
index e7e0f4b..a76665e 100644
--- a/noncore/multimedia/opierec/device.cpp
+++ b/noncore/multimedia/opierec/device.cpp
@@ -60,6 +60,7 @@ Device::Device( QObject * parent, bool record )
if( !record){ //playing
- owarn << "setting up DSP for playing" << oendl;
- flags = O_WRONLY;
+ owarn << "New Sound device DSP for playing" << oendl;
+ flags = O_RDWR;
+// flags = O_WRONLY;
} else { //recording
- owarn << "setting up DSP for recording" << oendl;
+ owarn << "New Sound device DSP for recording" << oendl;
flags = O_RDWR;
@@ -71,2 +72,3 @@ Device::Device( QObject * parent, bool record )
bool Device::openDsp() {
+ qWarning("Device::openDsp()");
if( openDevice( flags) == -1) {
@@ -79,6 +81,6 @@ bool Device::openDsp() {
int Device::openDevice( int flags) {
- owarn << "Opening"<< dspstr;
+ owarn << "Opening sound device:"<< DSPSTROUT << oendl;
- if (( sd = ::open( DSPSTROUT, flags)) == -1) {
- perror("open(\"/dev/dsp\")");
+ if (( sd = ::open( DSPSTROUT, O_RDWR)) == -1) {
+ perror("open(\"/dev/dsp\")\n");
QString errorMsg="Could not open audio device\n /dev/dsp\n"
@@ -92,2 +94,3 @@ int Device::openDevice( int flags) {
}
+ qWarning("opened!");
return sd;
@@ -152,2 +155,3 @@ bool Device::selectMicInput() {
bool Device::closeDevice( bool) {
+ if(sd)
::close( sd); //close sound device
diff --git a/noncore/multimedia/opierec/opierec.pro b/noncore/multimedia/opierec/opierec.pro
index 6a5838a..6008bf7 100644
--- a/noncore/multimedia/opierec/opierec.pro
+++ b/noncore/multimedia/opierec/opierec.pro
@@ -33,2 +33,3 @@ contains(CONFIG, pdaudio) {
LIBS += -lqpe -lopiecore2 -lpthread
+ DEFINES += THREADED
TARGET = opierec
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index e827083..9b761aa 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -119,9 +119,9 @@ void quickRec()
int threshold = 0;
- int bits = filePara.resolution;
- odebug << "bits " << bits << "" << oendl;
+ int bits = filePara.resolution;
+ odebug << "bits " << bits << "" << oendl;
if( filePara.resolution == 16 ) { //AFMT_S16_LE)
- odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
- odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
- odebug << "" << filePara.sd << "" << oendl;
+ odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
+ odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
+ odebug << "" << filePara.sd << "" << oendl;
level = 7;
@@ -130,3 +130,3 @@ void quickRec()
if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
- odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
+ odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
@@ -158,3 +158,3 @@ void quickRec()
- bytesWritten = ::write( filePara.fd , (short *)abuf, number/4);
+ bytesWritten = ::write( filePara.fd , abuf, number/4);
@@ -166,6 +166,6 @@ void quickRec()
- printf("%d, bytes %d,total %d\r", number, bytesWritten, total);
- fflush(stdout);
+ printf("%d, bytes %d,total %d\r", number, bytesWritten, total);
+ fflush(stdout);
- filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels;
+ filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;// / filePara.channels;
@@ -216,4 +216,4 @@ void quickRec()
timeSlider->setValue( total);
- printf("%d, bytes %d,total %d\r",number, bytesWritten , total);
- fflush(stdout);
+ printf("%d, bytes %d,total %d\r",number, bytesWritten , total);
+ fflush(stdout);
@@ -303,4 +303,6 @@ void playIt()
// }
- bytesWritten = write ( filePara.sd, sbuf, number * 4);
- waveform->newSamples( (const short *)sbuf, number *4);
+ bytesWritten = write ( soundDevice->sd , sbuf, number * 4);
+
+ waveform->newSamples( sbuf, number );
+
// if(filePara.channels==1)
@@ -344,3 +346,3 @@ void playIt()
// }
- bytesWritten = ::write( filePara.sd, inbuffer, number);
+ bytesWritten = ::write( soundDevice->sd, inbuffer, number);
waveform->newSamples( inbuffer, number);
@@ -434,3 +436,3 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
// if( soundDevice) delete soundDevice;
- QTimer::singleShot(100,this, SLOT(initIconView()));
+ QTimer::singleShot(100,this, SLOT(initIconView()));
@@ -790,4 +792,4 @@ void QtRec::initConfig() {
if( compressionCheckBox->isChecked()) {
+ bitRateComboBox->setCurrentItem(1);
bitRateComboBox->setEnabled(false);
- bitRateComboBox->setCurrentItem(0);
filePara.resolution=16;
@@ -1050,3 +1052,3 @@ bool QtRec::setupAudio( bool b) {
// if(soundDevice) delete soundDevice;
- odebug << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
+ owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
// owarn << "change waveform settings" << oendl;
@@ -1232,34 +1234,34 @@ void QtRec::deleteSound() {
// {
- QString file = ListView1->currentItem()->text(0);
- QString fileName;
- fileName = cfg.readEntry( file, "");
- QFile f( fileName);
- if( f.exists())
- if( !f.remove())
- QMessageBox::message( tr("Error"), tr("Could not remove file."));
-
- int nFiles = cfg.readNumEntry( "NumberofFiles",0);
- bool found = false;
- for(int i=0;i<nFiles+1;i++) {
-
- if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
- found = true;
- cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
- }
- if(found)
- cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
- }
-
- cfg.removeEntry( cfg.readEntry( file));
- cfg.removeEntry( file);
- cfg.writeEntry( "NumberofFiles", nFiles-1);
- cfg.write();
-
- ListView1->takeItem( ListView1->currentItem() );
- delete ListView1->currentItem();
-
- ListView1->clear();
- ListView1->setSelected( ListView1->firstChild(), true);
- initIconView();
- update();
+ QString file = ListView1->currentItem()->text(0);
+ QString fileName;
+ fileName = cfg.readEntry( file, "");
+ QFile f( fileName);
+ if( f.exists())
+ if( !f.remove())
+ QMessageBox::message( tr("Error"), tr("Could not remove file."));
+
+ int nFiles = cfg.readNumEntry( "NumberofFiles",0);
+ bool found = false;
+ for(int i=0;i<nFiles+1;i++) {
+
+ if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
+ found = true;
+ cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
+ }
+ if(found)
+ cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
+ }
+
+ cfg.removeEntry( cfg.readEntry( file));
+ cfg.removeEntry( file);
+ cfg.writeEntry( "NumberofFiles", nFiles-1);
+ cfg.write();
+
+ ListView1->takeItem( ListView1->currentItem() );
+ delete ListView1->currentItem();
+
+ ListView1->clear();
+ ListView1->setSelected( ListView1->firstChild(), true);
+ initIconView();
+ update();
setCaption( tr( "OpieRecord " ));
@@ -1411,3 +1413,3 @@ void QtRec::endRecording() {
cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
- odebug << "moving tmp file to "+currentFileName << oendl;
+ odebug << "moving tmp file to "+currentFileName << oendl;
system( cmd.latin1());
@@ -1431,3 +1433,3 @@ void QtRec::endRecording() {
cfg.writeEntry( wavFile->currentFileName, time );
- odebug << "writing config numberOfRecordedSeconds "+time << oendl;
+ odebug << "writing config numberOfRecordedSeconds "+time << oendl;
@@ -1485,6 +1487,6 @@ void QtRec::endPlaying() {
bool QtRec::openPlayFile() {
-
+ qWarning("opening file");
qApp->processEvents();
if( currentFile.isEmpty()) {
- QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
+ QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
endPlaying();
@@ -1728,4 +1730,5 @@ void QtRec::compressionSelected(bool b) {
if(b) {
- bitRateComboBox->setEnabled( false);
+ qWarning("set adpcm");
bitRateComboBox->setCurrentItem( 1);
+ bitRateComboBox->setEnabled( false);
filePara.resolution = 16;
@@ -1803,3 +1806,3 @@ void QtRec::changeTimeSlider(int index) {
if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
- odebug << "Slider moved to " << index << "" << oendl;
+ odebug << "Slider moved to " << index << "" << oendl;
paused = true;
@@ -1818,3 +1821,3 @@ void QtRec::timeSliderPressed() {
if( ListView1->currentItem() == 0) return;
- odebug << "slider pressed" << oendl;
+ odebug << "slider pressed" << oendl;
paused = true;
@@ -1827,3 +1830,3 @@ void QtRec::timeSliderReleased() {
- odebug << "slider released " << sliderPos << "" << oendl;
+ odebug << "slider released " << sliderPos << "" << oendl;
stopped = false;
@@ -1857,3 +1860,3 @@ void QtRec::rewindTimerTimeout() {
timeSlider->setValue( sliderValue ) ;
- odebug << "" << sliderValue << "" << oendl;
+ odebug << "" << sliderValue << "" << oendl;
QString timeString;
@@ -1871,3 +1874,3 @@ void QtRec::rewindReleased() {
total = newPos * 4;
- odebug << "rewind released " << total << "" << oendl;
+ odebug << "rewind released " << total << "" << oendl;
startTimer( 1000);
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp
index 80453e1..b53c416 100644
--- a/noncore/multimedia/opierec/wavFile.cpp
+++ b/noncore/multimedia/opierec/wavFile.cpp
@@ -29,3 +29,3 @@ WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int
{
-//odebug << "new wave file" << oendl;
+ owarn << "new wave file: " << fileName << oendl;
bool b = makeNwFile;
@@ -111,16 +111,16 @@ void WavFile::closeFile() {
int WavFile::openFile(const QString &currentFileName) {
-// odebug << "open play file "+currentFileName << oendl;
+ qWarning("open play file "+currentFileName);;
closeFile();
- track.setName(currentFileName);
-
- if(!track.open(IO_ReadOnly)) {
- QString errorMsg=(QString)strerror(errno);
- odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl;
- QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
- return -1;
- } else {
- parseWavHeader( track.handle());
- }
- return track.handle();
+ track.setName(currentFileName);
+
+ if(!track.open(IO_ReadOnly)) {
+ QString errorMsg=(QString)strerror(errno);
+ odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl;
+ QMessageBox::message("Note", "Error opening file.\n" +errorMsg);
+ return -1;
+ } else {
+ parseWavHeader( track.handle());
+ }
+ return track.handle();
}
@@ -154,3 +154,3 @@ bool WavFile::setWavHeader(int fd, wavhdr *hdr) {
write( fd,hdr, sizeof(*hdr));
- odebug << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl;
+ owarn << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl;
return true;
@@ -164,3 +164,3 @@ bool WavFile::adjustHeaders(int fd, int total) {
write( fd, &total, sizeof(total));
- odebug << "adjusting header " << total << "" << oendl;
+ owarn << "adjusting header " << total << "" << oendl;
return true;
@@ -169,3 +169,3 @@ bool WavFile::adjustHeaders(int fd, int total) {
int WavFile::parseWavHeader(int fd) {
- odebug << "Parsing wav header" << oendl;
+ owarn << "Parsing wav header" << oendl;
char string[4];
@@ -177,3 +177,3 @@ int WavFile::parseWavHeader(int fd) {
if (read(fd, string, 4) < 4) {
- odebug << " Could not read from sound file." << oendl;
+ owarn << " Could not read from sound file." << oendl;
return -1;
@@ -181,3 +181,3 @@ int WavFile::parseWavHeader(int fd) {
if (strncmp(string, "RIFF", 4)) {
- odebug << " not a valid WAV file." << oendl;
+ owarn << " not a valid WAV file." << oendl;
return -1;
@@ -186,3 +186,3 @@ int WavFile::parseWavHeader(int fd) {
if (read(fd, string, 4) < 4) {
- odebug << "Could not read from sound file." << oendl;
+ owarn << "Could not read from sound file." << oendl;
return -1;
@@ -190,3 +190,3 @@ int WavFile::parseWavHeader(int fd) {
if (strncmp(string, "WAVE", 4)) {
- odebug << "not a valid WAV file." << oendl;
+ owarn << "not a valid WAV file." << oendl;
return -1;
@@ -197,3 +197,3 @@ int WavFile::parseWavHeader(int fd) {
if (read(fd, string, 4) < 4) {
- odebug << "Could not read from sound file." << oendl;
+ owarn << "Could not read from sound file." << oendl;
return -1;
@@ -202,3 +202,3 @@ int WavFile::parseWavHeader(int fd) {
if (read(fd, &longdata, 4) < 4) {
- odebug << "Could not read from sound file." << oendl;
+ owarn << "Could not read from sound file." << oendl;
return -1;
@@ -209,3 +209,3 @@ int WavFile::parseWavHeader(int fd) {
if (read(fd, &fmt, 2) < 2) {
- odebug << "Could not read format chunk." << oendl;
+ owarn << "Could not read format chunk." << oendl;
return -1;
@@ -213,3 +213,3 @@ int WavFile::parseWavHeader(int fd) {
if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) {
- odebug << "Wave file contains unknown format. Unable to continue." << oendl;
+ owarn << "Wave file contains unknown format. Unable to continue." << oendl;
return -1;
@@ -218,5 +218,5 @@ int WavFile::parseWavHeader(int fd) {
// compressionFormat=fmt;
- odebug << "compressionFormat is " << fmt << "" << oendl;
+ owarn << "compressionFormat is " << fmt << "" << oendl;
if (read(fd, &ch, 2) < 2) {
- odebug << "Could not read format chunk." << oendl;
+ owarn << "Could not read format chunk." << oendl;
return -1;
@@ -224,6 +224,6 @@ int WavFile::parseWavHeader(int fd) {
wavChannels = ch;
- odebug << "File has " << ch << " channels" << oendl;
+ owarn << "File has " << ch << " channels" << oendl;
}
if (read(fd, &samplerrate, 4) < 4) {
- odebug << "Could not read from format chunk." << oendl;
+ owarn << "Could not read from format chunk." << oendl;
return -1;
@@ -232,3 +232,3 @@ int WavFile::parseWavHeader(int fd) {
// sampleRate = samplerrate;
- odebug << "File has samplerate of " << (int) samplerrate << "" << oendl;
+ owarn << "File has samplerate of " << (int) samplerrate << "" << oendl;
}
@@ -236,3 +236,3 @@ int WavFile::parseWavHeader(int fd) {
if (read(fd, &bitrate, 2) < 2) {
- odebug << "Could not read format chunk." << oendl;
+ owarn << "Could not read format chunk." << oendl;
return -1;
@@ -241,3 +241,3 @@ int WavFile::parseWavHeader(int fd) {
// resolution = bitrate;
- odebug << "File has bitrate of " << bitrate << "" << oendl;
+ owarn << "File has bitrate of " << bitrate << "" << oendl;
}