summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 2d694d2..7965b59 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -52,512 +52,515 @@ typedef struct _waveheader {
52#define RIFF 0x46464952 52#define RIFF 0x46464952
53#define WAVE 0x45564157 53#define WAVE 0x45564157
54#define FMT 0x20746D66 54#define FMT 0x20746D66
55#define DATA 0x61746164 55#define DATA 0x61746164
56#define PCM_CODE 1 56#define PCM_CODE 1
57#define WAVE_MONO 1 57#define WAVE_MONO 1
58#define WAVE_STEREO 2 58#define WAVE_STEREO 2
59 59
60#include "vmemo.h" 60#include "vmemo.h"
61 61
62#include <qpe/qpeapplication.h> 62#include <qpe/qpeapplication.h>
63#include <qpe/resource.h> 63#include <qpe/resource.h>
64#include <qpe/config.h> 64#include <qpe/config.h>
65 65
66#include <qpainter.h> 66#include <qpainter.h>
67#include <qdatetime.h> 67#include <qdatetime.h>
68#include <qregexp.h> 68#include <qregexp.h>
69#include <qsound.h> 69#include <qsound.h>
70#include <qfile.h> 70#include <qfile.h>
71#include <qmessagebox.h> 71#include <qmessagebox.h>
72 72
73int seq = 0; 73int seq = 0;
74 74
75/* XPM */ 75/* XPM */
76static char * vmemo_xpm[] = { 76static char * vmemo_xpm[] = {
77 "16 16 102 2", 77 "16 16 102 2",
78 " c None", 78 " c None",
79 ". c #60636A", 79 ". c #60636A",
80 "+ c #6E6E72", 80 "+ c #6E6E72",
81 "@ c #68696E", 81 "@ c #68696E",
82 "# c #4D525C", 82 "# c #4D525C",
83 "$ c #6B6C70", 83 "$ c #6B6C70",
84 "% c #E3E3E8", 84 "% c #E3E3E8",
85 "& c #EEEEF2", 85 "& c #EEEEF2",
86 "* c #EAEAEF", 86 "* c #EAEAEF",
87 "= c #CACAD0", 87 "= c #CACAD0",
88 "- c #474A51", 88 "- c #474A51",
89 "; c #171819", 89 "; c #171819",
90 "> c #9B9B9F", 90 "> c #9B9B9F",
91 ", c #EBEBF0", 91 ", c #EBEBF0",
92 "' c #F4F4F7", 92 "' c #F4F4F7",
93 ") c #F1F1F5", 93 ") c #F1F1F5",
94 "! c #DEDEE4", 94 "! c #DEDEE4",
95 "~ c #57575C", 95 "~ c #57575C",
96 "{ c #010101", 96 "{ c #010101",
97 "] c #A2A2A6", 97 "] c #A2A2A6",
98 "^ c #747477", 98 "^ c #747477",
99 "/ c #B5B5B8", 99 "/ c #B5B5B8",
100 "( c #AEAEB2", 100 "( c #AEAEB2",
101 "_ c #69696D", 101 "_ c #69696D",
102 ": c #525256", 102 ": c #525256",
103 "< c #181C24", 103 "< c #181C24",
104 "[ c #97979B", 104 "[ c #97979B",
105 "} c #A7A7AC", 105 "} c #A7A7AC",
106 "| c #B0B0B4", 106 "| c #B0B0B4",
107 "1 c #C8C8D1", 107 "1 c #C8C8D1",
108 "2 c #75757B", 108 "2 c #75757B",
109 "3 c #46464A", 109 "3 c #46464A",
110 "4 c #494A4F", 110 "4 c #494A4F",
111 "5 c #323234", 111 "5 c #323234",
112 "6 c #909095", 112 "6 c #909095",
113 "7 c #39393B", 113 "7 c #39393B",
114 "8 c #757578", 114 "8 c #757578",
115 "9 c #87878E", 115 "9 c #87878E",
116 "0 c #222224", 116 "0 c #222224",
117 "a c #414144", 117 "a c #414144",
118 "b c #6A6A6E", 118 "b c #6A6A6E",
119 "c c #020C16", 119 "c c #020C16",
120 "d c #6B6B6F", 120 "d c #6B6B6F",
121 "e c #68686D", 121 "e c #68686D",
122 "f c #5B5B60", 122 "f c #5B5B60",
123 "g c #8A8A8F", 123 "g c #8A8A8F",
124 "h c #6B6B6E", 124 "h c #6B6B6E",
125 "i c #ADADB2", 125 "i c #ADADB2",
126 "j c #828289", 126 "j c #828289",
127 "k c #3E3E41", 127 "k c #3E3E41",
128 "l c #CFCFD7", 128 "l c #CFCFD7",
129 "m c #4C4C50", 129 "m c #4C4C50",
130 "n c #000000", 130 "n c #000000",
131 "o c #66666A", 131 "o c #66666A",
132 "p c #505054", 132 "p c #505054",
133 "q c #838388", 133 "q c #838388",
134 "r c #A1A1A7", 134 "r c #A1A1A7",
135 "s c #A9A9AE", 135 "s c #A9A9AE",
136 "t c #A8A8B0", 136 "t c #A8A8B0",
137 "u c #5E5E63", 137 "u c #5E5E63",
138 "v c #3A3A3E", 138 "v c #3A3A3E",
139 "w c #BDBDC6", 139 "w c #BDBDC6",
140 "x c #59595E", 140 "x c #59595E",
141 "y c #76767C", 141 "y c #76767C",
142 "z c #373738", 142 "z c #373738",
143 "A c #717174", 143 "A c #717174",
144 "B c #727278", 144 "B c #727278",
145 "C c #1C1C1E", 145 "C c #1C1C1E",
146 "D c #3C3C3F", 146 "D c #3C3C3F",
147 "E c #ADADB6", 147 "E c #ADADB6",
148 "F c #54555A", 148 "F c #54555A",
149 "G c #8B8C94", 149 "G c #8B8C94",
150 "H c #5A5A5F", 150 "H c #5A5A5F",
151 "I c #BBBBC3", 151 "I c #BBBBC3",
152 "J c #C4C4CB", 152 "J c #C4C4CB",
153 "K c #909098", 153 "K c #909098",
154 "L c #737379", 154 "L c #737379",
155 "M c #343437", 155 "M c #343437",
156 "N c #8F8F98", 156 "N c #8F8F98",
157 "O c #000407", 157 "O c #000407",
158 "P c #2D3137", 158 "P c #2D3137",
159 "Q c #B0B1BC", 159 "Q c #B0B1BC",
160 "R c #3B3C40", 160 "R c #3B3C40",
161 "S c #6E6E74", 161 "S c #6E6E74",
162 "T c #95959C", 162 "T c #95959C",
163 "U c #74747A", 163 "U c #74747A",
164 "V c #1D1D1E", 164 "V c #1D1D1E",
165 "W c #91929A", 165 "W c #91929A",
166 "X c #42444A", 166 "X c #42444A",
167 "Y c #22282E", 167 "Y c #22282E",
168 "Z c #B0B2BC", 168 "Z c #B0B2BC",
169 "` c #898A90", 169 "` c #898A90",
170 " . c #65656A", 170 " . c #65656A",
171 ".. c #999AA2", 171 ".. c #999AA2",
172 "+. c #52535A", 172 "+. c #52535A",
173 "@. c #151B21", 173 "@. c #151B21",
174 "#. c #515257", 174 "#. c #515257",
175 "$. c #B5B5BE", 175 "$. c #B5B5BE",
176 "%. c #616167", 176 "%. c #616167",
177 "&. c #1A1D22", 177 "&. c #1A1D22",
178 "*. c #000713", 178 "*. c #000713",
179 "=. c #1F1F21", 179 "=. c #1F1F21",
180 " ", 180 " ",
181 " . + @ # ", 181 " . + @ # ",
182 " $ % & * = - ", 182 " $ % & * = - ",
183 " ; > , ' ) ! ~ ", 183 " ; > , ' ) ! ~ ",
184 " { ] ^ / ( _ : ", 184 " { ] ^ / ( _ : ",
185 " < [ } | 1 2 3 ", 185 " < [ } | 1 2 3 ",
186 " 4 5 6 7 8 9 0 a b c ", 186 " 4 5 6 7 8 9 0 a b c ",
187 " d e f g h i j 3 k l m n ", 187 " d e f g h i j 3 k l m n ",
188 " o p q r s t u v w n ", 188 " o p q r s t u v w n ",
189 " o x y z A B C D E n ", 189 " o x y z A B C D E n ",
190 " F G H I J K L M N O ", 190 " F G H I J K L M N O ",
191 " P Q R S T U V W X ", 191 " P Q R S T U V W X ",
192 " Y Z ` b ...+. ", 192 " Y Z ` b ...+. ",
193 " @.#.$.%.&. ", 193 " @.#.$.%.&. ",
194 " *.B =. ", 194 " *.B =. ",
195 " n n n n n n n n n "}; 195 " n n n n n n n n n "};
196 196
197 197
198VMemo::VMemo( QWidget *parent, const char *_name ) 198VMemo::VMemo( QWidget *parent, const char *_name )
199 : QWidget( parent, _name ) 199 : QWidget( parent, _name )
200{ 200{
201 setFixedHeight( 18 ); 201 setFixedHeight( 18 );
202 setFixedWidth( 14 ); 202 setFixedWidth( 14 );
203 203
204 recording = FALSE; 204 recording = FALSE;
205 205
206 t_timer = new QTimer( this ); 206 t_timer = new QTimer( this );
207 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 207 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
208 208
209 struct utsname name; /* check for embedix kernel running on the zaurus*/ 209 struct utsname name; /* check for embedix kernel running on the zaurus*/
210 if (uname(&name) != -1) { 210 if (uname(&name) != -1) {
211 QString release=name.release; 211 QString release=name.release;
212 212
213 Config vmCfg("Vmemo"); 213 Config vmCfg("Vmemo");
214 vmCfg.setGroup("Defaults"); 214 vmCfg.setGroup("Defaults");
215 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 215 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
216 216
217 qDebug("toggleKey %d", toggleKey); 217 qDebug("toggleKey %d", toggleKey);
218 218
219 if(release.find("embedix",0,TRUE) !=-1) 219 if(release.find("embedix",0,TRUE) !=-1)
220 systemZaurus=TRUE; 220 systemZaurus=TRUE;
221 else 221 else
222 systemZaurus=FALSE; 222 systemZaurus=FALSE;
223 223
224 myChannel = new QCopChannel( "QPE/VMemo", this ); 224 myChannel = new QCopChannel( "QPE/VMemo", this );
225 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 225 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
226 this, SLOT(receive(const QCString&, const QByteArray&)) ); 226 this, SLOT(receive(const QCString&, const QByteArray&)) );
227 227
228 if( toggleKey != -1 ) { 228 if( toggleKey != -1 ) {
229 // QPEApplication::grabKeyboard(); 229 // QPEApplication::grabKeyboard();
230 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 230 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
231 // e << 4096; // Key_Escape 231 // e << 4096; // Key_Escape
232 // e << Key_F5; //4148 232 // e << Key_F5; //4148
233 e << toggleKey; 233 e << toggleKey;
234 e << QString("QPE/VMemo"); 234 e << QString("QPE/VMemo");
235 e << QString("toggleRecord()"); 235 e << QString("toggleRecord()");
236 } 236 }
237 237
238 if( vmCfg.readNumEntry("hideIcon",0) == 1) 238 if( vmCfg.readNumEntry("hideIcon",0) == 1)
239 hide(); 239 hide();
240 } 240 }
241} 241}
242 242
243VMemo::~VMemo() 243VMemo::~VMemo()
244{ 244{
245} 245}
246 246
247void VMemo::receive( const QCString &msg, const QByteArray &data ) 247void VMemo::receive( const QCString &msg, const QByteArray &data )
248{ 248{
249 qDebug("receive"); 249 qDebug("receive");
250 QDataStream stream( data, IO_ReadOnly ); 250 QDataStream stream( data, IO_ReadOnly );
251 if (msg == "toggleRecord()") { 251 if (msg == "toggleRecord()") {
252 if (recording) { 252 if (recording) {
253 fromToggle = TRUE; 253 fromToggle = TRUE;
254 stopRecording(); 254 stopRecording();
255 } else { 255 } else {
256 fromToggle = TRUE; 256 fromToggle = TRUE;
257 startRecording(); 257 startRecording();
258 } 258 }
259 } 259 }
260} 260}
261 261
262void VMemo::paintEvent( QPaintEvent* ) 262void VMemo::paintEvent( QPaintEvent* )
263{ 263{
264 QPainter p(this); 264 QPainter p(this);
265 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 265 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
266} 266}
267 267
268void VMemo::mousePressEvent( QMouseEvent * ) 268void VMemo::mousePressEvent( QMouseEvent * )
269{ 269{
270 startRecording(); 270 startRecording();
271} 271}
272 272
273void VMemo::mouseReleaseEvent( QMouseEvent * ) 273void VMemo::mouseReleaseEvent( QMouseEvent * )
274{ 274{
275 stopRecording(); 275 stopRecording();
276} 276}
277 277
278bool VMemo::startRecording() { 278bool VMemo::startRecording() {
279 279
280 if ( recording) 280 if ( recording)
281 return FALSE; 281 return FALSE;
282 282
283 Config config( "Vmemo" ); 283 Config config( "Vmemo" );
284 config.setGroup( "System" ); 284 config.setGroup( "System" );
285 285
286 useAlerts = config.readBoolEntry("Alert"); 286 useAlerts = config.readBoolEntry("Alert");
287 if(useAlerts) { 287 if(useAlerts) {
288 288
289 msgLabel = new QLabel( 0, "alertLabel" ); 289 msgLabel = new QLabel( 0, "alertLabel" );
290 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 290 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
291 msgLabel->show(); 291 msgLabel->show();
292 } 292 }
293 293
294 // if(useAlerts) 294 // if(useAlerts)
295 // QMessageBox::message("VMemo","Really Record?");//) ==1) 295 // QMessageBox::message("VMemo","Really Record?");//) ==1)
296 // return; 296 // return;
297 // } else { 297 // } else {
298 // if (!systemZaurus ) 298 // if (!systemZaurus )
299 // QSound::play(Resource::findSound("vmemob")); 299 // QSound::play(Resource::findSound("vmemob"));
300 // } 300 // }
301 qDebug("Start recording engines"); 301 qDebug("Start recording engines");
302 recording = TRUE; 302 recording = TRUE;
303 303
304 if (openDSP() == -1) { 304 if (openDSP() == -1) {
305 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 305 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
306 // delete msgLabel; 306 // delete msgLabel;
307 recording = FALSE; 307 recording = FALSE;
308 msgLabel=0;
309 delete msgLabel;
310
308 return FALSE; 311 return FALSE;
309 } 312 }
310 313
311 config.setGroup("Defaults"); 314 config.setGroup("Defaults");
312 315
313 QDateTime dt = QDateTime::currentDateTime(); 316 QDateTime dt = QDateTime::currentDateTime();
314 317
315 QString fName; 318 QString fName;
316 config.setGroup( "System" ); 319 config.setGroup( "System" );
317 fName = QPEApplication::documentDir() ; 320 fName = QPEApplication::documentDir() ;
318 fileName = config.readEntry("RecLocation", fName); 321 fileName = config.readEntry("RecLocation", fName);
319 322
320 int s; 323 int s;
321 s=fileName.find(':'); 324 s=fileName.find(':');
322 if(s) 325 if(s)
323 fileName=fileName.right(fileName.length()-s-2); 326 fileName=fileName.right(fileName.length()-s-2);
324 qDebug("pathname will be "+fileName); 327 qDebug("pathname will be "+fileName);
325 328
326 if( fileName.left(1).find('/') == -1) 329 if( fileName.left(1).find('/') == -1)
327 fileName="/"+fileName; 330 fileName="/"+fileName;
328 if( fileName.right(1).find('/') == -1) 331 if( fileName.right(1).find('/') == -1)
329 fileName+="/"; 332 fileName+="/";
330 fName = "vm_"+ dt.toString()+ ".wav"; 333 fName = "vm_"+ dt.toString()+ ".wav";
331 334
332 fileName+=fName; 335 fileName+=fName;
333 qDebug("filename is "+fileName); 336 qDebug("filename is "+fileName);
334 // No spaces in the filename 337 // No spaces in the filename
335 fileName.replace(QRegExp("'"),""); 338 fileName.replace(QRegExp("'"),"");
336 fileName.replace(QRegExp(" "),"_"); 339 fileName.replace(QRegExp(" "),"_");
337 fileName.replace(QRegExp(":"),"."); 340 fileName.replace(QRegExp(":"),".");
338 fileName.replace(QRegExp(","),""); 341 fileName.replace(QRegExp(","),"");
339 342
340 if(openWAV(fileName.latin1()) == -1) { 343 if(openWAV(fileName.latin1()) == -1) {
341 // QString err("Could not open the output file\n"); 344 // QString err("Could not open the output file\n");
342 // err += fileName; 345 // err += fileName;
343 // QMessageBox::critical(0, "vmemo", err, "Abort"); 346 // QMessageBox::critical(0, "vmemo", err, "Abort");
344 close(dsp); 347 close(dsp);
345 return FALSE; 348 return FALSE;
346 } 349 }
347 350
348 QArray<int> cats(1); 351 QArray<int> cats(1);
349 cats[0] = config.readNumEntry("Category", 0); 352 cats[0] = config.readNumEntry("Category", 0);
350 353
351 QString dlName("vm_"); 354 QString dlName("vm_");
352 dlName += dt.toString(); 355 dlName += dt.toString();
353 DocLnk l; 356 DocLnk l;
354 l.setFile(fileName); 357 l.setFile(fileName);
355 l.setName(dlName); 358 l.setName(dlName);
356 l.setType("audio/x-wav"); 359 l.setType("audio/x-wav");
357 l.setCategories(cats); 360 l.setCategories(cats);
358 l.writeLink(); 361 l.writeLink();
359 362
360 363
361 record(); 364 record();
362 // delete msgLabel; 365 // delete msgLabel;
363 return TRUE; 366 return TRUE;
364} 367}
365 368
366void VMemo::stopRecording() { 369void VMemo::stopRecording() {
367show(); 370show();
368 qDebug("Stopped recording"); 371 qDebug("Stopped recording");
369 recording = FALSE; 372 recording = FALSE;
370 if(useAlerts) 373 if(useAlerts)
371 if( msgLabel) delete msgLabel; 374 if( msgLabel) delete msgLabel;
372 t_timer->stop(); 375 t_timer->stop();
373 Config cfg("Vmemo"); 376 Config cfg("Vmemo");
374 cfg.setGroup("Defaults"); 377 cfg.setGroup("Defaults");
375 if( cfg.readNumEntry("hideIcon",0) == 1 ) 378 if( cfg.readNumEntry("hideIcon",0) == 1 )
376 hide(); 379 hide();
377} 380}
378 381
379int VMemo::openDSP() 382int VMemo::openDSP()
380{ 383{
381 Config cfg("Vmemo"); 384 Config cfg("Vmemo");
382 cfg.setGroup("Record"); 385 cfg.setGroup("Record");
383 386
384 speed = cfg.readNumEntry("SampleRate", 22050); 387 speed = cfg.readNumEntry("SampleRate", 22050);
385 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 388 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
386 if (cfg.readNumEntry("SixteenBit", 1)==1) { 389 if (cfg.readNumEntry("SixteenBit", 1)==1) {
387 format = AFMT_S16_LE; 390 format = AFMT_S16_LE;
388 resolution = 16; 391 resolution = 16;
389 } else { 392 } else {
390 format = AFMT_U8; 393 format = AFMT_U8;
391 resolution = 8; 394 resolution = 8;
392 } 395 }
393 396
394 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 397 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
395 398
396 if(systemZaurus) { 399 if(systemZaurus) {
397 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 400 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1
398 channels=1; //zaurus has one input channel 401 channels=1; //zaurus has one input channel
399 } else { 402 } else {
400 dsp = open("/dev/dsp", O_RDONLY); 403 dsp = open("/dev/dsp", O_RDONLY);
401 } 404 }
402 405
403 if(dsp == -1) { 406 if(dsp == -1) {
404 perror("open(\"/dev/dsp\")"); 407 perror("open(\"/dev/dsp\")");
405 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 408 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
406 QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); 409 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
407 return -1; 410 return -1;
408 } 411 }
409 412
410 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 413 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
411 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 414 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
412 return -1; 415 return -1;
413 } 416 }
414 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 417 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
415 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 418 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
416 return -1; 419 return -1;
417 } 420 }
418 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 421 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
419 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 422 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
420 return -1; 423 return -1;
421 } 424 }
422 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 425 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
423 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 426 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
424 return -1; 427 return -1;
425 } 428 }
426 429
427 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute 430 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute
428 431
429 return 1; 432 return 1;
430} 433}
431 434
432int VMemo::openWAV(const char *filename) 435int VMemo::openWAV(const char *filename)
433{ 436{
434 track.setName(filename); 437 track.setName(filename);
435 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { 438 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
436 errorMsg=filename; 439 errorMsg=filename;
437 return -1; 440 return -1;
438 } 441 }
439 442
440 wav=track.handle(); 443 wav=track.handle();
441 444
442 WaveHeader wh; 445 WaveHeader wh;
443 446
444 wh.main_chunk = RIFF; 447 wh.main_chunk = RIFF;
445 wh.length=0; 448 wh.length=0;
446 wh.chunk_type = WAVE; 449 wh.chunk_type = WAVE;
447 wh.sub_chunk = FMT; 450 wh.sub_chunk = FMT;
448 wh.sc_len = 16; 451 wh.sc_len = 16;
449 wh.format = PCM_CODE; 452 wh.format = PCM_CODE;
450 wh.modus = channels; 453 wh.modus = channels;
451 wh.sample_fq = speed; 454 wh.sample_fq = speed;
452 wh.byte_p_sec = speed * channels * resolution/8; 455 wh.byte_p_sec = speed * channels * resolution/8;
453 wh.byte_p_spl = channels * (resolution / 8); 456 wh.byte_p_spl = channels * (resolution / 8);
454 wh.bit_p_spl = resolution; 457 wh.bit_p_spl = resolution;
455 wh.data_chunk = DATA; 458 wh.data_chunk = DATA;
456 wh.data_length= 0; 459 wh.data_length= 0;
457 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" 460 // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d"
458 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); 461 // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl );
459 write (wav, &wh, sizeof(WaveHeader)); 462 write (wav, &wh, sizeof(WaveHeader));
460 463
461 return 1; 464 return 1;
462} 465}
463 466
464void VMemo::record(void) 467void VMemo::record(void)
465{ 468{
466 int length=0, result, value; 469 int length=0, result, value;
467 QString msg; 470 QString msg;
468 msg.sprintf("Recording format %d", format); 471 msg.sprintf("Recording format %d", format);
469 qDebug(msg); 472 qDebug(msg);
470 Config config("Vmemo"); 473 Config config("Vmemo");
471 config.setGroup("Record"); 474 config.setGroup("Record");
472 int sRate=config.readNumEntry("SizeLimit", 30); 475 int sRate=config.readNumEntry("SizeLimit", 30);
473 476
474 t_timer->start( sRate * 1000+1000, TRUE); 477 t_timer->start( sRate * 1000+1000, TRUE);
475 478
476 if(systemZaurus) { 479 if(systemZaurus) {
477 480
478 msg.sprintf("Recording format zaurus"); 481 msg.sprintf("Recording format zaurus");
479 qDebug(msg); 482 qDebug(msg);
480 signed short sound[512], monoBuffer[512]; 483 signed short sound[512], monoBuffer[512];
481 484
482 if(format==AFMT_S16_LE) { 485 if(format==AFMT_S16_LE) {
483 486
484 487
485 488
486 while(recording) { 489 while(recording) {
487 490
488 result = read(dsp, sound, 512); // 8192 491 result = read(dsp, sound, 512); // 8192
489 // int j=0; 492 // int j=0;
490 493
491 for (int i = 0; i < result; i++) { //since Z is mono do normally 494 for (int i = 0; i < result; i++) { //since Z is mono do normally
492 monoBuffer[i] = sound[i]; 495 monoBuffer[i] = sound[i];
493 } 496 }
494 497
495 length+=write(wav, monoBuffer, result); 498 length+=write(wav, monoBuffer, result);
496 if(length<0) 499 if(length<0)
497 recording=false; 500 recording=false;
498 501
499 // for (int i = 0; i < result; i+=2) { 502 // for (int i = 0; i < result; i+=2) {
500 // monoBuffer[j] = sound[i]; 503 // monoBuffer[j] = sound[i];
501 // // monoBuffer[j] = (sound[i]+sound[i+1])/2; 504 // // monoBuffer[j] = (sound[i]+sound[i+1])/2;
502 505
503 // j++; 506 // j++;
504 // } 507 // }
505 qApp->processEvents(); 508 qApp->processEvents();
506 // printf("%d\r",length); 509 // printf("%d\r",length);
507 // fflush(stdout); 510 // fflush(stdout);
508 } 511 }
509 512
510 } else { //AFMT_U8 513 } else { //AFMT_U8
511 // 8bit unsigned 514 // 8bit unsigned
512 unsigned short sound[512], monoBuffer[512]; 515 unsigned short sound[512], monoBuffer[512];
513 while(recording) { 516 while(recording) {
514 result = read(dsp, sound, 512); // 8192 517 result = read(dsp, sound, 512); // 8192
515 // int j=0; 518 // int j=0;
516 519
517 // if(systemZaurus) { 520 // if(systemZaurus) {
518 521
519 for (int i = 0; i < result; i++) { //since Z is mono do normally 522 for (int i = 0; i < result; i++) { //since Z is mono do normally
520 monoBuffer[i] = sound[i]; 523 monoBuffer[i] = sound[i];
521 } 524 }
522 525
523 length+=write(wav, monoBuffer, result); 526 length+=write(wav, monoBuffer, result);
524 527
525 // for (int i = 0; i < result; i+=2) { 528 // for (int i = 0; i < result; i+=2) {
526 // monoBuffer[j] = (sound[i]+sound[i+1])/2; 529 // monoBuffer[j] = (sound[i]+sound[i+1])/2;
527 // j++; 530 // j++;
528 // } 531 // }
529 // length+=write(wav, monoBuffer, result/2); 532 // length+=write(wav, monoBuffer, result/2);
530 length += result; 533 length += result;
531 // printf("%d\r",length); 534 // printf("%d\r",length);
532 // fflush(stdout); 535 // fflush(stdout);
533 } 536 }
534 537
535 qApp->processEvents(); 538 qApp->processEvents();
536 } 539 }
537 540
538 } else { // 16 bit only capabilities 541 } else { // 16 bit only capabilities
539 542
540 543
541 msg.sprintf("Recording format other"); 544 msg.sprintf("Recording format other");
542 qDebug(msg); 545 qDebug(msg);
543 546
544 signed short sound[512];//, monoBuffer[512]; 547 signed short sound[512];//, monoBuffer[512];
545 548
546 while(recording) { 549 while(recording) {
547 550
548 result = read(dsp, sound, 512); // 8192 551 result = read(dsp, sound, 512); // 8192
549 552
550 write(wav, sound, result); 553 write(wav, sound, result);
551 length += result; 554 length += result;
552 if(length<0) { 555 if(length<0) {
553 556
554 recording=false; 557 recording=false;
555 perror("dev/dsp's is a lookin' messy"); 558 perror("dev/dsp's is a lookin' messy");
556 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 559 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
557 } 560 }
558 // printf("%d\r",length); 561 // printf("%d\r",length);
559 // fflush(stdout); 562 // fflush(stdout);
560 qApp->processEvents(); 563 qApp->processEvents();
561 } 564 }
562 // qDebug("file has length of %d lasting %d seconds", 565 // qDebug("file has length of %d lasting %d seconds",
563 // length, (( length / speed) / channels) / 2 ); 566 // length, (( length / speed) / channels) / 2 );