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