summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/helpwindow.cpp8
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp6
2 files changed, 8 insertions, 6 deletions
diff --git a/noncore/multimedia/opierec/helpwindow.cpp b/noncore/multimedia/opierec/helpwindow.cpp
index 7f984c3..b0a8ac3 100644
--- a/noncore/multimedia/opierec/helpwindow.cpp
+++ b/noncore/multimedia/opierec/helpwindow.cpp
@@ -1,201 +1,203 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5** 5**
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 12
13/* OPIE */ 13/* OPIE */
14#include <opie2/odebug.h> 14#include <opie2/odebug.h>
15#include <qpe/resource.h> 15#include <opie2/oresource.h>
16using namespace Opie::Core; 16using namespace Opie::Core;
17 17
18/* QT */ 18/* QT */
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qtoolbar.h> 20#include <qtoolbar.h>
21#include <qaction.h> 21#include <qaction.h>
22#include <qmenubar.h> 22#include <qmenubar.h>
23 23
24/* STD */ 24/* STD */
25#include <ctype.h> 25#include <ctype.h>
26 26
27HelpWindow::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 )
28 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() 28 : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
29{ 29{
30 QGridLayout *layout = new QGridLayout( this ); 30 QGridLayout *layout = new QGridLayout( this );
31 layout->setSpacing( 2); 31 layout->setSpacing( 2);
32 layout->setMargin( 2); 32 layout->setMargin( 2);
33 odebug << _path << oendl; 33 odebug << _path << oendl;
34 browser = new QTextBrowser( this ); 34 browser = new QTextBrowser( this );
35 QStringList Strlist; 35 QStringList Strlist;
36 Strlist.append( home_); 36 Strlist.append( home_);
37 browser->mimeSourceFactory()->setFilePath( Strlist ); 37 browser->mimeSourceFactory()->setFilePath( Strlist );
38 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 38 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
39 39
40 connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); 40 connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) );
41 41
42 if ( !home_.isEmpty() ) 42 if ( !home_.isEmpty() )
43 browser->setSource( home_ ); 43 browser->setSource( home_ );
44 QToolBar *toolbar = new QToolBar( this ); 44 QToolBar *toolbar = new QToolBar( this );
45 45
46 QAction *a = new QAction( tr( "Backward" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); 46 QAction *a = new QAction( tr( "Backward" ), Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ),
47 QString::null, 0, this, 0 );
47 connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) ); 48 connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) );
48 a->addTo( toolbar ); 49 a->addTo( toolbar );
49 50
50 a = new QAction( tr( "Forward" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); 51 a = new QAction( tr( "Forward" ), Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ),
52 QString::null, 0, this, 0 );
51 connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) ); 53 connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) );
52 a->addTo( toolbar ); 54 a->addTo( toolbar );
53 55
54 56
55 layout->addMultiCellWidget( toolbar, 0, 0, 0, 0); 57 layout->addMultiCellWidget( toolbar, 0, 0, 0, 0);
56 58
57 layout->addMultiCellWidget( browser, 1, 2, 0, 2); 59 layout->addMultiCellWidget( browser, 1, 2, 0, 2);
58 60
59 browser->setFocus(); 61 browser->setFocus();
60} 62}
61 63
62 64
63void HelpWindow::setBackwardAvailable( bool b) 65void HelpWindow::setBackwardAvailable( bool b)
64{ 66{
65 menuBar()->setItemEnabled( backwardId, b); 67 menuBar()->setItemEnabled( backwardId, b);
66} 68}
67 69
68void HelpWindow::setForwardAvailable( bool b) 70void HelpWindow::setForwardAvailable( bool b)
69{ 71{
70 menuBar()->setItemEnabled( forwardId, b); 72 menuBar()->setItemEnabled( forwardId, b);
71} 73}
72 74
73 75
74void HelpWindow::textChanged() 76void HelpWindow::textChanged()
75{ 77{
76 if ( browser->documentTitle().isNull() ) { 78 if ( browser->documentTitle().isNull() ) {
77 setCaption( "QpeRec - Helpviewer - " + browser->context() ); 79 setCaption( "QpeRec - Helpviewer - " + browser->context() );
78 selectedURL = browser->context(); 80 selectedURL = browser->context();
79 } 81 }
80 else { 82 else {
81 setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ; 83 setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ;
82 selectedURL = browser->documentTitle(); 84 selectedURL = browser->documentTitle();
83 } 85 }
84 86
85// if ( !selectedURL.isEmpty() && pathCombo ) { 87// if ( !selectedURL.isEmpty() && pathCombo ) {
86// bool exists = FALSE; 88// bool exists = FALSE;
87// int i; 89// int i;
88// for ( i = 0; i < pathCombo->count(); ++i ) { 90// for ( i = 0; i < pathCombo->count(); ++i ) {
89// if ( pathCombo->text( i ) == selectedURL ) { 91// if ( pathCombo->text( i ) == selectedURL ) {
90// exists = TRUE; 92// exists = TRUE;
91// break; 93// break;
92// } 94// }
93// } 95// }
94// if ( !exists ) { 96// if ( !exists ) {
95// pathCombo->insertItem( selectedURL, 0 ); 97// pathCombo->insertItem( selectedURL, 0 );
96// pathCombo->setCurrentItem( 0 ); 98// pathCombo->setCurrentItem( 0 );
97// mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; 99// mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
98// } else 100// } else
99// pathCombo->setCurrentItem( i ); 101// pathCombo->setCurrentItem( i );
100// selectedURL = QString::null; 102// selectedURL = QString::null;
101// } 103// }
102} 104}
103 105
104HelpWindow::~HelpWindow() 106HelpWindow::~HelpWindow()
105{ 107{
106 history.clear(); 108 history.clear();
107 QMap<int, QString>::Iterator it = mHistory.begin(); 109 QMap<int, QString>::Iterator it = mHistory.begin();
108 for ( ; it != mHistory.end(); ++it ) 110 for ( ; it != mHistory.end(); ++it )
109 history.append( *it ); 111 history.append( *it );
110 112
111 QFile f( QDir::currentDirPath() + "/.history" ); 113 QFile f( QDir::currentDirPath() + "/.history" );
112 f.open( IO_WriteOnly ); 114 f.open( IO_WriteOnly );
113 QDataStream s( &f ); 115 QDataStream s( &f );
114 s << history; 116 s << history;
115 f.close(); 117 f.close();
116 118
117 bookmarks.clear(); 119 bookmarks.clear();
118 QMap<int, QString>::Iterator it2 = mBookmarks.begin(); 120 QMap<int, QString>::Iterator it2 = mBookmarks.begin();
119 for ( ; it2 != mBookmarks.end(); ++it2 ) 121 for ( ; it2 != mBookmarks.end(); ++it2 )
120 bookmarks.append( *it2 ); 122 bookmarks.append( *it2 );
121 123
122 QFile f2( QDir::currentDirPath() + "/.bookmarks" ); 124 QFile f2( QDir::currentDirPath() + "/.bookmarks" );
123 f2.open( IO_WriteOnly ); 125 f2.open( IO_WriteOnly );
124 QDataStream s2( &f2 ); 126 QDataStream s2( &f2 );
125 s2 << bookmarks; 127 s2 << bookmarks;
126 f2.close(); 128 f2.close();
127} 129}
128 130
129void HelpWindow::openFile() 131void HelpWindow::openFile()
130{ 132{
131#ifndef QT_NO_FILEDIALOG 133#ifndef QT_NO_FILEDIALOG
132#endif 134#endif
133} 135}
134 136
135void HelpWindow::newWindow() 137void HelpWindow::newWindow()
136{ 138{
137 ( new HelpWindow(browser->source(), "qbrowser") )->show(); 139 ( new HelpWindow(browser->source(), "qbrowser") )->show();
138} 140}
139 141
140void HelpWindow::print() 142void HelpWindow::print()
141{ 143{
142#ifndef QT_NO_PRINTER 144#ifndef QT_NO_PRINTER
143#endif 145#endif
144} 146}
145 147
146void HelpWindow::pathSelected( const QString &_path ) 148void HelpWindow::pathSelected( const QString &_path )
147{ 149{
148 browser->setSource( _path ); 150 browser->setSource( _path );
149 QMap<int, QString>::Iterator it = mHistory.begin(); 151 QMap<int, QString>::Iterator it = mHistory.begin();
150 bool exists = FALSE; 152 bool exists = FALSE;
151 for ( ; it != mHistory.end(); ++it ) { 153 for ( ; it != mHistory.end(); ++it ) {
152 if ( *it == _path ) { 154 if ( *it == _path ) {
153 exists = TRUE; 155 exists = TRUE;
154 break; 156 break;
155 } 157 }
156 } 158 }
157 if ( !exists ) 159 if ( !exists )
158 mHistory[ hist->insertItem( _path ) ] = _path; 160 mHistory[ hist->insertItem( _path ) ] = _path;
159} 161}
160 162
161void HelpWindow::readHistory() 163void HelpWindow::readHistory()
162{ 164{
163 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { 165 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
164 QFile f( QDir::currentDirPath() + "/.history" ); 166 QFile f( QDir::currentDirPath() + "/.history" );
165 f.open( IO_ReadOnly ); 167 f.open( IO_ReadOnly );
166 QDataStream s( &f ); 168 QDataStream s( &f );
167 s >> history; 169 s >> history;
168 f.close(); 170 f.close();
169 while ( history.count() > 20 ) 171 while ( history.count() > 20 )
170 history.remove( history.begin() ); 172 history.remove( history.begin() );
171 } 173 }
172} 174}
173 175
174void HelpWindow::readBookmarks() 176void HelpWindow::readBookmarks()
175{ 177{
176 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { 178 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
177 QFile f( QDir::currentDirPath() + "/.bookmarks" ); 179 QFile f( QDir::currentDirPath() + "/.bookmarks" );
178 f.open( IO_ReadOnly ); 180 f.open( IO_ReadOnly );
179 QDataStream s( &f ); 181 QDataStream s( &f );
180 s >> bookmarks; 182 s >> bookmarks;
181 f.close(); 183 f.close();
182 } 184 }
183} 185}
184 186
185void HelpWindow::histChosen( int i ) 187void HelpWindow::histChosen( int i )
186{ 188{
187 if ( mHistory.contains( i ) ) 189 if ( mHistory.contains( i ) )
188 browser->setSource( mHistory[ i ] ); 190 browser->setSource( mHistory[ i ] );
189} 191}
190 192
191void HelpWindow::bookmChosen( int i ) 193void HelpWindow::bookmChosen( int i )
192{ 194{
193 if ( mBookmarks.contains( i ) ) 195 if ( mBookmarks.contains( i ) )
194 browser->setSource( mBookmarks[ i ] ); 196 browser->setSource( mBookmarks[ i ] );
195} 197}
196 198
197void HelpWindow::addBookmark() 199void HelpWindow::addBookmark()
198{ 200{
199 mBookmarks[ bookm->insertItem( caption() ) ] = caption(); 201 mBookmarks[ bookm->insertItem( caption() ) ] = caption();
200} 202}
201 203
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp
index 9d3d5cf..75413be 100644
--- a/noncore/multimedia/opierec/qtrec.cpp
+++ b/noncore/multimedia/opierec/qtrec.cpp
@@ -1,2053 +1,2053 @@
1/**************************************************************************** 1/****************************************************************************
2 // qtrec.cpp 2 // qtrec.cpp
3 Created: Thu Jan 17 11:19:58 2002 3 Created: Thu Jan 17 11:19:58 2002
4 copyright 2002 by L.J. Potter <ljp@llornkcor.com> 4 copyright 2002 by L.J. Potter <ljp@llornkcor.com>
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"
11extern "C" { 11extern "C" {
12#include "adpcm.h" 12#include "adpcm.h"
13} 13}
14 14
15/* OPIE */ 15/* OPIE */
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/oresource.h>
17#include <qpe/config.h> 18#include <qpe/config.h>
18#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
19#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
20#include <qpe/resource.h>
21#include <qpe/storage.h> 21#include <qpe/storage.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24/* QT */ 24/* QT */
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qtimer.h> 37#include <qtimer.h>
38 38
39/* STD */ 39/* STD */
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <math.h> 42#include <math.h>
43#include <mntent.h> 43#include <mntent.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <sys/ioctl.h> 46#include <sys/ioctl.h>
47#include <sys/soundcard.h> 47#include <sys/soundcard.h>
48#include <sys/stat.h> 48#include <sys/stat.h>
49#include <sys/time.h> 49#include <sys/time.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/vfs.h> 51#include <sys/vfs.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <sys/wait.h> 53#include <sys/wait.h>
54#include <sys/signal.h> 54#include <sys/signal.h>
55#include <pthread.h> 55#include <pthread.h>
56 56
57#ifdef PDAUDIO //ALSA 57#ifdef PDAUDIO //ALSA
58#include <alsa/asoundlib.h> 58#include <alsa/asoundlib.h>
59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 59static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
60static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 60static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
61#else //OSS 61#else //OSS
62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 62static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
63static int deviceBitRates[] = { 8, 16, -1 }; 63static int deviceBitRates[] = { 8, 16, -1 };
64#endif 64#endif
65 65
66 66
67//#define ZAURUS 0 67//#define ZAURUS 0
68struct adpcm_state encoder_state; 68struct adpcm_state encoder_state;
69struct adpcm_state decoder_state; 69struct adpcm_state decoder_state;
70 70
71typedef struct { 71typedef struct {
72 int sampleRate; 72 int sampleRate;
73 /* int fragSize; */ 73 /* int fragSize; */
74 /* int blockSize; */ 74 /* int blockSize; */
75 int resolution; //bitrate 75 int resolution; //bitrate
76 int channels; //number of channels 76 int channels; //number of channels
77 int fd; //file descriptor 77 int fd; //file descriptor
78 int sd; //sound device descriptor 78 int sd; //sound device descriptor
79 int numberSamples; //total number of samples 79 int numberSamples; //total number of samples
80 int SecondsToRecord; // number of seconds that should be recorded 80 int SecondsToRecord; // number of seconds that should be recorded
81 float numberOfRecordedSeconds; //total number of samples recorded 81 float numberOfRecordedSeconds; //total number of samples recorded
82 int samplesToRecord; //number of samples to be recorded 82 int samplesToRecord; //number of samples to be recorded
83 int inVol; //input volume 83 int inVol; //input volume
84 int outVol; //output volume 84 int outVol; //output volume
85 int format; //wavfile format PCM.. ADPCM 85 int format; //wavfile format PCM.. ADPCM
86 const char *fileName; //name of fiel to be played/recorded 86 const char *fileName; //name of fiel to be played/recorded
87} fileParameters; 87} fileParameters;
88 88
89fileParameters filePara; 89fileParameters filePara;
90 90
91bool monitoring, recording, playing; 91bool monitoring, recording, playing;
92bool stopped; 92bool stopped;
93QLabel *timeLabel; 93QLabel *timeLabel;
94QSlider *timeSlider; 94QSlider *timeSlider;
95int sd; 95int sd;
96 96
97Waveform* waveform; 97Waveform* waveform;
98Device *soundDevice; 98Device *soundDevice;
99 99
100 100
101#ifdef THREADED 101#ifdef THREADED
102void quickRec() 102void quickRec()
103#else 103#else
104 void QtRec::quickRec() 104 void QtRec::quickRec()
105#endif 105#endif
106{ 106{
107 107
108 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl; 108 odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl;
109 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate 109 odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate
110 << ", channels " << filePara.channels << oendl; 110 << ", channels " << filePara.channels << oendl;
111 111
112 int total = 0; // Total number of bytes read in so far. 112 int total = 0; // Total number of bytes read in so far.
113 int bytesWritten, number; 113 int bytesWritten, number;
114 114
115 bytesWritten = 0; 115 bytesWritten = 0;
116 number = 0; 116 number = 0;
117 QString num; 117 QString num;
118 int level = 0; 118 int level = 0;
119 int threshold = 0; 119 int threshold = 0;
120 int bits = filePara.resolution; 120 int bits = filePara.resolution;
121 odebug << "bits " << bits << "" << oendl; 121 odebug << "bits " << bits << "" << oendl;
122 122
123 if( filePara.resolution == 16 ) { //AFMT_S16_LE) 123 if( filePara.resolution == 16 ) { //AFMT_S16_LE)
124 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; 124 odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl;
125 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; 125 odebug << "samples to record " << filePara.samplesToRecord << "" << oendl;
126 odebug << "" << filePara.sd << "" << oendl; 126 odebug << "" << filePara.sd << "" << oendl;
127 level = 7; 127 level = 7;
128 threshold = 0; 128 threshold = 0;
129 129
130 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 130 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
131 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; 131 odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl;
132// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 132// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
133 char abuf[ BUFSIZE/2 ]; 133 char abuf[ BUFSIZE/2 ];
134 short sbuf[ BUFSIZE ]; 134 short sbuf[ BUFSIZE ];
135 short sbuf2[ BUFSIZE ]; 135 short sbuf2[ BUFSIZE ];
136 memset( abuf, 0, BUFSIZE/2); 136 memset( abuf, 0, BUFSIZE/2);
137 memset( sbuf, 0, BUFSIZE); 137 memset( sbuf, 0, BUFSIZE);
138 memset( sbuf2, 0, BUFSIZE); 138 memset( sbuf2, 0, BUFSIZE);
139 139
140 for(;;) { 140 for(;;) {
141 if ( stopped) { 141 if ( stopped) {
142 odebug << "quickRec:: stopped" << oendl; 142 odebug << "quickRec:: stopped" << oendl;
143 break; 143 break;
144 } 144 }
145 145
146// number=::read( filePara.sd, sbuf, BUFSIZE); 146// number=::read( filePara.sd, sbuf, BUFSIZE);
147 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE); 147 number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE);
148 148
149 if(number <= 0) { 149 if(number <= 0) {
150 perror("recording error "); 150 perror("recording error ");
151 odebug << "" << filePara.fileName << " " << number << "" << oendl; 151 odebug << "" << filePara.fileName << " " << number << "" << oendl;
152 stopped = true; 152 stopped = true;
153 return; 153 return;
154 } 154 }
155 //if(stereo == 2) { 155 //if(stereo == 2) {
156// adpcm_coder( sbuf2, abuf, number/2, &encoder_state); 156// adpcm_coder( sbuf2, abuf, number/2, &encoder_state);
157 adpcm_coder( sbuf, abuf, number/2, &encoder_state); 157 adpcm_coder( sbuf, abuf, number/2, &encoder_state);
158 158
159 bytesWritten = ::write( filePara.fd , abuf, number/4); 159 bytesWritten = ::write( filePara.fd , abuf, number/4);
160 160
161 waveform->newSamples( sbuf, number ); 161 waveform->newSamples( sbuf, number );
162 162
163 total += bytesWritten; 163 total += bytesWritten;
164 filePara.numberSamples = total; 164 filePara.numberSamples = total;
165 timeSlider->setValue( total); 165 timeSlider->setValue( total);
166 166
167 printf("%d, bytes %d,total %d\r", number, bytesWritten, total); 167 printf("%d, bytes %d,total %d\r", number, bytesWritten, total);
168 fflush(stdout); 168 fflush(stdout);
169 169
170 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;/// filePara.channels; 170 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2;/// filePara.channels;
171 171
172 qApp->processEvents(); 172 qApp->processEvents();
173 if( total >= filePara.samplesToRecord) { 173 if( total >= filePara.samplesToRecord) {
174 stopped = true; 174 stopped = true;
175 break; 175 break;
176 } 176 }
177 } 177 }
178 } else { 178 } else {
179 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 179 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
180 odebug << "start recording WAVE_FORMAT_PCM" << oendl; 180 odebug << "start recording WAVE_FORMAT_PCM" << oendl;
181 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 181 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
182 memset( inbuffer, 0, BUFSIZE); 182 memset( inbuffer, 0, BUFSIZE);
183 memset( outbuffer, 0, BUFSIZE); 183 memset( outbuffer, 0, BUFSIZE);
184 184
185 for(;;) { 185 for(;;) {
186 if ( stopped) { 186 if ( stopped) {
187 odebug << "quickRec:: stopped" << oendl; 187 odebug << "quickRec:: stopped" << oendl;
188 stopped = true; 188 stopped = true;
189 break; // stop if playing was set to false 189 break; // stop if playing was set to false
190 return; 190 return;
191 } 191 }
192 192
193 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE); 193 number = soundDevice->devRead( soundDevice->sd /*filePara.sd*/, (short *)inbuffer, BUFSIZE);
194 194
195 if( number <= 0) { 195 if( number <= 0) {
196 perror( "recording error "); 196 perror( "recording error ");
197 odebug << filePara.fileName << oendl; 197 odebug << filePara.fileName << oendl;
198 stopped = true; 198 stopped = true;
199 return; 199 return;
200 } 200 }
201 201
202 bytesWritten = ::write( filePara.fd , inbuffer, number); 202 bytesWritten = ::write( filePara.fd , inbuffer, number);
203 waveform->newSamples( inbuffer, number ); 203 waveform->newSamples( inbuffer, number );
204 204
205 if( bytesWritten < 0) { 205 if( bytesWritten < 0) {
206 perror("File writing error "); 206 perror("File writing error ");
207 stopped = true; 207 stopped = true;
208 return; 208 return;
209 } 209 }
210 210
211 total += bytesWritten; 211 total += bytesWritten;
212 212
213 filePara.numberSamples = total; 213 filePara.numberSamples = total;
214 214
215 if( filePara.SecondsToRecord != 0) 215 if( filePara.SecondsToRecord != 0)
216 timeSlider->setValue( total); 216 timeSlider->setValue( total);
217 printf("%d, bytes %d,total %d\r",number, bytesWritten , total); 217 printf("%d, bytes %d,total %d\r",number, bytesWritten , total);
218 fflush(stdout); 218 fflush(stdout);
219 219
220 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate 220 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate
221 / (float)2/filePara.channels; 221 / (float)2/filePara.channels;
222 qApp->processEvents(); 222 qApp->processEvents();
223 223
224 if( total >= filePara.samplesToRecord) { 224 if( total >= filePara.samplesToRecord) {
225 stopped = true; 225 stopped = true;
226 break; 226 break;
227 } 227 }
228 } 228 }
229 } //end main loop 229 } //end main loop
230 230
231 } else { 231 } else {
232// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; 232// <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8;
233 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; 233 unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ];
234 memset( unsigned_inbuffer, 0, BUFSIZE); 234 memset( unsigned_inbuffer, 0, BUFSIZE);
235 memset( unsigned_outbuffer, 0, BUFSIZE); 235 memset( unsigned_outbuffer, 0, BUFSIZE);
236 236
237 for(;;) { 237 for(;;) {
238 if ( stopped) { 238 if ( stopped) {
239 odebug << "quickRec:: stopped" << oendl; 239 odebug << "quickRec:: stopped" << oendl;
240 break; // stop if playing was set to false 240 break; // stop if playing was set to false
241 } 241 }
242 242
243 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE); 243 number = ::read( soundDevice->sd /*filePara.sd*/ , unsigned_inbuffer, BUFSIZE);
244 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); 244 bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number);
245 waveform->newSamples( (const short *) unsigned_inbuffer, number ); 245 waveform->newSamples( (const short *) unsigned_inbuffer, number );
246 246
247 if(bytesWritten < 0) { 247 if(bytesWritten < 0) {
248 stopped = true; 248 stopped = true;
249 QMessageBox::message("Note","<p>There was a problem writing to the file</p>"); 249 QMessageBox::message("Note","<p>There was a problem writing to the file</p>");
250 perror("File writing error "); 250 perror("File writing error ");
251 return; 251 return;
252 } 252 }
253 253
254 total += bytesWritten; 254 total += bytesWritten;
255 filePara.numberSamples = total; 255 filePara.numberSamples = total;
256 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total); 256 // printf("%d, bytes %d,total %d \r",number, bytesWritten , total);
257 // fflush(stdout); 257 // fflush(stdout);
258 if( filePara.SecondsToRecord !=0) 258 if( filePara.SecondsToRecord !=0)
259 timeSlider->setValue( total); 259 timeSlider->setValue( total);
260 260
261 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 261 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
262 262
263 qApp->processEvents(); 263 qApp->processEvents();
264 if( total >= filePara.samplesToRecord) { 264 if( total >= filePara.samplesToRecord) {
265 stopped = true; 265 stopped = true;
266 break; 266 break;
267 } 267 }
268 } //end main loop 268 } //end main loop
269 } 269 }
270 printf("\n"); 270 printf("\n");
271} /// END quickRec() 271} /// END quickRec()
272 272
273 273
274#ifdef THREADED 274#ifdef THREADED
275void playIt() 275void playIt()
276#else 276#else
277 void QtRec::playIt() 277 void QtRec::playIt()
278#endif 278#endif
279{ 279{
280 int bytesWritten = 0; 280 int bytesWritten = 0;
281 int number = 0; 281 int number = 0;
282 int total = 0; // Total number of bytes read in so far. 282 int total = 0; // Total number of bytes read in so far.
283 if( filePara.resolution == 16 ) { //AFMT_S16_LE) { 283 if( filePara.resolution == 16 ) { //AFMT_S16_LE) {
284 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { 284 if( filePara.format == WAVE_FORMAT_DVI_ADPCM) {
285 char abuf[ BUFSIZE / 2 ]; 285 char abuf[ BUFSIZE / 2 ];
286 short sbuf[ BUFSIZE ]; 286 short sbuf[ BUFSIZE ];
287 short sbuf2[ BUFSIZE * 2 ]; 287 short sbuf2[ BUFSIZE * 2 ];
288 memset( abuf, 0, BUFSIZE / 2); 288 memset( abuf, 0, BUFSIZE / 2);
289 memset( sbuf, 0, BUFSIZE); 289 memset( sbuf, 0, BUFSIZE);
290 memset( sbuf2, 0, BUFSIZE * 2); 290 memset( sbuf2, 0, BUFSIZE * 2);
291// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> 291// <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>>
292 for(;;) { // play loop 292 for(;;) { // play loop
293 if ( stopped) { 293 if ( stopped) {
294 break; 294 break;
295 return; 295 return;
296 }// stop if playing was set to false 296 }// stop if playing was set to false
297 297
298 number = ::read( filePara.fd, abuf, BUFSIZE / 2); 298 number = ::read( filePara.fd, abuf, BUFSIZE / 2);
299 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); 299 adpcm_decoder( abuf, sbuf, number * 2, &decoder_state);
300 300
301// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 301// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
302// sbuf2[i+1]=sbuf2[i]=sbuf[i]; 302// sbuf2[i+1]=sbuf2[i]=sbuf[i];
303// } 303// }
304 bytesWritten = write ( soundDevice->sd , sbuf, number * 4); 304 bytesWritten = write ( soundDevice->sd , sbuf, number * 4);
305 305
306 waveform->newSamples( sbuf, number ); 306 waveform->newSamples( sbuf, number );
307 307
308 // if(filePara.channels==1) 308 // if(filePara.channels==1)
309 // total += bytesWritten/2; //mono 309 // total += bytesWritten/2; //mono
310 // else 310 // else
311 total += bytesWritten; 311 total += bytesWritten;
312 filePara.numberSamples = total/4; 312 filePara.numberSamples = total/4;
313 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; 313 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2;
314 314
315 timeSlider->setValue( total/4); 315 timeSlider->setValue( total/4);
316// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 316// timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
317// if(filePara.numberOfRecordedSeconds>1) 317// if(filePara.numberOfRecordedSeconds>1)
318// timeLabel->setText( timeString+ tr(" seconds")); 318// timeLabel->setText( timeString+ tr(" seconds"));
319// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); 319// printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4);
320// fflush(stdout); 320// fflush(stdout);
321 321
322 qApp->processEvents(); 322 qApp->processEvents();
323 323
324 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 324 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
325// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { 325// if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) {
326 stopped = true; 326 stopped = true;
327 break; 327 break;
328 } 328 }
329 } 329 }
330 } else { 330 } else {
331 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> 331 // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>>
332 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; 332 short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ];
333 memset( inbuffer, 0, BUFSIZE); 333 memset( inbuffer, 0, BUFSIZE);
334 memset( outbuffer, 0, BUFSIZE); 334 memset( outbuffer, 0, BUFSIZE);
335 335
336 for(;;) { // play loop 336 for(;;) { // play loop
337 if ( stopped) { 337 if ( stopped) {
338 break; 338 break;
339 return; 339 return;
340 } 340 }
341// stop if playing was set to false 341// stop if playing was set to false
342 number = ::read( filePara.fd, inbuffer, BUFSIZE); 342 number = ::read( filePara.fd, inbuffer, BUFSIZE);
343// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel 343// for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel
344// // for (int i=0;i< number ; i++) { //2*i is left channel 344// // for (int i=0;i< number ; i++) { //2*i is left channel
345// outbuffer[i+1]= outbuffer[i]=inbuffer[i]; 345// outbuffer[i+1]= outbuffer[i]=inbuffer[i];
346// } 346// }
347 bytesWritten = ::write( soundDevice->sd, inbuffer, number); 347 bytesWritten = ::write( soundDevice->sd, inbuffer, number);
348 waveform->newSamples( inbuffer, number); 348 waveform->newSamples( inbuffer, number);
349 //-------------->>>> out to device 349 //-------------->>>> out to device
350 // total+=bytesWritten; 350 // total+=bytesWritten;
351 // if(filePara.channels==1) 351 // if(filePara.channels==1)
352 // total += bytesWritten/2; //mono 352 // total += bytesWritten/2; //mono
353 // else 353 // else
354 total += bytesWritten; 354 total += bytesWritten;
355 timeSlider->setValue( total); 355 timeSlider->setValue( total);
356 356
357 filePara.numberSamples = total; 357 filePara.numberSamples = total;
358 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; 358 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2;
359 359
360// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 360// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
361// timeLabel->setText( timeString + tr(" seconds")); 361// timeLabel->setText( timeString + tr(" seconds"));
362 362
363 qApp->processEvents(); 363 qApp->processEvents();
364 364
365 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 365 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
366 owarn << "Jane! Stop this crazy thing!" << oendl; 366 owarn << "Jane! Stop this crazy thing!" << oendl;
367 stopped = true; 367 stopped = true;
368// playing = false; 368// playing = false;
369 break; 369 break;
370 } 370 }
371 } 371 }
372// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); 372// printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total);
373// fflush(stdout); 373// fflush(stdout);
374 } //end loop 374 } //end loop
375 } else { 375 } else {
376/////////////////////////////// format = AFMT_U8; 376/////////////////////////////// format = AFMT_U8;
377 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; 377 unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE];
378 memset( unsigned_inbuffer, 0, BUFSIZE); 378 memset( unsigned_inbuffer, 0, BUFSIZE);
379 for(;;) { 379 for(;;) {
380// main loop 380// main loop
381 if (stopped) { 381 if (stopped) {
382 break; // stop if playing was set to false 382 break; // stop if playing was set to false
383 return; 383 return;
384 } 384 }
385 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); 385 number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE);
386//data = (val >> 8) ^ 0x80; 386//data = (val >> 8) ^ 0x80;
387 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; 387 // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80;
388 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); 388 bytesWritten = write ( filePara.sd, unsigned_inbuffer, number);
389 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); 389 waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten );
390 total += bytesWritten; 390 total += bytesWritten;
391 391
392 timeSlider->setValue( total); 392 timeSlider->setValue( total);
393 filePara.numberSamples = total; 393 filePara.numberSamples = total;
394 394
395 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; 395 filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate;
396// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); 396// timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds);
397// timeLabel->setText( timeString + tr(" seconds")); 397// timeLabel->setText( timeString + tr(" seconds"));
398 qApp->processEvents(); 398 qApp->processEvents();
399 399
400 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { 400 if( /*total >= filePara.numberSamples || */ bytesWritten == 0) {
401// if( total >= filePara.numberSamples ) { 401// if( total >= filePara.numberSamples ) {
402 stopped = true; 402 stopped = true;
403 break; 403 break;
404 } 404 }
405// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); 405// printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples);
406// fflush(stdout); 406// fflush(stdout);
407 } 407 }
408 } 408 }
409} 409}
410 410
411 411
412QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 412QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
413 : QWidget( parent, name, fl ) 413 : QWidget( parent, name, fl )
414{ 414{
415 if ( !name ) 415 if ( !name )
416 setName( "OpieRec" ); 416 setName( "OpieRec" );
417 init(); 417 init();
418 initConfig(); 418 initConfig();
419 initConnections(); 419 initConnections();
420 renameBox = 0; 420 renameBox = 0;
421 421
422// open sound device to get volumes 422// open sound device to get volumes
423 Config hwcfg("OpieRec"); 423 Config hwcfg("OpieRec");
424 hwcfg.setGroup("Hardware"); 424 hwcfg.setGroup("Hardware");
425 425
426 426
427 soundDevice = new Device( this, false); //open play 427 soundDevice = new Device( this, false); //open play
428 428
429 getInVol(); 429 getInVol();
430 getOutVol(); 430 getOutVol();
431 431
432 soundDevice->closeDevice( true); 432 soundDevice->closeDevice( true);
433 soundDevice->sd = -1; 433 soundDevice->sd = -1;
434 soundDevice = 0; 434 soundDevice = 0;
435 wavFile = 0; 435 wavFile = 0;
436// if( soundDevice) delete soundDevice; 436// if( soundDevice) delete soundDevice;
437 QTimer::singleShot(100,this, SLOT(initIconView())); 437 QTimer::singleShot(100,this, SLOT(initIconView()));
438 438
439 if( autoMute) 439 if( autoMute)
440 doMute( true); 440 doMute( true);
441 // ListView1->setFocus(); 441 // ListView1->setFocus();
442 playing = false; 442 playing = false;
443} 443}
444 444
445QtRec::~QtRec() { 445QtRec::~QtRec() {
446// if( soundDevice) delete soundDevice; 446// if( soundDevice) delete soundDevice;
447 447
448} 448}
449 449
450void QtRec::cleanUp() { 450void QtRec::cleanUp() {
451 451
452 if( !stopped) { 452 if( !stopped) {
453 stopped = true; 453 stopped = true;
454 endRecording(); 454 endRecording();
455 } 455 }
456 456
457 ListView1->clear(); 457 ListView1->clear();
458 458
459 if( autoMute) 459 if( autoMute)
460 doMute(false); 460 doMute(false);
461 461
462// if( wavFile) delete wavFile; 462// if( wavFile) delete wavFile;
463// if(soundDevice) delete soundDevice; 463// if(soundDevice) delete soundDevice;
464} 464}
465 465
466void QtRec::init() { 466void QtRec::init() {
467 467
468 needsStereoOut = false; 468 needsStereoOut = false;
469 QPixmap image3( ( const char** ) image3_data ); 469 QPixmap image3( ( const char** ) image3_data );
470 QPixmap image4( ( const char** ) image4_data ); 470 QPixmap image4( ( const char** ) image4_data );
471 QPixmap image6( ( const char** ) image6_data ); 471 QPixmap image6( ( const char** ) image6_data );
472 472
473 stopped = true; 473 stopped = true;
474 setCaption( tr( "OpieRecord " )); 474 setCaption( tr( "OpieRecord " ));
475 QGridLayout *layout = new QGridLayout( this ); 475 QGridLayout *layout = new QGridLayout( this );
476 layout->setSpacing( 2); 476 layout->setSpacing( 2);
477 layout->setMargin( 2); 477 layout->setMargin( 2);
478 478
479 TabWidget = new QTabWidget( this, "TabWidget" ); 479 TabWidget = new QTabWidget( this, "TabWidget" );
480 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8); 480 layout->addMultiCellWidget(TabWidget, 0, 7, 0, 8);
481// TabWidget->setTabShape(QTabWidget::Triangular); 481// TabWidget->setTabShape(QTabWidget::Triangular);
482 482
483 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 483 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
484 tab = new QWidget( TabWidget, "tab" ); 484 tab = new QWidget( TabWidget, "tab" );
485 485
486 QGridLayout *layout1 = new QGridLayout( tab); 486 QGridLayout *layout1 = new QGridLayout( tab);
487 layout1->setSpacing( 2); 487 layout1->setSpacing( 2);
488 layout1->setMargin( 2); 488 layout1->setMargin( 2);
489 489
490 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); 490 timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" );
491 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); 491 layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3);
492 492
493 // timeLabel = new QLabel( tab, "TimeLabel" ); 493 // timeLabel = new QLabel( tab, "TimeLabel" );
494 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); 494 // layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3);
495 495
496 // playLabel2 = new QLabel(tab, "PlayLabel2" ); 496 // playLabel2 = new QLabel(tab, "PlayLabel2" );
497 // playLabel2->setText(tr("Play") ); 497 // playLabel2->setText(tr("Play") );
498 // playLabel2->setFixedHeight( 18); 498 // playLabel2->setFixedHeight( 18);
499 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); 499 // layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4);
500 500
501 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); 501 Stop_PushButton = new QPushButton( tab, "Stop_PushButton" );
502 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); 502 layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4);
503 Stop_PushButton->setFixedSize( 22, 22); 503 Stop_PushButton->setFixedSize( 22, 22);
504 Stop_PushButton->setPixmap( image4 ); 504 Stop_PushButton->setPixmap( image4 );
505 505
506 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); 506 toBeginningButton = new QPushButton( tab, "Beginning_PushButton" );
507 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); 507 layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5);
508 toBeginningButton->setFixedSize( 22, 22); 508 toBeginningButton->setFixedSize( 22, 22);
509 toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); 509 toBeginningButton->setPixmap( Opie::Core::OResource::loadPixmap("fastback", Opie::Core::OResource::SmallIcon) );
510 510
511 toEndButton = new QPushButton( tab, "End_PushButton" ); 511 toEndButton = new QPushButton( tab, "End_PushButton" );
512 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); 512 layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6);
513 toEndButton->setFixedSize( 22, 22); 513 toEndButton->setFixedSize( 22, 22);
514 toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); 514 toEndButton->setPixmap( Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ) );
515 515
516 // QLabel *recLabel2; 516 // QLabel *recLabel2;
517 // recLabel2 = new QLabel( tab, "recLabel2" ); 517 // recLabel2 = new QLabel( tab, "recLabel2" );
518 // recLabel2->setText(tr("Rec")); 518 // recLabel2->setText(tr("Rec"));
519 // recLabel2->setFixedHeight( 18); 519 // recLabel2->setFixedHeight( 18);
520 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); 520 // layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7);
521 521
522 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); 522 Rec_PushButton = new QPushButton( tab, "Rec_PushButton" );
523 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); 523 layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7);
524 Rec_PushButton->setFixedSize( 22, 22); 524 Rec_PushButton->setFixedSize( 22, 22);
525 Rec_PushButton->setPixmap( image6 ); 525 Rec_PushButton->setPixmap( image6 );
526 526
527 t = new QTimer( this ); 527 t = new QTimer( this );
528 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 528 connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) );
529 529
530 rewindTimer = new QTimer( this ); 530 rewindTimer = new QTimer( this );
531 connect( rewindTimer, SIGNAL( timeout() ), 531 connect( rewindTimer, SIGNAL( timeout() ),
532 this, SLOT( rewindTimerTimeout() ) ); 532 this, SLOT( rewindTimerTimeout() ) );
533 533
534 forwardTimer = new QTimer( this ); 534 forwardTimer = new QTimer( this );
535 connect( forwardTimer, SIGNAL( timeout() ), 535 connect( forwardTimer, SIGNAL( timeout() ),
536 this, SLOT( forwardTimerTimeout() ) ); 536 this, SLOT( forwardTimerTimeout() ) );
537 537
538 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); 538 deleteSoundButton = new QPushButton( tab, "deleteSoundButton" );
539 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); 539 layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8);
540 deleteSoundButton->setText( tr( "Del" ) ); 540 deleteSoundButton->setText( tr( "Del" ) );
541 541
542 ListView1 = new QListView( tab, "IconView1" ); 542 ListView1 = new QListView( tab, "IconView1" );
543 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); 543 layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8);
544 544
545 ListView1->addColumn( tr( "Name" ) ); 545 ListView1->addColumn( tr( "Name" ) );
546 ListView1->setSorting( 1, false); 546 ListView1->setSorting( 1, false);
547 ListView1->addColumn( tr( "Time" ) ); //in seconds 547 ListView1->addColumn( tr( "Time" ) ); //in seconds
548 ListView1->setColumnWidthMode(0, QListView::Maximum); 548 ListView1->setColumnWidthMode(0, QListView::Maximum);
549 ListView1->setColumnAlignment( 1, QListView::AlignCenter); 549 ListView1->setColumnAlignment( 1, QListView::AlignCenter);
550 ListView1->setAllColumnsShowFocus( true ); 550 ListView1->setAllColumnsShowFocus( true );
551 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); 551 QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold);
552 552
553 TabWidget->insertTab( tab, tr( "Files" ) ); 553 TabWidget->insertTab( tab, tr( "Files" ) );
554 554
555 ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** 555 ///**********<<<<<<<<<<<<>>>>>>>>>>>>***************
556 tab_3 = new QWidget( TabWidget, "tab_3" ); 556 tab_3 = new QWidget( TabWidget, "tab_3" );
557 QGridLayout *glayout3 = new QGridLayout( tab_3 ); 557 QGridLayout *glayout3 = new QGridLayout( tab_3 );
558 glayout3->setSpacing( 2); 558 glayout3->setSpacing( 2);
559 glayout3->setMargin( 2); 559 glayout3->setMargin( 2);
560 //////////////////////////////////// 560 ////////////////////////////////////
561 sampleGroup = new QGroupBox( tab_3, "samplegroup" ); 561 sampleGroup = new QGroupBox( tab_3, "samplegroup" );
562 sampleGroup->setTitle( tr( "Sample Rate" ) ); 562 sampleGroup->setTitle( tr( "Sample Rate" ) );
563 sampleGroup->setFixedSize( 95,50); 563 sampleGroup->setFixedSize( 95,50);
564 564
565 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); 565 sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" );
566 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); 566 sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) );
567 QString s; 567 QString s;
568 int z = 0; 568 int z = 0;
569 while( deviceSampleRates[z] != -1) { 569 while( deviceSampleRates[z] != -1) {
570 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); 570 sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10));
571 z++; 571 z++;
572 } 572 }
573 573
574 574
575 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); 575 glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0);
576 576
577 sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); 577 sizeGroup= new QGroupBox( tab_3, "sizeGroup" );
578 sizeGroup->setTitle( tr( "Limit Size" ) ); 578 sizeGroup->setTitle( tr( "Limit Size" ) );
579 sizeGroup->setFixedSize( 80, 50); 579 sizeGroup->setFixedSize( 80, 50);
580 580
581 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); 581 sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" );
582 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); 582 sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) );
583 sizeLimitCombo->insertItem(tr("Unlimited")); 583 sizeLimitCombo->insertItem(tr("Unlimited"));
584 584
585 for(int i=1;i<13; i++) { 585 for(int i=1;i<13; i++) {
586 sizeLimitCombo->insertItem( QString::number( i * 5)); 586 sizeLimitCombo->insertItem( QString::number( i * 5));
587 } 587 }
588 588
589 589
590 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); 590 glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1);
591 dirGroup = new QGroupBox( tab_3, "dirGroup" ); 591 dirGroup = new QGroupBox( tab_3, "dirGroup" );
592 dirGroup->setTitle( tr( "File Directory" ) ); 592 dirGroup->setTitle( tr( "File Directory" ) );
593 dirGroup->setFixedSize( 130, 50); 593 dirGroup->setFixedSize( 130, 50);
594 594
595 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); 595 directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" );
596 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); 596 directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) );
597 597
598 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); 598 glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0);
599 599
600 bitGroup = new QGroupBox( tab_3, "bitGroup" ); 600 bitGroup = new QGroupBox( tab_3, "bitGroup" );
601 bitGroup->setTitle( tr( "Bit Depth" ) ); 601 bitGroup->setTitle( tr( "Bit Depth" ) );
602 bitGroup->setFixedSize( 65, 50); 602 bitGroup->setFixedSize( 65, 50);
603 603
604 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); 604 bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" );
605 605
606 z = 0; 606 z = 0;
607 while( deviceBitRates[z] != -1) { 607 while( deviceBitRates[z] != -1) {
608 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); 608 bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) );
609 z++; 609 z++;
610 } 610 }
611 611
612 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); 612 bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) );
613 613
614 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); 614 glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1);
615 615
616 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); 616 compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 );
617 617
618 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); 618 autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 );
619 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 ); 619 stereoCheckBox = new QCheckBox ( tr("Stereo"), tab_3 );
620 620
621 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); 621 glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3);
622 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); 622 glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0);
623 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); 623 glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1);
624 624
625 tab_5 = new QWidget( TabWidget, "tab_5" ); 625 tab_5 = new QWidget( TabWidget, "tab_5" );
626 626
627 QHBoxLayout *Layout19a; 627 QHBoxLayout *Layout19a;
628 Layout19a = new QHBoxLayout( tab_5); 628 Layout19a = new QHBoxLayout( tab_5);
629 Layout19a->setSpacing( 2 ); 629 Layout19a->setSpacing( 2 );
630 Layout19a->setMargin( 0 ); 630 Layout19a->setMargin( 0 );
631 631
632 Layout15 = new QVBoxLayout( this); 632 Layout15 = new QVBoxLayout( this);
633 Layout15->setSpacing( 2 ); 633 Layout15->setSpacing( 2 );
634 Layout15->setMargin( 0 ); 634 Layout15->setMargin( 0 );
635 635
636 Layout15b = new QVBoxLayout( this); 636 Layout15b = new QVBoxLayout( this);
637 Layout15b->setSpacing( 2 ); 637 Layout15b->setSpacing( 2 );
638 Layout15b->setMargin( 0 ); 638 Layout15b->setMargin( 0 );
639 639
640 TextLabel2 = new QLabel( tab_5, "InputLabel" ); 640 TextLabel2 = new QLabel( tab_5, "InputLabel" );
641 TextLabel2->setText( tr( "In")); 641 TextLabel2->setText( tr( "In"));
642 TextLabel2->setFixedWidth( 35); 642 TextLabel2->setFixedWidth( 35);
643 Layout15->addWidget( TextLabel2 ); 643 Layout15->addWidget( TextLabel2 );
644 644
645 TextLabel3 = new QLabel( tab_5, "OutputLabel" ); 645 TextLabel3 = new QLabel( tab_5, "OutputLabel" );
646 TextLabel3->setText( tr( "Out" ) ); 646 TextLabel3->setText( tr( "Out" ) );
647 Layout15b->addWidget( TextLabel3 ); 647 Layout15b->addWidget( TextLabel3 );
648 648
649 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); 649 InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" );
650 InputSlider->setTickmarks( QSlider::Both); 650 InputSlider->setTickmarks( QSlider::Both);
651 Layout15->addWidget( InputSlider); 651 Layout15->addWidget( InputSlider);
652 652
653 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); 653 OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" );
654 OutputSlider->setTickmarks( QSlider::Both); 654 OutputSlider->setTickmarks( QSlider::Both);
655 655
656 Layout15b->addWidget( OutputSlider ); 656 Layout15b->addWidget( OutputSlider );
657 657
658 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 658 outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
659 Layout15->addWidget( outMuteCheckBox ); 659 Layout15->addWidget( outMuteCheckBox );
660 660
661 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); 661 inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 );
662 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); 662 inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus );
663 Layout15b->addWidget( inMuteCheckBox ); 663 Layout15b->addWidget( inMuteCheckBox );
664 664
665 665
666 Layout19a->addLayout( Layout15 ); 666 Layout19a->addLayout( Layout15 );
667 Layout19a->addLayout( Layout15b ); 667 Layout19a->addLayout( Layout15b );
668 668
669 fillDirectoryCombo(); 669 fillDirectoryCombo();
670 670
671 TabWidget->insertTab( tab_3, tr( "Options" ) ); 671 TabWidget->insertTab( tab_3, tr( "Options" ) );
672 672
673 TabWidget->insertTab( tab_5, tr( "Volume" ) ); 673 TabWidget->insertTab( tab_5, tr( "Volume" ) );
674 674
675 waveform = new Waveform( this, "waveform" ); 675 waveform = new Waveform( this, "waveform" );
676 waveform->setMinimumSize( QSize( 0, 50 ) ); 676 waveform->setMinimumSize( QSize( 0, 50 ) );
677 677
678 layout->addMultiCellWidget( waveform, 8, 8, 0, 8); 678 layout->addMultiCellWidget( waveform, 8, 8, 0, 8);
679 waveform->setBackgroundColor ( black ); 679 waveform->setBackgroundColor ( black );
680} 680}
681 681
682void QtRec::initIconView() { 682void QtRec::initIconView() {
683 ListView1->clear(); 683 ListView1->clear();
684 Config cfg("OpieRec"); 684 Config cfg("OpieRec");
685 cfg.setGroup("Sounds"); 685 cfg.setGroup("Sounds");
686 QString temp; 686 QString temp;
687 QPixmap image0( ( const char** ) image0_data ); 687 QPixmap image0( ( const char** ) image0_data );
688 688
689 int nFiles = cfg.readNumEntry("NumberofFiles",0); 689 int nFiles = cfg.readNumEntry("NumberofFiles",0);
690// owarn << "init number of files " << nFiles << "" << oendl; 690// owarn << "init number of files " << nFiles << "" << oendl;
691 691
692 for(int i = 1; i <= nFiles; i++) { 692 for(int i = 1; i <= nFiles; i++) {
693 693
694 QListViewItem * item; 694 QListViewItem * item;
695 QString fileS, mediaLocation, fileDate, filePath; 695 QString fileS, mediaLocation, fileDate, filePath;
696 696
697 temp.sprintf( "%d",i); 697 temp.sprintf( "%d",i);
698 temp = cfg.readEntry( temp,""); //reads currentFile 698 temp = cfg.readEntry( temp,""); //reads currentFile
699 filePath = cfg.readEntry( temp,""); //currentFileName 699 filePath = cfg.readEntry( temp,""); //currentFileName
700 700
701 QFileInfo info(filePath); 701 QFileInfo info(filePath);
702 fileDate = info.lastModified().toString(); 702 fileDate = info.lastModified().toString();
703 703
704 fileS = cfg.readEntry( filePath, "0" );// file length in seconds 704 fileS = cfg.readEntry( filePath, "0" );// file length in seconds
705 mediaLocation = getStorage( filePath); 705 mediaLocation = getStorage( filePath);
706 if( info.exists()) { 706 if( info.exists()) {
707 // owarn << "new item " << temp << oendl; 707 // owarn << "new item " << temp << oendl;
708 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); 708 item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/);
709 item->setPixmap( 0, image0); 709 item->setPixmap( 0, image0);
710 if( currentFileName == filePath) 710 if( currentFileName == filePath)
711 ListView1->setSelected( item, true); 711 ListView1->setSelected( item, true);
712 } 712 }
713 } 713 }
714} 714}
715 715
716void QtRec::initConnections() { 716void QtRec::initConnections() {
717 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp())); 717 connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp()));
718 718
719 connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed())); 719 connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed()));
720 connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased())); 720 connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased()));
721 connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed())); 721 connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed()));
722 connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased())); 722 connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased()));
723 723
724 connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound())); 724 connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound()));
725 725
726 connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); 726 connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn()));
727 // connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); 727 // connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn()));
728 728
729 // connect(Rec_PushButton,SIGNAL(released()),this,SIGNAL(startRecording())); 729 // connect(Rec_PushButton,SIGNAL(released()),this,SIGNAL(startRecording()));
730 connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound())); 730 connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound()));
731 731
732 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*))); 732 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*)));
733 733
734 connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume())); 734 connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume()));
735 connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume())); 735 connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume()));
736 736
737 connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int))); 737 connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int)));
738 connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int))); 738 connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int)));
739 connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int))); 739 connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int)));
740 connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int))); 740 connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int)));
741 741
742 connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool))); 742 connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool)));
743 connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool))); 743 connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool)));
744 connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool))); 744 connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool)));
745 745
746 connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*))); 746 connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*)));
747 connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int))); 747 connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int)));
748 748
749 connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int))); 749 connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int)));
750 connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed())); 750 connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed()));
751 connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased())); 751 connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased()));
752 752
753 connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool))); 753 connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool)));
754 connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool))); 754 connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool)));
755} 755}
756 756
757void QtRec::initConfig() { 757void QtRec::initConfig() {
758 int index, fred, i; 758 int index, fred, i;
759 Config cfg("OpieRec"); 759 Config cfg("OpieRec");
760 cfg.setGroup("Settings"); 760 cfg.setGroup("Settings");
761 761
762 index = cfg.readNumEntry("samplerate",22050); 762 index = cfg.readNumEntry("samplerate",22050);
763 bool ok; 763 bool ok;
764 764
765 for(int ws=0;ws<sampleRateComboBox->count();ws++) { 765 for(int ws=0;ws<sampleRateComboBox->count();ws++) {
766 fred = sampleRateComboBox->text(ws).toInt(&ok, 10); 766 fred = sampleRateComboBox->text(ws).toInt(&ok, 10);
767 if( index == fred) { 767 if( index == fred) {
768 filePara.sampleRate = fred; 768 filePara.sampleRate = fred;
769 sampleRateComboBox->setCurrentItem(ws); 769 sampleRateComboBox->setCurrentItem(ws);
770 } 770 }
771 } 771 }
772 772
773 i = cfg.readNumEntry("bitrate",16); 773 i = cfg.readNumEntry("bitrate",16);
774 if(i == 16) 774 if(i == 16)
775 bitRateComboBox->setCurrentItem( 1); 775 bitRateComboBox->setCurrentItem( 1);
776 else if(i == 24) 776 else if(i == 24)
777 bitRateComboBox->setCurrentItem( 2); 777 bitRateComboBox->setCurrentItem( 2);
778 else if(i == 32) 778 else if(i == 32)
779 bitRateComboBox->setCurrentItem( 3); 779 bitRateComboBox->setCurrentItem( 3);
780 else 780 else
781 bitRateComboBox->setCurrentItem( 0); 781 bitRateComboBox->setCurrentItem( 0);
782 782
783 filePara.resolution = i; 783 filePara.resolution = i;
784 784
785 i = cfg.readNumEntry("sizeLimit", 5 ); 785 i = cfg.readNumEntry("sizeLimit", 5 );
786 QString temp; 786 QString temp;
787 sizeLimitCombo->setCurrentItem((i/5)); 787 sizeLimitCombo->setCurrentItem((i/5));
788 788
789 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); 789 stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1));
790 if( stereoCheckBox->isChecked()) { 790 if( stereoCheckBox->isChecked()) {
791 filePara.channels = 2; 791 filePara.channels = 2;
792 } else { 792 } else {
793 filePara.channels = 1; 793 filePara.channels = 1;
794 } 794 }
795 795
796 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); 796 compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1));
797 if( compressionCheckBox->isChecked()) { 797 if( compressionCheckBox->isChecked()) {
798 bitRateComboBox->setCurrentItem(1); 798 bitRateComboBox->setCurrentItem(1);
799 bitRateComboBox->setEnabled(false); 799 bitRateComboBox->setEnabled(false);
800 filePara.resolution=16; 800 filePara.resolution=16;
801 } 801 }
802 802
803 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); 803 autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0));
804 if( autoMuteCheckBox->isChecked()) 804 if( autoMuteCheckBox->isChecked())
805 slotAutoMute(true); 805 slotAutoMute(true);
806 else 806 else
807 slotAutoMute(false); 807 slotAutoMute(false);
808 808
809 Config cofg( "qpe"); 809 Config cofg( "qpe");
810 cofg.setGroup( "Volume"); 810 cofg.setGroup( "Volume");
811 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); 811 outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0));
812 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); 812 inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0));
813} 813}
814 814
815void QtRec::stop() { 815void QtRec::stop() {
816 // owarn << "STOP" << oendl; 816 // owarn << "STOP" << oendl;
817 setRecordButton(false); 817 setRecordButton(false);
818 818
819 if( !recording) { 819 if( !recording) {
820 emit stopPlaying(); 820 emit stopPlaying();
821 endPlaying(); 821 endPlaying();
822 } else { 822 } else {
823 emit stopRecording(); 823 emit stopRecording();
824 endRecording(); 824 endRecording();
825 } 825 }
826 timeSlider->setValue(0); 826 timeSlider->setValue(0);
827} 827}
828 828
829void QtRec::doPlayBtn() { 829void QtRec::doPlayBtn() {
830 830
831 if(!stopped) { 831 if(!stopped) {
832 // playLabel2->setText(tr("Play")); 832 // playLabel2->setText(tr("Play"));
833 stop(); 833 stop();
834 } else { 834 } else {
835 if(ListView1->currentItem() == 0) return; 835 if(ListView1->currentItem() == 0) return;
836 // playLabel2->setText(tr("Stop")); 836 // playLabel2->setText(tr("Stop"));
837 currentFile = ListView1->currentItem()->text(0); 837 currentFile = ListView1->currentItem()->text(0);
838 start(); 838 start();
839 } 839 }
840} 840}
841 841
842void QtRec::start() { //play 842void QtRec::start() { //play
843 if( stopped) { 843 if( stopped) {
844 QPixmap image3( ( const char** ) image3_data ); 844 QPixmap image3( ( const char** ) image3_data );
845 Stop_PushButton->setPixmap( image3 ); 845 Stop_PushButton->setPixmap( image3 );
846 Stop_PushButton->setDown( true); 846 Stop_PushButton->setDown( true);
847 stopped = false; 847 stopped = false;
848 paused = false; 848 paused = false;
849 secCount = 1; 849 secCount = 1;
850 850
851 if( openPlayFile()) 851 if( openPlayFile())
852 if( setupAudio( false)) //recording is false 852 if( setupAudio( false)) //recording is false
853 doPlay(); 853 doPlay();
854 } 854 }
855} 855}
856 856
857bool QtRec::rec() { //record 857bool QtRec::rec() { //record
858 QString timeString; 858 QString timeString;
859 timeString.sprintf("%.0f", 0.0); 859 timeString.sprintf("%.0f", 0.0);
860 // timeLabel->setText( timeString+ " seconds"); 860 // timeLabel->setText( timeString+ " seconds");
861 if(!stopped) { 861 if(!stopped) {
862 monitoring = true; 862 monitoring = true;
863 return false; 863 return false;
864 } else { 864 } else {
865 secCount = 1; 865 secCount = 1;
866 // playLabel2->setText(tr("Stop")); 866 // playLabel2->setText(tr("Stop"));
867 monitoring = false; 867 monitoring = false;
868 setRecordButton( true); 868 setRecordButton( true);
869 869
870 if( setupAudio( true)) 870 if( setupAudio( true))
871 if(setUpFile()) { 871 if(setUpFile()) {
872 int fileSize = 0; 872 int fileSize = 0;
873 Config cfg("OpieRec"); 873 Config cfg("OpieRec");
874 cfg.setGroup("Settings"); 874 cfg.setGroup("Settings");
875 filePara.SecondsToRecord = getCurrentSizeLimit(); 875 filePara.SecondsToRecord = getCurrentSizeLimit();
876 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); 876 int diskSize = checkDiskSpace( (const QString &) wavFile->trackName());
877 877
878 if( filePara.SecondsToRecord == 0) { 878 if( filePara.SecondsToRecord == 0) {
879 fileSize = diskSize; 879 fileSize = diskSize;
880 } else if( filePara.format == WAVE_FORMAT_PCM) { 880 } else if( filePara.format == WAVE_FORMAT_PCM) {
881// odebug << "WAVE_FORMAT_PCM" << oendl; 881// odebug << "WAVE_FORMAT_PCM" << oendl;
882 fileSize = (filePara.SecondsToRecord ) * filePara.channels 882 fileSize = (filePara.SecondsToRecord ) * filePara.channels
883 * filePara.sampleRate * ( filePara.resolution / 8) + 1000; 883 * filePara.sampleRate * ( filePara.resolution / 8) + 1000;
884 } else { 884 } else {
885// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 885// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
886 fileSize = ((filePara.SecondsToRecord) * filePara.channels 886 fileSize = ((filePara.SecondsToRecord) * filePara.channels
887 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; 887 * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250;
888 } 888 }
889 889
890 filePara.samplesToRecord = fileSize; 890 filePara.samplesToRecord = fileSize;
891 odebug << "filesize should be " << filePara.samplesToRecord 891 odebug << "filesize should be " << filePara.samplesToRecord
892 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate; 892 << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate;
893 if( paused) { 893 if( paused) {
894 paused = false; 894 paused = false;
895 } 895 }
896 // else { 896 // else {
897 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; 897 odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl;
898 // if(fileSize != 0) 898 // if(fileSize != 0)
899 timeSlider->setRange(0, filePara.samplesToRecord); 899 timeSlider->setRange(0, filePara.samplesToRecord);
900 // } 900 // }
901 901
902 if( diskSize < fileSize/1024) { 902 if( diskSize < fileSize/1024) {
903 QMessageBox::warning(this, 903 QMessageBox::warning(this,
904 tr("Low Disk Space"), 904 tr("Low Disk Space"),
905 tr("You are running low of\nrecording space\n" 905 tr("You are running low of\nrecording space\n"
906 "or a card isn't being recognized")); 906 "or a card isn't being recognized"));
907 stopped = true; //we need to be stopped 907 stopped = true; //we need to be stopped
908 stop(); 908 stop();
909 } else { 909 } else {
910 QString msg; 910 QString msg;
911 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); 911 msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution);
912#ifdef DEV_VERSION 912#ifdef DEV_VERSION
913 setCaption( msg); 913 setCaption( msg);
914#endif 914#endif
915 filePara.fileName=currentFile.latin1(); 915 filePara.fileName=currentFile.latin1();
916 odebug << "Start recording" << oendl; 916 odebug << "Start recording" << oendl;
917 stopped = false; 917 stopped = false;
918 918
919#ifdef THREADED 919#ifdef THREADED
920 odebug << "Start recording thread" << oendl; 920 odebug << "Start recording thread" << oendl;
921 pthread_t thread1; 921 pthread_t thread1;
922 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); 922 pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/);
923#endif 923#endif
924 toBeginningButton->setEnabled( false); 924 toBeginningButton->setEnabled( false);
925 toEndButton->setEnabled( false); 925 toEndButton->setEnabled( false);
926 926
927 startTimer(1000); 927 startTimer(1000);
928#ifndef THREADED 928#ifndef THREADED
929 quickRec(); 929 quickRec();
930#endif 930#endif
931 } 931 }
932 } //end setUpFile 932 } //end setUpFile
933 } //end setupAudio 933 } //end setupAudio
934 return true; 934 return true;
935} 935}
936/* 936/*
937 This happens when a tab is selected*/ 937 This happens when a tab is selected*/
938void QtRec::thisTab(QWidget* widg) { 938void QtRec::thisTab(QWidget* widg) {
939 if(widg != NULL) { 939 if(widg != NULL) {
940 int index = TabWidget->currentPageIndex(); 940 int index = TabWidget->currentPageIndex();
941 941
942 if(index == 0) { //file page 942 if(index == 0) { //file page
943 } 943 }
944 944
945 if(index == 1) { //control page 945 if(index == 1) { //control page
946 fillDirectoryCombo(); 946 fillDirectoryCombo();
947// soundDevice->getOutVol(); 947// soundDevice->getOutVol();
948// soundDevice->getInVol(); 948// soundDevice->getInVol();
949 } 949 }
950 950
951 if( index==2) { //help page 951 if( index==2) { //help page
952 } 952 }
953 953
954 qApp->processEvents(); 954 qApp->processEvents();
955 update(); 955 update();
956 } 956 }
957} 957}
958 958
959void QtRec::getOutVol( ) { 959void QtRec::getOutVol( ) {
960 filePara.outVol = soundDevice->getOutVolume(); 960 filePara.outVol = soundDevice->getOutVolume();
961// odebug << "out vol " << filePara.outVol << "" << oendl; 961// odebug << "out vol " << filePara.outVol << "" << oendl;
962 OutputSlider->setValue( -filePara.outVol); 962 OutputSlider->setValue( -filePara.outVol);
963} 963}
964 964
965void QtRec::getInVol() { 965void QtRec::getInVol() {
966 filePara.inVol = soundDevice->getInVolume(); 966 filePara.inVol = soundDevice->getInVolume();
967// odebug << "in vol " << filePara.inVol << "" << oendl; 967// odebug << "in vol " << filePara.inVol << "" << oendl;
968 InputSlider->setValue( -filePara.inVol); 968 InputSlider->setValue( -filePara.inVol);
969} 969}
970 970
971void QtRec::changedOutVolume() { 971void QtRec::changedOutVolume() {
972 soundDevice->changedOutVolume( -OutputSlider->value()); 972 soundDevice->changedOutVolume( -OutputSlider->value());
973} 973}
974 974
975void QtRec::changedInVolume( ) { 975void QtRec::changedInVolume( ) {
976 soundDevice->changedInVolume( -InputSlider->value()); 976 soundDevice->changedInVolume( -InputSlider->value());
977} 977}
978 978
979 979
980bool QtRec::setupAudio( bool b) { 980bool QtRec::setupAudio( bool b) {
981 bool ok; 981 bool ok;
982 int sampleformat, stereo, flags; 982 int sampleformat, stereo, flags;
983 QString dspString, mixerString; 983 QString dspString, mixerString;
984 984
985 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 985 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
986 986
987 if( !b) { 987 if( !b) {
988// we want to play 988// we want to play
989#ifdef PDAUDIO //ALSA 989#ifdef PDAUDIO //ALSA
990 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 990 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
991 sampleformat = SND_PCM_FORMAT_S16; 991 sampleformat = SND_PCM_FORMAT_S16;
992 filePara.resolution = 16; 992 filePara.resolution = 16;
993 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { 993 } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) {
994 sampleformat = SND_PCM_FORMAT_S24; 994 sampleformat = SND_PCM_FORMAT_S24;
995 filePara.resolution = 24; 995 filePara.resolution = 24;
996 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { 996 } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) {
997 sampleformat = SND_PCM_FORMAT_S32; 997 sampleformat = SND_PCM_FORMAT_S32;
998 filePara.resolution = 32; 998 filePara.resolution = 32;
999 } else { 999 } else {
1000 sampleformat = SND_PCM_FORMAT_U8; 1000 sampleformat = SND_PCM_FORMAT_U8;
1001 filePara.resolution = 8; 1001 filePara.resolution = 8;
1002 } 1002 }
1003#else 1003#else
1004// we want to play 1004// we want to play
1005 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { 1005 if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) {
1006 sampleformat = AFMT_S16_LE; 1006 sampleformat = AFMT_S16_LE;
1007 filePara.resolution = 16; 1007 filePara.resolution = 16;
1008 } else { 1008 } else {
1009 sampleformat = AFMT_U8; 1009 sampleformat = AFMT_U8;
1010 filePara.resolution = 8; 1010 filePara.resolution = 8;
1011 } 1011 }
1012#endif 1012#endif
1013 1013
1014 stereo = filePara.channels; 1014 stereo = filePara.channels;
1015 flags = O_WRONLY; 1015 flags = O_WRONLY;
1016 recording = false; 1016 recording = false;
1017 } else { // we want to record 1017 } else { // we want to record
1018 1018
1019#ifdef PDAUDIO //ALSA 1019#ifdef PDAUDIO //ALSA
1020 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1020 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1021 sampleformat = SND_PCM_FORMAT_S16; 1021 sampleformat = SND_PCM_FORMAT_S16;
1022 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") 1022 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24")
1023 sampleformat = SND_PCM_FORMAT_S24; 1023 sampleformat = SND_PCM_FORMAT_S24;
1024 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") 1024 else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32")
1025 sampleformat = SND_PCM_FORMAT_S32; 1025 sampleformat = SND_PCM_FORMAT_S32;
1026 else 1026 else
1027 sampleformat = SND_PCM_FORMAT_U8; 1027 sampleformat = SND_PCM_FORMAT_U8;
1028 1028
1029#else 1029#else
1030 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") 1030 if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16")
1031 sampleformat = AFMT_S16_LE; 1031 sampleformat = AFMT_S16_LE;
1032 else 1032 else
1033 sampleformat = AFMT_U8; 1033 sampleformat = AFMT_U8;
1034 1034
1035 if( !compressionCheckBox->isChecked()) { 1035 if( !compressionCheckBox->isChecked()) {
1036 filePara.format = WAVE_FORMAT_PCM; 1036 filePara.format = WAVE_FORMAT_PCM;
1037// odebug << "WAVE_FORMAT_PCM" << oendl; 1037// odebug << "WAVE_FORMAT_PCM" << oendl;
1038 } else { 1038 } else {
1039 filePara.format = WAVE_FORMAT_DVI_ADPCM; 1039 filePara.format = WAVE_FORMAT_DVI_ADPCM;
1040 sampleformat = AFMT_S16_LE; 1040 sampleformat = AFMT_S16_LE;
1041// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; 1041// odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl;
1042 } 1042 }
1043#endif 1043#endif
1044 1044
1045 stereo = filePara.channels; 1045 stereo = filePara.channels;
1046// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; 1046// filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100;
1047 flags= O_RDWR; 1047 flags= O_RDWR;
1048// flags= O_RDONLY; 1048// flags= O_RDONLY;
1049 recording = true; 1049 recording = true;
1050 } 1050 }
1051 1051
1052 owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; 1052 owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl;
1053 // owarn << "change waveform settings" << oendl; 1053 // owarn << "change waveform settings" << oendl;
1054 waveform->changeSettings( filePara.sampleRate, filePara.channels ); 1054 waveform->changeSettings( filePara.sampleRate, filePara.channels );
1055 1055
1056 soundDevice = new Device( this, b); //open rec 1056 soundDevice = new Device( this, b); //open rec
1057// soundDevice->openDsp(); 1057// soundDevice->openDsp();
1058 soundDevice->reset(); 1058 soundDevice->reset();
1059 1059
1060 odebug << "device has been made " << soundDevice->sd << "" << oendl; 1060 odebug << "device has been made " << soundDevice->sd << "" << oendl;
1061 1061
1062 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> 1062 ////////////////// <<<<<<<<<<<<>>>>>>>>>>>>
1063 soundDevice->setDeviceFormat( sampleformat); 1063 soundDevice->setDeviceFormat( sampleformat);
1064 soundDevice->setDeviceChannels( filePara.channels); 1064 soundDevice->setDeviceChannels( filePara.channels);
1065 soundDevice->setDeviceRate( filePara.sampleRate); 1065 soundDevice->setDeviceRate( filePara.sampleRate);
1066 soundDevice->getDeviceFragSize(); 1066 soundDevice->getDeviceFragSize();
1067#ifdef QT_QWS_EBX 1067#ifdef QT_QWS_EBX
1068 int frag = FRAGSIZE; 1068 int frag = FRAGSIZE;
1069 soundDevice->setFragSize( frag); 1069 soundDevice->setFragSize( frag);
1070 soundDevice->getDeviceFragSize(); 1070 soundDevice->getDeviceFragSize();
1071#endif 1071#endif
1072 ///////////////// 1072 /////////////////
1073 filePara.sd = soundDevice->sd; 1073 filePara.sd = soundDevice->sd;
1074 1074
1075 if ( filePara.sd == -1) { 1075 if ( filePara.sd == -1) {
1076 1076
1077 monitoring = false; 1077 monitoring = false;
1078 stopped = true; 1078 stopped = true;
1079 update(); 1079 update();
1080 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); 1080 setCaption( tr( "OpieRecord " )+ QString::number(VERSION) );
1081 return false; 1081 return false;
1082 } 1082 }
1083 if(autoMute) 1083 if(autoMute)
1084 doMute(false); 1084 doMute(false);
1085 1085
1086 return true; 1086 return true;
1087} 1087}
1088 1088
1089 1089
1090bool QtRec::setUpFile() { //setup file for recording 1090bool QtRec::setUpFile() { //setup file for recording
1091 wavFile = new WavFile( this, (const QString &)"", 1091 wavFile = new WavFile( this, (const QString &)"",
1092 true, 1092 true,
1093 filePara.sampleRate, 1093 filePara.sampleRate,
1094 filePara.channels, 1094 filePara.channels,
1095 filePara.resolution, 1095 filePara.resolution,
1096 filePara.format); 1096 filePara.format);
1097 1097
1098 filePara.fd = wavFile->wavHandle(); 1098 filePara.fd = wavFile->wavHandle();
1099 if(filePara.fd == -1) { 1099 if(filePara.fd == -1) {
1100 return false; 1100 return false;
1101 } else { 1101 } else {
1102 } 1102 }
1103 return true; 1103 return true;
1104} 1104}
1105 1105
1106/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> 1106/// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>>
1107bool QtRec::doPlay() { 1107bool QtRec::doPlay() {
1108 1108
1109 if( !paused) { 1109 if( !paused) {
1110 total = 0; 1110 total = 0;
1111 filePara.numberOfRecordedSeconds = 0; 1111 filePara.numberOfRecordedSeconds = 0;
1112 } else { 1112 } else {
1113 paused = false; 1113 paused = false;
1114 secCount = (int)filePara.numberOfRecordedSeconds; 1114 secCount = (int)filePara.numberOfRecordedSeconds;
1115 } 1115 }
1116 playing = true; 1116 playing = true;
1117 stopped = false; 1117 stopped = false;
1118 recording = false; 1118 recording = false;
1119 1119
1120 QString num; 1120 QString num;
1121 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; 1121 odebug << "Play number of samples " << filePara.numberSamples << "" << oendl;
1122 1122
1123// timeSlider->setRange( 0, filePara.numberSamples); 1123// timeSlider->setRange( 0, filePara.numberSamples);
1124 1124
1125 timeString.sprintf("%f", filePara.numberOfRecordedSeconds); 1125 timeString.sprintf("%f", filePara.numberOfRecordedSeconds);
1126 // timeLabel->setText( timeString+ tr(" seconds")); 1126 // timeLabel->setText( timeString+ tr(" seconds"));
1127 1127
1128 QString msg; 1128 QString msg;
1129 msg.sprintf("%d, %d, %d", 1129 msg.sprintf("%d, %d, %d",
1130 filePara.sampleRate, 1130 filePara.sampleRate,
1131 filePara.channels, 1131 filePara.channels,
1132 filePara.resolution); 1132 filePara.resolution);
1133#ifdef DEV_VERSION 1133#ifdef DEV_VERSION
1134 setCaption( msg); 1134 setCaption( msg);
1135#endif 1135#endif
1136 1136
1137 startTimer( 1000); 1137 startTimer( 1000);
1138#ifdef THREADED 1138#ifdef THREADED
1139 pthread_t thread2; 1139 pthread_t thread2;
1140 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); 1140 pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/);
1141#endif 1141#endif
1142 1142
1143 toBeginningButton->setEnabled( false); 1143 toBeginningButton->setEnabled( false);
1144 toEndButton->setEnabled( false); 1144 toEndButton->setEnabled( false);
1145#ifndef THREADED 1145#ifndef THREADED
1146 playIt(); 1146 playIt();
1147#endif 1147#endif
1148 return true; 1148 return true;
1149} 1149}
1150 1150
1151 1151
1152void QtRec::changebitrateCombo(int i) { 1152void QtRec::changebitrateCombo(int i) {
1153 Config cfg("OpieRec"); 1153 Config cfg("OpieRec");
1154 cfg.setGroup("Settings"); 1154 cfg.setGroup("Settings");
1155 int bits = 0; 1155 int bits = 0;
1156 if( i == 1) { bits = 16; } 1156 if( i == 1) { bits = 16; }
1157 else if( i == 2) { bits = 24; } 1157 else if( i == 2) { bits = 24; }
1158 else if( i == 3) { bits = 32; } 1158 else if( i == 3) { bits = 32; }
1159 else { bits=8; } 1159 else { bits=8; }
1160 cfg.writeEntry("bitrate", bits); 1160 cfg.writeEntry("bitrate", bits);
1161 filePara.resolution = bits; 1161 filePara.resolution = bits;
1162 cfg.write(); 1162 cfg.write();
1163} 1163}
1164 1164
1165void QtRec::changesamplerateCombo(int i) { 1165void QtRec::changesamplerateCombo(int i) {
1166 Config cfg("OpieRec"); 1166 Config cfg("OpieRec");
1167 cfg.setGroup("Settings"); 1167 cfg.setGroup("Settings");
1168 int rate=0; 1168 int rate=0;
1169 bool ok; 1169 bool ok;
1170 rate = sampleRateComboBox->text(i).toInt(&ok, 10); 1170 rate = sampleRateComboBox->text(i).toInt(&ok, 10);
1171 cfg.writeEntry( "samplerate",rate); 1171 cfg.writeEntry( "samplerate",rate);
1172 filePara.sampleRate=rate; 1172 filePara.sampleRate=rate;
1173 odebug << "Change sample rate " << rate << "" << oendl; 1173 odebug << "Change sample rate " << rate << "" << oendl;
1174 cfg.write(); 1174 cfg.write();
1175} 1175}
1176 1176
1177 1177
1178void QtRec::changeDirCombo(int index) { 1178void QtRec::changeDirCombo(int index) {
1179 Config cfg("OpieRec"); 1179 Config cfg("OpieRec");
1180 cfg.setGroup("Settings"); 1180 cfg.setGroup("Settings");
1181 QString sName = directoryComboBox->text(index); 1181 QString sName = directoryComboBox->text(index);
1182 1182
1183 StorageInfo storageInfo; 1183 StorageInfo storageInfo;
1184 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1184 const QList<FileSystem> &fs = storageInfo.fileSystems();
1185 QListIterator<FileSystem> it ( fs ); 1185 QListIterator<FileSystem> it ( fs );
1186 QString storage; 1186 QString storage;
1187 for( ; it.current(); ++it ){ 1187 for( ; it.current(); ++it ){
1188 if( sName == (*it)->name()+" "+ (*it)->path() || 1188 if( sName == (*it)->name()+" "+ (*it)->path() ||
1189 (*it)->name() == sName ) { 1189 (*it)->name() == sName ) {
1190 const QString path = (*it)->path(); 1190 const QString path = (*it)->path();
1191 recDir = path; 1191 recDir = path;
1192 cfg.writeEntry("directory", recDir); 1192 cfg.writeEntry("directory", recDir);
1193 odebug << "new rec dir "+recDir << oendl; 1193 odebug << "new rec dir "+recDir << oendl;
1194 } 1194 }
1195 } 1195 }
1196 cfg.write(); 1196 cfg.write();
1197} 1197}
1198 1198
1199 1199
1200void QtRec::changeSizeLimitCombo(int) { 1200void QtRec::changeSizeLimitCombo(int) {
1201 Config cfg("OpieRec"); 1201 Config cfg("OpieRec");
1202 cfg.setGroup("Settings"); 1202 cfg.setGroup("Settings");
1203 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); 1203 cfg.writeEntry("sizeLimit", getCurrentSizeLimit() );
1204 cfg.write(); 1204 cfg.write();
1205} 1205}
1206 1206
1207void QtRec::newSound() { 1207void QtRec::newSound() {
1208 if( !rec()) { 1208 if( !rec()) {
1209 endRecording(); 1209 endRecording();
1210 deleteSound(); 1210 deleteSound();
1211 } 1211 }
1212} 1212}
1213 1213
1214void QtRec::itClick(QListViewItem *item) { 1214void QtRec::itClick(QListViewItem *item) {
1215 currentFile = item->text(0); 1215 currentFile = item->text(0);
1216 setCaption("OpieRecord "+currentFile); 1216 setCaption("OpieRecord "+currentFile);
1217} 1217}
1218 1218
1219void QtRec::deleteSound() { 1219void QtRec::deleteSound() {
1220 Config cfg("OpieRec"); 1220 Config cfg("OpieRec");
1221 cfg.setGroup("Sounds"); 1221 cfg.setGroup("Sounds");
1222 if( ListView1->currentItem() == NULL) 1222 if( ListView1->currentItem() == NULL)
1223 return; 1223 return;
1224 QString file = ListView1->currentItem()->text(0); 1224 QString file = ListView1->currentItem()->text(0);
1225 QString fileName; 1225 QString fileName;
1226 fileName = cfg.readEntry( file, ""); 1226 fileName = cfg.readEntry( file, "");
1227 QFile f( fileName); 1227 QFile f( fileName);
1228 if( f.exists()) 1228 if( f.exists())
1229 if( !f.remove()) 1229 if( !f.remove())
1230 QMessageBox::message( tr("Error"), tr("Could not remove file.")); 1230 QMessageBox::message( tr("Error"), tr("Could not remove file."));
1231 1231
1232 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1232 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1233 bool found = false; 1233 bool found = false;
1234 for(int i=0;i<nFiles+1;i++) { 1234 for(int i=0;i<nFiles+1;i++) {
1235 1235
1236 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { 1236 if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) {
1237 found = true; 1237 found = true;
1238 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1238 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1239 } 1239 }
1240 if(found) 1240 if(found)
1241 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); 1241 cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),""));
1242 } 1242 }
1243 1243
1244 cfg.removeEntry( cfg.readEntry( file)); 1244 cfg.removeEntry( cfg.readEntry( file));
1245 cfg.removeEntry( file); 1245 cfg.removeEntry( file);
1246 cfg.writeEntry( "NumberofFiles", nFiles-1); 1246 cfg.writeEntry( "NumberofFiles", nFiles-1);
1247 cfg.write(); 1247 cfg.write();
1248 1248
1249 ListView1->takeItem( ListView1->currentItem() ); 1249 ListView1->takeItem( ListView1->currentItem() );
1250 delete ListView1->currentItem(); 1250 delete ListView1->currentItem();
1251 1251
1252 ListView1->clear(); 1252 ListView1->clear();
1253 ListView1->setSelected( ListView1->firstChild(), true); 1253 ListView1->setSelected( ListView1->firstChild(), true);
1254 initIconView(); 1254 initIconView();
1255 update(); 1255 update();
1256 setCaption( tr( "OpieRecord " )); 1256 setCaption( tr( "OpieRecord " ));
1257} 1257}
1258 1258
1259void QtRec::keyPressEvent( QKeyEvent *e) { 1259void QtRec::keyPressEvent( QKeyEvent *e) {
1260 1260
1261 switch ( e->key() ) { 1261 switch ( e->key() ) {
1262 // case Key_F1: 1262 // case Key_F1:
1263 // if(stopped && !recording) 1263 // if(stopped && !recording)
1264 // newSound(); 1264 // newSound();
1265 // else 1265 // else
1266 // stop(); 1266 // stop();
1267 // break; 1267 // break;
1268 // case Key_F2: { 1268 // case Key_F2: {
1269 // if( !e->isAutoRepeat()) 1269 // if( !e->isAutoRepeat())
1270 // rewindPressed(); 1270 // rewindPressed();
1271 // } 1271 // }
1272 // break; 1272 // break;
1273 // case Key_F3: { 1273 // case Key_F3: {
1274 // if( !e->isAutoRepeat()) 1274 // if( !e->isAutoRepeat())
1275 // FastforwardPressed(); 1275 // FastforwardPressed();
1276 // } 1276 // }
1277 // break; 1277 // break;
1278 1278
1279 ////////////////////////////// Zaurus keys 1279 ////////////////////////////// Zaurus keys
1280 case Key_F9: //activity 1280 case Key_F9: //activity
1281 break; 1281 break;
1282 case Key_F10: //contacts 1282 case Key_F10: //contacts
1283 break; 1283 break;
1284 case Key_F11: //menu 1284 case Key_F11: //menu
1285 break; 1285 break;
1286 case Key_F12: //home 1286 case Key_F12: //home
1287 break; 1287 break;
1288 case Key_F13: //mail 1288 case Key_F13: //mail
1289 break; 1289 break;
1290 case Key_Space: 1290 case Key_Space:
1291 break; 1291 break;
1292 case Key_Delete: 1292 case Key_Delete:
1293 break; 1293 break;
1294 case Key_Up: 1294 case Key_Up:
1295 // stop(); 1295 // stop();
1296 break; 1296 break;
1297 case Key_Down: 1297 case Key_Down:
1298 // newSound(); 1298 // newSound();
1299 break; 1299 break;
1300 case Key_Left: { 1300 case Key_Left: {
1301 odebug << "rewinding" << oendl; 1301 odebug << "rewinding" << oendl;
1302 if( !e->isAutoRepeat()) 1302 if( !e->isAutoRepeat())
1303 rewindPressed(); 1303 rewindPressed();
1304 } 1304 }
1305 break; 1305 break;
1306 case Key_Right: { 1306 case Key_Right: {
1307 if( !e->isAutoRepeat()) 1307 if( !e->isAutoRepeat())
1308 FastforwardPressed(); 1308 FastforwardPressed();
1309 } 1309 }
1310 break; 1310 break;
1311 } 1311 }
1312} 1312}
1313 1313
1314void QtRec::keyReleaseEvent( QKeyEvent *e) { 1314void QtRec::keyReleaseEvent( QKeyEvent *e) {
1315 switch ( e->key() ) { 1315 switch ( e->key() ) {
1316 // case Key_F1: 1316 // case Key_F1:
1317 // if(stopped && !recording) 1317 // if(stopped && !recording)
1318 // newSound(); 1318 // newSound();
1319 // else 1319 // else
1320 // stop(); 1320 // stop();
1321 // break; 1321 // break;
1322 // case Key_F2: 1322 // case Key_F2:
1323 // rewindReleased(); 1323 // rewindReleased();
1324 // break; 1324 // break;
1325 // case Key_F3: 1325 // case Key_F3:
1326 // FastforwardReleased(); 1326 // FastforwardReleased();
1327 // break; 1327 // break;
1328 1328
1329 ////////////////////////////// Zaurus keys 1329 ////////////////////////////// Zaurus keys
1330 case Key_F9: //activity 1330 case Key_F9: //activity
1331 break; 1331 break;
1332 case Key_F10: //contacts 1332 case Key_F10: //contacts
1333 break; 1333 break;
1334 case Key_F11: //menu 1334 case Key_F11: //menu
1335 break; 1335 break;
1336 case Key_F12: //home 1336 case Key_F12: //home
1337 if(stopped) 1337 if(stopped)
1338 doPlayBtn(); 1338 doPlayBtn();
1339 else 1339 else
1340 stop(); 1340 stop();
1341 break; 1341 break;
1342 case Key_F13: //mail 1342 case Key_F13: //mail
1343 break; 1343 break;
1344 case Key_Space: 1344 case Key_Space:
1345 if(stopped && !recording) 1345 if(stopped && !recording)
1346 newSound(); 1346 newSound();
1347 else 1347 else
1348 stop(); 1348 stop();
1349 break; 1349 break;
1350 case Key_Delete: 1350 case Key_Delete:
1351 deleteSound(); 1351 deleteSound();
1352 break; 1352 break;
1353 case Key_Up: 1353 case Key_Up:
1354 // stop(); 1354 // stop();
1355 odebug << "Up" << oendl; 1355 odebug << "Up" << oendl;
1356 break; 1356 break;
1357 case Key_Down: 1357 case Key_Down:
1358 // start(); 1358 // start();
1359 // odebug << "Down" << oendl; 1359 // odebug << "Down" << oendl;
1360 // newSound(); 1360 // newSound();
1361 break; 1361 break;
1362 case Key_Left: 1362 case Key_Left:
1363 odebug << "Left" << oendl; 1363 odebug << "Left" << oendl;
1364 rewindReleased(); 1364 rewindReleased();
1365 break; 1365 break;
1366 case Key_Right: 1366 case Key_Right:
1367 odebug << "Right" << oendl; 1367 odebug << "Right" << oendl;
1368 FastforwardReleased(); 1368 FastforwardReleased();
1369 break; 1369 break;
1370 } 1370 }
1371} 1371}
1372 1372
1373void QtRec::endRecording() { 1373void QtRec::endRecording() {
1374 1374
1375 monitoring = false; 1375 monitoring = false;
1376 recording = false; 1376 recording = false;
1377 stopped = true; 1377 stopped = true;
1378 waveform->reset(); 1378 waveform->reset();
1379 setRecordButton( false); 1379 setRecordButton( false);
1380 1380
1381 toBeginningButton->setEnabled( true); 1381 toBeginningButton->setEnabled( true);
1382 toEndButton->setEnabled( true); 1382 toEndButton->setEnabled( true);
1383 1383
1384 killTimers(); 1384 killTimers();
1385 1385
1386 if(autoMute) 1386 if(autoMute)
1387 doMute( true); 1387 doMute( true);
1388 1388
1389 soundDevice->closeDevice( true); 1389 soundDevice->closeDevice( true);
1390 1390
1391 if( wavFile->track.isOpen()) { 1391 if( wavFile->track.isOpen()) {
1392 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); 1392 wavFile->adjustHeaders( filePara.fd, filePara.numberSamples);
1393 filePara.numberSamples = 0; 1393 filePara.numberSamples = 0;
1394 wavFile->closeFile(); 1394 wavFile->closeFile();
1395 filePara.fd=0; 1395 filePara.fd=0;
1396 1396
1397 if( wavFile->isTempFile()) { 1397 if( wavFile->isTempFile()) {
1398// move tmp file to regular file 1398// move tmp file to regular file
1399 QString cmd; 1399 QString cmd;
1400 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); 1400 cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName);
1401 odebug << "moving tmp file to "+currentFileName << oendl; 1401 odebug << "moving tmp file to "+currentFileName << oendl;
1402 system( cmd.latin1()); 1402 system( cmd.latin1());
1403 } 1403 }
1404 1404
1405 odebug << "Just moved " + wavFile->currentFileName << oendl; 1405 odebug << "Just moved " + wavFile->currentFileName << oendl;
1406 Config cfg("OpieRec"); 1406 Config cfg("OpieRec");
1407 cfg.setGroup("Sounds"); 1407 cfg.setGroup("Sounds");
1408 1408
1409 int nFiles = cfg.readNumEntry( "NumberofFiles",0); 1409 int nFiles = cfg.readNumEntry( "NumberofFiles",0);
1410 1410
1411 currentFile = QFileInfo( wavFile->currentFileName).fileName(); 1411 currentFile = QFileInfo( wavFile->currentFileName).fileName();
1412 currentFile = currentFile.left( currentFile.length() - 4); 1412 currentFile = currentFile.left( currentFile.length() - 4);
1413 1413
1414 cfg.writeEntry( "NumberofFiles", nFiles + 1); 1414 cfg.writeEntry( "NumberofFiles", nFiles + 1);
1415 cfg.writeEntry( QString::number( nFiles + 1), currentFile); 1415 cfg.writeEntry( QString::number( nFiles + 1), currentFile);
1416 cfg.writeEntry( currentFile, wavFile->currentFileName); 1416 cfg.writeEntry( currentFile, wavFile->currentFileName);
1417 1417
1418 QString time; 1418 QString time;
1419 time.sprintf("%.2f", filePara.numberOfRecordedSeconds); 1419 time.sprintf("%.2f", filePara.numberOfRecordedSeconds);
1420 cfg.writeEntry( wavFile->currentFileName, time ); 1420 cfg.writeEntry( wavFile->currentFileName, time );
1421 odebug << "writing config numberOfRecordedSeconds "+time << oendl; 1421 odebug << "writing config numberOfRecordedSeconds "+time << oendl;
1422 1422
1423 cfg.write(); 1423 cfg.write();
1424 odebug << "finished recording" << oendl; 1424 odebug << "finished recording" << oendl;
1425 // timeLabel->setText(""); 1425 // timeLabel->setText("");
1426 } 1426 }
1427 1427
1428// if(soundDevice) delete soundDevice; 1428// if(soundDevice) delete soundDevice;
1429 1429
1430 timeSlider->setValue(0); 1430 timeSlider->setValue(0);
1431 initIconView(); 1431 initIconView();
1432 selectItemByName( currentFile); 1432 selectItemByName( currentFile);
1433 setCaption( tr( "OpieRecord " )); 1433 setCaption( tr( "OpieRecord " ));
1434 1434
1435} 1435}
1436 1436
1437void QtRec::endPlaying() { 1437void QtRec::endPlaying() {
1438 monitoring = false; 1438 monitoring = false;
1439 recording = false; 1439 recording = false;
1440 playing = false; 1440 playing = false;
1441 stopped = true; 1441 stopped = true;
1442 waveform->reset(); 1442 waveform->reset();
1443// errorStop(); 1443// errorStop();
1444 odebug << "end playing" << oendl; 1444 odebug << "end playing" << oendl;
1445 setRecordButton( false); 1445 setRecordButton( false);
1446 1446
1447 toBeginningButton->setEnabled( true); 1447 toBeginningButton->setEnabled( true);
1448 toEndButton->setEnabled( true); 1448 toEndButton->setEnabled( true);
1449 1449
1450 if(autoMute) 1450 if(autoMute)
1451 doMute( true); 1451 doMute( true);
1452 1452
1453 soundDevice->closeDevice( false); 1453 soundDevice->closeDevice( false);
1454 soundDevice->sd = -1; 1454 soundDevice->sd = -1;
1455 // if(soundDevice) delete soundDevice; 1455 // if(soundDevice) delete soundDevice;
1456 odebug << "file and sound device closed" << oendl; 1456 odebug << "file and sound device closed" << oendl;
1457 // timeLabel->setText(""); 1457 // timeLabel->setText("");
1458 total = 0; 1458 total = 0;
1459 filePara.numberSamples = 0; 1459 filePara.numberSamples = 0;
1460 filePara.sd = -1; 1460 filePara.sd = -1;
1461// wavFile->closeFile(); 1461// wavFile->closeFile();
1462 filePara.fd = 0; 1462 filePara.fd = 0;
1463// if(wavFile) delete wavFile; //this crashes 1463// if(wavFile) delete wavFile; //this crashes
1464 1464
1465 odebug << "track closed" << oendl; 1465 odebug << "track closed" << oendl;
1466 killTimers(); 1466 killTimers();
1467 // owarn << "reset slider" << oendl; 1467 // owarn << "reset slider" << oendl;
1468 timeSlider->setValue(0); 1468 timeSlider->setValue(0);
1469 1469
1470// if(soundDevice) delete soundDevice; 1470// if(soundDevice) delete soundDevice;
1471 1471
1472} 1472}
1473 1473
1474bool QtRec::openPlayFile() { 1474bool QtRec::openPlayFile() {
1475 qWarning("opening file"); 1475 qWarning("opening file");
1476 qApp->processEvents(); 1476 qApp->processEvents();
1477 if( currentFile.isEmpty()) { 1477 if( currentFile.isEmpty()) {
1478 QMessageBox::message(tr("Opierec"),tr("Please select file to play")); 1478 QMessageBox::message(tr("Opierec"),tr("Please select file to play"));
1479 endPlaying(); 1479 endPlaying();
1480 return false; 1480 return false;
1481 } 1481 }
1482 QString currentFileName; 1482 QString currentFileName;
1483 Config cfg("OpieRec"); 1483 Config cfg("OpieRec");
1484 cfg.setGroup("Sounds"); 1484 cfg.setGroup("Sounds");
1485 int nFiles = cfg.readNumEntry( "NumberofFiles", 0); 1485 int nFiles = cfg.readNumEntry( "NumberofFiles", 0);
1486 for(int i=0;i<nFiles+1;i++) { //look for file 1486 for(int i=0;i<nFiles+1;i++) { //look for file
1487 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { 1487 if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) {
1488 currentFileName = cfg.readEntry( currentFile, "" ); 1488 currentFileName = cfg.readEntry( currentFile, "" );
1489 odebug << "opening for play: " + currentFileName << oendl; 1489 odebug << "opening for play: " + currentFileName << oendl;
1490 } 1490 }
1491 } 1491 }
1492 wavFile = new WavFile(this, 1492 wavFile = new WavFile(this,
1493 currentFileName, 1493 currentFileName,
1494 false); 1494 false);
1495 filePara.fd = wavFile->wavHandle(); 1495 filePara.fd = wavFile->wavHandle();
1496 if(filePara.fd == -1) { 1496 if(filePara.fd == -1) {
1497 // if(!track.open(IO_ReadOnly)) { 1497 // if(!track.open(IO_ReadOnly)) {
1498 QString errorMsg = (QString)strerror(errno); 1498 QString errorMsg = (QString)strerror(errno);
1499 monitoring = false; 1499 monitoring = false;
1500 setCaption( tr( "OpieRecord " )); 1500 setCaption( tr( "OpieRecord " ));
1501 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") 1501 QMessageBox::message(tr("Note"), tr("Could not open audio file.\n")
1502 + errorMsg + "\n" + currentFile); 1502 + errorMsg + "\n" + currentFile);
1503 return false; 1503 return false;
1504 } else { 1504 } else {
1505 1505
1506 filePara.numberSamples = wavFile->getNumberSamples(); 1506 filePara.numberSamples = wavFile->getNumberSamples();
1507 filePara.format = wavFile->getFormat(); 1507 filePara.format = wavFile->getFormat();
1508 filePara.sampleRate = wavFile->getSampleRate(); 1508 filePara.sampleRate = wavFile->getSampleRate();
1509 filePara.resolution = wavFile->getResolution(); 1509 filePara.resolution = wavFile->getResolution();
1510 filePara.channels = wavFile->getChannels(); 1510 filePara.channels = wavFile->getChannels();
1511 timeSlider->setPageStep(1); 1511 timeSlider->setPageStep(1);
1512 monitoring = true; 1512 monitoring = true;
1513 1513
1514 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl; 1514 odebug << "file " << filePara.fd << ", samples " << filePara.numberSamples << " " << filePara.sampleRate << "" << oendl;
1515 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); 1515 int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8));
1516 1516
1517 // owarn << "seconds " << sec << "" << oendl; 1517 // owarn << "seconds " << sec << "" << oendl;
1518 1518
1519 timeSlider->setRange(0, filePara.numberSamples ); 1519 timeSlider->setRange(0, filePara.numberSamples );
1520 } 1520 }
1521 1521
1522 return true; 1522 return true;
1523} 1523}
1524 1524
1525void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { 1525void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) {
1526 if(item == NULL ) 1526 if(item == NULL )
1527 return; 1527 return;
1528 switch (mouse) { 1528 switch (mouse) {
1529 case 1: { 1529 case 1: {
1530 if( renameBox != 0 ) //tricky 1530 if( renameBox != 0 ) //tricky
1531 cancelRename(); 1531 cancelRename();
1532 1532
1533 currentFile = item->text(0); 1533 currentFile = item->text(0);
1534 // setCaption( "OpieRecord " + currentFile); 1534 // setCaption( "OpieRecord " + currentFile);
1535 } 1535 }
1536 break; 1536 break;
1537 case 2: 1537 case 2:
1538 showListMenu(item); 1538 showListMenu(item);
1539 ListView1->clearSelection(); 1539 ListView1->clearSelection();
1540 break; 1540 break;
1541 }; 1541 };
1542} 1542}
1543 1543
1544void QtRec::showListMenu(QListViewItem * item) { 1544void QtRec::showListMenu(QListViewItem * item) {
1545 if(item == NULL) 1545 if(item == NULL)
1546 return; 1546 return;
1547 QPopupMenu *m = new QPopupMenu(this); 1547 QPopupMenu *m = new QPopupMenu(this);
1548 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); 1548 m->insertItem( tr("Play"), this, SLOT( doMenuPlay() ));
1549 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); 1549 if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() ));
1550 m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); 1550 m->insertItem( tr( "Rename" ), this, SLOT( doRename() ));
1551 // #if defined (QTOPIA_INTERNAL_FSLP) 1551 // #if defined (QTOPIA_INTERNAL_FSLP)
1552 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); 1552 // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
1553 // #endif 1553 // #endif
1554 m->insertSeparator(); 1554 m->insertSeparator();
1555 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); 1555 m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) );
1556 m->exec( QCursor::pos() ); 1556 m->exec( QCursor::pos() );
1557 qApp->processEvents(); 1557 qApp->processEvents();
1558} 1558}
1559 1559
1560void QtRec::fileBeamFinished( Ir *ir) { 1560void QtRec::fileBeamFinished( Ir *ir) {
1561 if(ir) 1561 if(ir)
1562 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); 1562 QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") );
1563 1563
1564} 1564}
1565 1565
1566void QtRec::doBeam() { 1566void QtRec::doBeam() {
1567 qApp->processEvents(); 1567 qApp->processEvents();
1568 if( ListView1->currentItem() == NULL) 1568 if( ListView1->currentItem() == NULL)
1569 return; 1569 return;
1570 Ir ir; 1570 Ir ir;
1571 if( ir.supported()) { 1571 if( ir.supported()) {
1572 QString file = ListView1->currentItem()->text(0); 1572 QString file = ListView1->currentItem()->text(0);
1573 Config cfg("OpieRec"); 1573 Config cfg("OpieRec");
1574 cfg.setGroup("Sounds"); 1574 cfg.setGroup("Sounds");
1575 1575
1576 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1576 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1577 1577
1578 for(int i=0;i<nFiles+1;i++) { 1578 for(int i=0;i<nFiles+1;i++) {
1579 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { 1579 if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) {
1580 QString filePath = cfg.readEntry(file,""); 1580 QString filePath = cfg.readEntry(file,"");
1581 Ir *file = new Ir(this, "IR"); 1581 Ir *file = new Ir(this, "IR");
1582 connect( file, SIGNAL( done(Ir*)), 1582 connect( file, SIGNAL( done(Ir*)),
1583 this, SLOT( fileBeamFinished(Ir*))); 1583 this, SLOT( fileBeamFinished(Ir*)));
1584 file->send( filePath, "OPieRec audio file\n" + filePath ); 1584 file->send( filePath, "OPieRec audio file\n" + filePath );
1585 } 1585 }
1586 } 1586 }
1587 } 1587 }
1588} 1588}
1589 1589
1590void QtRec::doMenuPlay() { 1590void QtRec::doMenuPlay() {
1591 qApp->processEvents(); 1591 qApp->processEvents();
1592 currentFile = ListView1->currentItem()->text(0); 1592 currentFile = ListView1->currentItem()->text(0);
1593} 1593}
1594 1594
1595void QtRec::doRename() { 1595void QtRec::doRename() {
1596 QRect r = ListView1->itemRect( ListView1->currentItem( )); 1596 QRect r = ListView1->itemRect( ListView1->currentItem( ));
1597 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); 1597 r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() );
1598 r.setX( ListView1->contentsX() ); 1598 r.setX( ListView1->contentsX() );
1599 if ( r.width() > ListView1->visibleWidth() ) 1599 if ( r.width() > ListView1->visibleWidth() )
1600 r.setWidth( ListView1->visibleWidth() ); 1600 r.setWidth( ListView1->visibleWidth() );
1601 1601
1602 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); 1602 renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" );
1603 renameBox->setFrame(true); 1603 renameBox->setFrame(true);
1604 1604
1605 renameBox->setText( ListView1->currentItem()->text(0) ); 1605 renameBox->setText( ListView1->currentItem()->text(0) );
1606 1606
1607 renameBox->selectAll(); 1607 renameBox->selectAll();
1608 renameBox->installEventFilter( this ); 1608 renameBox->installEventFilter( this );
1609 ListView1->addChild( renameBox, r.x(), r.y() ); 1609 ListView1->addChild( renameBox, r.x(), r.y() );
1610 renameBox->resize( r.size() ); 1610 renameBox->resize( r.size() );
1611 ListView1->viewport()->setFocusProxy( renameBox ); 1611 ListView1->viewport()->setFocusProxy( renameBox );
1612 renameBox->setFocus(); 1612 renameBox->setFocus();
1613 renameBox->show(); 1613 renameBox->show();
1614 1614
1615} 1615}
1616 1616
1617void QtRec::okRename() { 1617void QtRec::okRename() {
1618 odebug << renameBox->text() << oendl; 1618 odebug << renameBox->text() << oendl;
1619 QString filename = renameBox->text(); 1619 QString filename = renameBox->text();
1620 cancelRename(); 1620 cancelRename();
1621 1621
1622 if( ListView1->currentItem() == NULL) 1622 if( ListView1->currentItem() == NULL)
1623 return; 1623 return;
1624 1624
1625 Config cfg("OpieRec"); 1625 Config cfg("OpieRec");
1626 cfg.setGroup("Sounds"); 1626 cfg.setGroup("Sounds");
1627 1627
1628 QString file = ListView1->currentItem()->text(0); 1628 QString file = ListView1->currentItem()->text(0);
1629 1629
1630 odebug << "filename is " + filename << oendl; 1630 odebug << "filename is " + filename << oendl;
1631 1631
1632 int nFiles = cfg.readNumEntry("NumberofFiles",0); 1632 int nFiles = cfg.readNumEntry("NumberofFiles",0);
1633 1633
1634 for(int i=0;i<nFiles+1;i++) { //look for file 1634 for(int i=0;i<nFiles+1;i++) { //look for file
1635 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { 1635 if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) {
1636 1636
1637 QString filePath = cfg.readEntry(file,""); 1637 QString filePath = cfg.readEntry(file,"");
1638 1638
1639 cfg.writeEntry( QString::number(i), filename ); 1639 cfg.writeEntry( QString::number(i), filename );
1640 cfg.writeEntry( filename, filePath ); 1640 cfg.writeEntry( filename, filePath );
1641 cfg.removeEntry( file); 1641 cfg.removeEntry( file);
1642 cfg.write(); 1642 cfg.write();
1643 } 1643 }
1644 } 1644 }
1645 1645
1646 ListView1->takeItem( ListView1->currentItem() ); 1646 ListView1->takeItem( ListView1->currentItem() );
1647 delete ListView1->currentItem(); 1647 delete ListView1->currentItem();
1648 ListView1->clear(); 1648 ListView1->clear();
1649 initIconView(); 1649 initIconView();
1650 update(); 1650 update();
1651} 1651}
1652 1652
1653void QtRec::cancelRename() { 1653void QtRec::cancelRename() {
1654 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; 1654 bool resetFocus = ListView1->viewport()->focusProxy() == renameBox;
1655 delete renameBox; 1655 delete renameBox;
1656 renameBox = 0; 1656 renameBox = 0;
1657 if ( resetFocus ) { 1657 if ( resetFocus ) {
1658 ListView1->viewport()->setFocusProxy( ListView1 ); 1658 ListView1->viewport()->setFocusProxy( ListView1 );
1659 ListView1->setFocus(); 1659 ListView1->setFocus();
1660 } 1660 }
1661} 1661}
1662 1662
1663bool QtRec::eventFilter( QObject * o, QEvent * e ) { 1663bool QtRec::eventFilter( QObject * o, QEvent * e ) {
1664 if ( o->inherits( "QLineEdit" ) ) { 1664 if ( o->inherits( "QLineEdit" ) ) {
1665 if ( e->type() == QEvent::KeyPress ) { 1665 if ( e->type() == QEvent::KeyPress ) {
1666 QKeyEvent *ke = (QKeyEvent*)e; 1666 QKeyEvent *ke = (QKeyEvent*)e;
1667 if ( ke->key() == Key_Return || 1667 if ( ke->key() == Key_Return ||
1668 ke->key() == Key_Enter ) { 1668 ke->key() == Key_Enter ) {
1669 okRename(); 1669 okRename();
1670 return true; 1670 return true;
1671 } else if ( ke->key() == Key_Escape ) { 1671 } else if ( ke->key() == Key_Escape ) {
1672 cancelRename(); 1672 cancelRename();
1673 return true; 1673 return true;
1674 } 1674 }
1675 } else if ( e->type() == QEvent::FocusOut ) { 1675 } else if ( e->type() == QEvent::FocusOut ) {
1676 cancelRename(); 1676 cancelRename();
1677 return true; 1677 return true;
1678 } 1678 }
1679 } 1679 }
1680 return QWidget::eventFilter( o, e ); 1680 return QWidget::eventFilter( o, e );
1681} 1681}
1682 1682
1683 1683
1684int QtRec::getCurrentSizeLimit() { 1684int QtRec::getCurrentSizeLimit() {
1685 return sizeLimitCombo->currentItem() * 5; 1685 return sizeLimitCombo->currentItem() * 5;
1686} 1686}
1687 1687
1688void QtRec::timerBreak() { 1688void QtRec::timerBreak() {
1689 endPlaying(); 1689 endPlaying();
1690} 1690}
1691 1691
1692void QtRec::doVolMuting(bool b) { 1692void QtRec::doVolMuting(bool b) {
1693 Config cfg( "qpe" ); 1693 Config cfg( "qpe" );
1694 cfg. setGroup( "Volume" ); 1694 cfg. setGroup( "Volume" );
1695 cfg.writeEntry( "Mute",b); 1695 cfg.writeEntry( "Mute",b);
1696 cfg.write(); 1696 cfg.write();
1697 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; 1697 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b;
1698} 1698}
1699 1699
1700void QtRec::doMicMuting(bool b) { 1700void QtRec::doMicMuting(bool b) {
1701 // odebug << "mic mute" << oendl; 1701 // odebug << "mic mute" << oendl;
1702 Config cfg( "qpe" ); 1702 Config cfg( "qpe" );
1703 cfg. setGroup( "Volume" ); 1703 cfg. setGroup( "Volume" );
1704 cfg.writeEntry( "MicMute",b); 1704 cfg.writeEntry( "MicMute",b);
1705 cfg.write(); 1705 cfg.write();
1706 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; 1706 QCopEnvelope( "QPE/System", "micChange(bool)" ) << b;
1707} 1707}
1708 1708
1709void QtRec::compressionSelected(bool b) { 1709void QtRec::compressionSelected(bool b) {
1710 Config cfg("OpieRec"); 1710 Config cfg("OpieRec");
1711 cfg.setGroup("Settings"); 1711 cfg.setGroup("Settings");
1712 cfg.writeEntry("wavCompression", b); 1712 cfg.writeEntry("wavCompression", b);
1713 cfg.writeEntry("bitrate", 16); 1713 cfg.writeEntry("bitrate", 16);
1714 filePara.resolution = 16; 1714 filePara.resolution = 16;
1715 cfg.write(); 1715 cfg.write();
1716 1716
1717 if(b) { 1717 if(b) {
1718 qWarning("set adpcm"); 1718 qWarning("set adpcm");
1719 bitRateComboBox->setCurrentItem( 1); 1719 bitRateComboBox->setCurrentItem( 1);
1720 bitRateComboBox->setEnabled( false); 1720 bitRateComboBox->setEnabled( false);
1721 filePara.resolution = 16; 1721 filePara.resolution = 16;
1722 } else{ 1722 } else{
1723 bitRateComboBox->setEnabled( true); 1723 bitRateComboBox->setEnabled( true);
1724 } 1724 }
1725} 1725}
1726 1726
1727long QtRec::checkDiskSpace(const QString &path) { 1727long QtRec::checkDiskSpace(const QString &path) {
1728 1728
1729 struct statfs fs; 1729 struct statfs fs;
1730 1730
1731 if ( !statfs( path.latin1(), &fs ) ) { 1731 if ( !statfs( path.latin1(), &fs ) ) {
1732 1732
1733 int blkSize = fs.f_bsize; 1733 int blkSize = fs.f_bsize;
1734 int availBlks = fs.f_bavail; 1734 int availBlks = fs.f_bavail;
1735 1735
1736 long mult = blkSize / 1024; 1736 long mult = blkSize / 1024;
1737 long div = 1024 / blkSize; 1737 long div = 1024 / blkSize;
1738 1738
1739 if ( !mult ) mult = 1; 1739 if ( !mult ) mult = 1;
1740 if ( !div ) div = 1; 1740 if ( !div ) div = 1;
1741 1741
1742 return availBlks * mult / div; 1742 return availBlks * mult / div;
1743 } 1743 }
1744 return -1; 1744 return -1;
1745} 1745}
1746 1746
1747// short f_fstyp; /* File system type */ 1747// short f_fstyp; /* File system type */
1748// long f_bsize; /* Block size */ 1748// long f_bsize; /* Block size */
1749// long f_frsize; /* Fragment size */ 1749// long f_frsize; /* Fragment size */
1750// long f_blocks; /* Total number of blocks*/ 1750// long f_blocks; /* Total number of blocks*/
1751// long f_bfree; /* Count of free blocks */ 1751// long f_bfree; /* Count of free blocks */
1752// long f_files; /* Total number of file nodes */ 1752// long f_files; /* Total number of file nodes */
1753// long f_ffree; /* Count of free file nodes */ 1753// long f_ffree; /* Count of free file nodes */
1754// char f_fname[6]; /* Volumename */ 1754// char f_fname[6]; /* Volumename */
1755// char f_fpack[6]; /* Pack name */ 1755// char f_fpack[6]; /* Pack name */
1756 1756
1757void QtRec::receive( const QCString &msg, const QByteArray & ) { 1757void QtRec::receive( const QCString &msg, const QByteArray & ) {
1758 odebug << "Voicerecord received message "+msg << oendl; 1758 odebug << "Voicerecord received message "+msg << oendl;
1759 1759
1760} 1760}
1761 1761
1762 1762
1763///////////////////////////// timerEvent 1763///////////////////////////// timerEvent
1764void QtRec::timerEvent( QTimerEvent * ) { 1764void QtRec::timerEvent( QTimerEvent * ) {
1765 1765
1766// if(!recording) 1766// if(!recording)
1767// timeSlider->setValue( secCount); 1767// timeSlider->setValue( secCount);
1768// else 1768// else
1769// timeSlider->setValue( filePara.numberOfRecordedSeconds); 1769// timeSlider->setValue( filePara.numberOfRecordedSeconds);
1770 1770
1771 if( stopped && playing) { 1771 if( stopped && playing) {
1772 stop(); 1772 stop();
1773 } 1773 }
1774 1774
1775 if( stopped && recording ){ 1775 if( stopped && recording ){
1776 stop(); 1776 stop();
1777 } 1777 }
1778 1778
1779 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { 1779 if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) {
1780 stop(); 1780 stop();
1781 } 1781 }
1782 1782
1783 odebug << "" << secCount << "" << oendl; 1783 odebug << "" << secCount << "" << oendl;
1784 QString timeString; 1784 QString timeString;
1785 1785
1786 timeString.sprintf("%d", secCount); 1786 timeString.sprintf("%d", secCount);
1787 // timeLabel->setText( timeString + " seconds"); 1787 // timeLabel->setText( timeString + " seconds");
1788 1788
1789 secCount++; 1789 secCount++;
1790} 1790}
1791 1791
1792void QtRec::changeTimeSlider(int index) { 1792void QtRec::changeTimeSlider(int index) {
1793 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; 1793 if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return;
1794 odebug << "Slider moved to " << index << "" << oendl; 1794 odebug << "Slider moved to " << index << "" << oendl;
1795 paused = true; 1795 paused = true;
1796 stopped = true; 1796 stopped = true;
1797 1797
1798 sliderPos=index; 1798 sliderPos=index;
1799 1799
1800 QString timeString; 1800 QString timeString;
1801 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1801 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1802 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1802 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1803 secCount = (int)filePara.numberOfRecordedSeconds; 1803 secCount = (int)filePara.numberOfRecordedSeconds;
1804 // timeLabel->setText( timeString + tr(" seconds")); 1804 // timeLabel->setText( timeString + tr(" seconds"));
1805} 1805}
1806 1806
1807void QtRec::timeSliderPressed() { 1807void QtRec::timeSliderPressed() {
1808 if( ListView1->currentItem() == 0) return; 1808 if( ListView1->currentItem() == 0) return;
1809 odebug << "slider pressed" << oendl; 1809 odebug << "slider pressed" << oendl;
1810 paused = true; 1810 paused = true;
1811 stopped = true; 1811 stopped = true;
1812} 1812}
1813 1813
1814void QtRec::timeSliderReleased() { 1814void QtRec::timeSliderReleased() {
1815 if( ListView1->currentItem() == 0) return; 1815 if( ListView1->currentItem() == 0) return;
1816 sliderPos = timeSlider->value(); 1816 sliderPos = timeSlider->value();
1817 1817
1818 odebug << "slider released " << sliderPos << "" << oendl; 1818 odebug << "slider released " << sliderPos << "" << oendl;
1819 stopped = false; 1819 stopped = false;
1820 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1820 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1821 total = newPos*4; 1821 total = newPos*4;
1822 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1822 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1823 1823
1824 doPlay(); 1824 doPlay();
1825} 1825}
1826 1826
1827void QtRec::rewindPressed() { 1827void QtRec::rewindPressed() {
1828 if( ListView1->currentItem() == 0) return; 1828 if( ListView1->currentItem() == 0) return;
1829 if( !wavFile->track.isOpen()) { 1829 if( !wavFile->track.isOpen()) {
1830 if( !openPlayFile() ) 1830 if( !openPlayFile() )
1831 return; 1831 return;
1832 else 1832 else
1833 if( !setupAudio( false)) 1833 if( !setupAudio( false))
1834 return; 1834 return;
1835 } else { 1835 } else {
1836 killTimers(); 1836 killTimers();
1837 paused = true; 1837 paused = true;
1838 stopped = true; 1838 stopped = true;
1839 rewindTimer->start( 50, false); 1839 rewindTimer->start( 50, false);
1840 } 1840 }
1841} 1841}
1842 1842
1843void QtRec::rewindTimerTimeout() { 1843void QtRec::rewindTimerTimeout() {
1844 int sliderValue = timeSlider->value(); 1844 int sliderValue = timeSlider->value();
1845 sliderValue = sliderValue - ( filePara.numberSamples / 100); 1845 sliderValue = sliderValue - ( filePara.numberSamples / 100);
1846 // if(toBeginningButton->isDown()) 1846 // if(toBeginningButton->isDown())
1847 timeSlider->setValue( sliderValue ) ; 1847 timeSlider->setValue( sliderValue ) ;
1848 odebug << "" << sliderValue << "" << oendl; 1848 odebug << "" << sliderValue << "" << oendl;
1849 QString timeString; 1849 QString timeString;
1850 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1850 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1851 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1851 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1852 // timeLabel->setText( timeString+ tr(" seconds")); 1852 // timeLabel->setText( timeString+ tr(" seconds"));
1853} 1853}
1854 1854
1855void QtRec::rewindReleased() { 1855void QtRec::rewindReleased() {
1856 rewindTimer->stop(); 1856 rewindTimer->stop();
1857 if( wavFile->track.isOpen()) { 1857 if( wavFile->track.isOpen()) {
1858 sliderPos=timeSlider->value(); 1858 sliderPos=timeSlider->value();
1859 stopped = false; 1859 stopped = false;
1860 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1860 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1861 total = newPos * 4; 1861 total = newPos * 4;
1862 odebug << "rewind released " << total << "" << oendl; 1862 odebug << "rewind released " << total << "" << oendl;
1863 startTimer( 1000); 1863 startTimer( 1000);
1864 doPlay(); 1864 doPlay();
1865 } 1865 }
1866} 1866}
1867 1867
1868void QtRec::FastforwardPressed() { 1868void QtRec::FastforwardPressed() {
1869 if( ListView1->currentItem() == 0) return; 1869 if( ListView1->currentItem() == 0) return;
1870 if( !wavFile->track.isOpen()) 1870 if( !wavFile->track.isOpen())
1871 if( !openPlayFile() ) 1871 if( !openPlayFile() )
1872 return; 1872 return;
1873 else 1873 else
1874 if( !setupAudio( false)) 1874 if( !setupAudio( false))
1875 return; 1875 return;
1876 killTimers(); 1876 killTimers();
1877 1877
1878 paused = true; 1878 paused = true;
1879 stopped = true; 1879 stopped = true;
1880 forwardTimer->start(50, false); 1880 forwardTimer->start(50, false);
1881} 1881}
1882 1882
1883 1883
1884void QtRec::forwardTimerTimeout() { 1884void QtRec::forwardTimerTimeout() {
1885 int sliderValue = timeSlider->value(); 1885 int sliderValue = timeSlider->value();
1886 sliderValue = sliderValue + ( filePara.numberSamples / 100); 1886 sliderValue = sliderValue + ( filePara.numberSamples / 100);
1887 1887
1888 // if(toEndButton->isDown()) 1888 // if(toEndButton->isDown())
1889 timeSlider->setValue( sliderValue); 1889 timeSlider->setValue( sliderValue);
1890 1890
1891 QString timeString; 1891 QString timeString;
1892 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; 1892 filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2;
1893 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); 1893 timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds);
1894 // timeLabel->setText( timeString+ tr(" seconds")); 1894 // timeLabel->setText( timeString+ tr(" seconds"));
1895} 1895}
1896 1896
1897void QtRec::FastforwardReleased() { 1897void QtRec::FastforwardReleased() {
1898 forwardTimer->stop(); 1898 forwardTimer->stop();
1899 if( wavFile->track.isOpen()) { 1899 if( wavFile->track.isOpen()) {
1900 sliderPos=timeSlider->value(); 1900 sliderPos=timeSlider->value();
1901 stopped = false; 1901 stopped = false;
1902 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); 1902 int newPos = lseek( filePara.fd, sliderPos, SEEK_SET);
1903 total = newPos * 4; 1903 total = newPos * 4;
1904 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; 1904 filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2;
1905 startTimer( 1000); 1905 startTimer( 1000);
1906 doPlay(); 1906 doPlay();
1907 } 1907 }
1908} 1908}
1909 1909
1910 1910
1911QString QtRec::getStorage(const QString &fileName) { 1911QString QtRec::getStorage(const QString &fileName) {
1912 1912
1913 StorageInfo storageInfo; 1913 StorageInfo storageInfo;
1914 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1914 const QList<FileSystem> &fs = storageInfo.fileSystems();
1915 QListIterator<FileSystem> it ( fs ); 1915 QListIterator<FileSystem> it ( fs );
1916 QString storage; 1916 QString storage;
1917 for( ; it.current(); ++it ){ 1917 for( ; it.current(); ++it ){
1918 const QString name = ( *it)->name(); 1918 const QString name = ( *it)->name();
1919 const QString path = ( *it)->path(); 1919 const QString path = ( *it)->path();
1920 const QString disk = ( *it)->disk(); 1920 const QString disk = ( *it)->disk();
1921 if( fileName.find( path,0,true) != -1) 1921 if( fileName.find( path,0,true) != -1)
1922 storage = name; 1922 storage = name;
1923 // const QString options = (*it)->options(); 1923 // const QString options = (*it)->options();
1924 // if( name.find( tr("Internal"),0,true) == -1) { 1924 // if( name.find( tr("Internal"),0,true) == -1) {
1925 // storageComboBox->insertItem( name +" -> "+disk); 1925 // storageComboBox->insertItem( name +" -> "+disk);
1926 // odebug << name << oendl; 1926 // odebug << name << oendl;
1927 } 1927 }
1928 return storage; 1928 return storage;
1929 // struct mntent *me; 1929 // struct mntent *me;
1930 // // if(fileName == "/etc/mtab") { 1930 // // if(fileName == "/etc/mtab") {
1931 // FILE *mntfp = setmntent( fileName.latin1(), "r" ); 1931 // FILE *mntfp = setmntent( fileName.latin1(), "r" );
1932 // if ( mntfp ) { 1932 // if ( mntfp ) {
1933 // while ( (me = getmntent( mntfp )) != 0 ) { 1933 // while ( (me = getmntent( mntfp )) != 0 ) {
1934 // QString filesystemType = me->mnt_type; 1934 // QString filesystemType = me->mnt_type;
1935 1935
1936 // } 1936 // }
1937 // } 1937 // }
1938 // endmntent( mntfp ); 1938 // endmntent( mntfp );
1939} 1939}
1940 1940
1941void QtRec::setRecordButton(bool b) { 1941void QtRec::setRecordButton(bool b) {
1942 1942
1943 if(b) { //about to record or play 1943 if(b) { //about to record or play
1944 1944
1945 Rec_PushButton->setDown( true); 1945 Rec_PushButton->setDown( true);
1946 QPixmap image3( ( const char** ) image3_data ); 1946 QPixmap image3( ( const char** ) image3_data );
1947 Stop_PushButton->setPixmap( image3 ); 1947 Stop_PushButton->setPixmap( image3 );
1948 if(Stop_PushButton->isDown()) 1948 if(Stop_PushButton->isDown())
1949 Stop_PushButton->setDown( true); 1949 Stop_PushButton->setDown( true);
1950 // playLabel2->setText( tr("Stop") ); 1950 // playLabel2->setText( tr("Stop") );
1951 1951
1952 } else { //about to stop 1952 } else { //about to stop
1953 1953
1954 QPixmap image4( ( const char** ) image4_data ); 1954 QPixmap image4( ( const char** ) image4_data );
1955 Stop_PushButton->setPixmap( image4); 1955 Stop_PushButton->setPixmap( image4);
1956 if(Stop_PushButton->isDown()) 1956 if(Stop_PushButton->isDown())
1957 Stop_PushButton->setDown( false); 1957 Stop_PushButton->setDown( false);
1958 // playLabel2->setText( tr("Play") ); 1958 // playLabel2->setText( tr("Play") );
1959 if(Rec_PushButton->isDown()) 1959 if(Rec_PushButton->isDown())
1960 Rec_PushButton->setDown( false); 1960 Rec_PushButton->setDown( false);
1961 } 1961 }
1962} 1962}
1963 1963
1964void QtRec::fillDirectoryCombo() { 1964void QtRec::fillDirectoryCombo() {
1965 if( directoryComboBox->count() > 0) 1965 if( directoryComboBox->count() > 0)
1966 directoryComboBox->clear(); 1966 directoryComboBox->clear();
1967 int index = 0; 1967 int index = 0;
1968 Config cfg("OpieRec"); 1968 Config cfg("OpieRec");
1969 cfg.setGroup("Settings"); 1969 cfg.setGroup("Settings");
1970 QString dir = cfg.readEntry("directory", "/"); 1970 QString dir = cfg.readEntry("directory", "/");
1971 StorageInfo storageInfo; 1971 StorageInfo storageInfo;
1972 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1972 const QList<FileSystem> &fs = storageInfo.fileSystems();
1973 QListIterator<FileSystem> it ( fs ); 1973 QListIterator<FileSystem> it ( fs );
1974 QString storage; 1974 QString storage;
1975 for( ; it.current(); ++it ){ 1975 for( ; it.current(); ++it ){
1976 const QString name = ( *it)->name(); 1976 const QString name = ( *it)->name();
1977 const QString path = ( *it)->path(); 1977 const QString path = ( *it)->path();
1978 // directoryComboBox->insertItem(name+" "+path); 1978 // directoryComboBox->insertItem(name+" "+path);
1979 directoryComboBox->insertItem(name); 1979 directoryComboBox->insertItem(name);
1980 if( path == dir) 1980 if( path == dir)
1981 directoryComboBox->setCurrentItem( index); 1981 directoryComboBox->setCurrentItem( index);
1982 index++; 1982 index++;
1983 } 1983 }
1984} 1984}
1985 1985
1986void QtRec::errorStop() { 1986void QtRec::errorStop() {
1987 stopped = true; 1987 stopped = true;
1988 wavFile->closeFile(); 1988 wavFile->closeFile();
1989 killTimers(); 1989 killTimers();
1990} 1990}
1991 1991
1992void QtRec::doMute(bool b) { 1992void QtRec::doMute(bool b) {
1993 doVolMuting( b); 1993 doVolMuting( b);
1994 doMicMuting( b); 1994 doMicMuting( b);
1995} 1995}
1996 1996
1997void QtRec::slotAutoMute(bool b) { 1997void QtRec::slotAutoMute(bool b) {
1998 autoMute = b; 1998 autoMute = b;
1999 Config cfg("OpieRec"); 1999 Config cfg("OpieRec");
2000 cfg.setGroup("Settings"); 2000 cfg.setGroup("Settings");
2001 cfg.writeEntry("useAutoMute",b); 2001 cfg.writeEntry("useAutoMute",b);
2002 doMute( b); 2002 doMute( b);
2003 outMuteCheckBox->setChecked( b); 2003 outMuteCheckBox->setChecked( b);
2004 inMuteCheckBox->setChecked( b); 2004 inMuteCheckBox->setChecked( b);
2005} 2005}
2006 2006
2007void QtRec::selectItemByName(const QString & name) { 2007void QtRec::selectItemByName(const QString & name) {
2008 QListViewItemIterator it( ListView1 ); 2008 QListViewItemIterator it( ListView1 );
2009 for ( ; it.current(); ++it ) 2009 for ( ; it.current(); ++it )
2010 if( name == it.current()->text(0)) 2010 if( name == it.current()->text(0))
2011 ListView1->setCurrentItem(it.current()); 2011 ListView1->setCurrentItem(it.current());
2012} 2012}
2013 2013
2014 2014
2015// long findPeak(long input ) { 2015// long findPeak(long input ) {
2016 2016
2017// // halfLife = time in seconds for output to decay to half value after an impulse 2017// // halfLife = time in seconds for output to decay to half value after an impulse
2018// static float output = 0.0; 2018// static float output = 0.0;
2019// float halfLife = .0025; 2019// float halfLife = .0025;
2020// float vsf = .0025; 2020// float vsf = .0025;
2021// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); 2021// float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate ));
2022// if( input < 0.0 ) 2022// if( input < 0.0 )
2023// input = -input; // Absolute value. 2023// input = -input; // Absolute value.
2024// if ( input >= output ) { 2024// if ( input >= output ) {
2025// // When we hit a peak, ride the peak to the top. 2025// // When we hit a peak, ride the peak to the top.
2026// output = input; 2026// output = input;
2027// } else { 2027// } else {
2028// // Exponential decay of output when signal is low. 2028// // Exponential decay of output when signal is low.
2029// output = output * scalar; 2029// output = output * scalar;
2030// // 2030// //
2031// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow 2031// // When current gets close to 0.0, set current to 0.0 to prevent FP underflow
2032// // which can cause a severe performance degradation due to a flood 2032// // which can cause a severe performance degradation due to a flood
2033// // of interrupts. 2033// // of interrupts.
2034// // 2034// //
2035// if( output < vsf ) output = 0.0; 2035// if( output < vsf ) output = 0.0;
2036// } 2036// }
2037 2037
2038// return (long) output; 2038// return (long) output;
2039// } 2039// }
2040 2040
2041void QtRec::changeStereoCheck(bool b) { 2041void QtRec::changeStereoCheck(bool b) {
2042 Config cfg("OpieRec"); 2042 Config cfg("OpieRec");
2043 cfg.setGroup("Settings"); 2043 cfg.setGroup("Settings");
2044 int ch = 0; 2044 int ch = 0;
2045 if ( !b) { ch = 1;} 2045 if ( !b) { ch = 1;}
2046 else { ch = 2;} 2046 else { ch = 2;}
2047 cfg.writeEntry("stereo", b); 2047 cfg.writeEntry("stereo", b);
2048 filePara.channels = ch; 2048 filePara.channels = ch;
2049 2049
2050 cfg.write(); 2050 cfg.write();
2051} 2051}
2052 2052
2053 2053