-rw-r--r-- | core/applets/vmemo/adpcm.c | 252 | ||||
-rw-r--r-- | core/applets/vmemo/adpcm.h | 19 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 134 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 2 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.pro | 4 |
5 files changed, 324 insertions, 87 deletions
diff --git a/core/applets/vmemo/adpcm.c b/core/applets/vmemo/adpcm.c new file mode 100644 index 0000000..c4dfa50 --- a/dev/null +++ b/core/applets/vmemo/adpcm.c | |||
@@ -0,0 +1,252 @@ | |||
1 | /*********************************************************** | ||
2 | Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The | ||
3 | Netherlands. | ||
4 | |||
5 | All Rights Reserved | ||
6 | |||
7 | Permission to use, copy, modify, and distribute this software and its | ||
8 | documentation for any purpose and without fee is hereby granted, | ||
9 | provided that the above copyright notice appear in all copies and that | ||
10 | both that copyright notice and this permission notice appear in | ||
11 | supporting documentation, and that the names of Stichting Mathematisch | ||
12 | Centrum or CWI not be used in advertising or publicity pertaining to | ||
13 | distribution of the software without specific, written prior permission. | ||
14 | |||
15 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | ||
16 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
17 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | ||
18 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
20 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | ||
21 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
22 | |||
23 | ******************************************************************/ | ||
24 | |||
25 | /* | ||
26 | ** Intel/DVI ADPCM coder/decoder. | ||
27 | ** | ||
28 | ** The algorithm for this coder was taken from the IMA Compatability Project | ||
29 | ** proceedings, Vol 2, Number 2; May 1992. | ||
30 | ** | ||
31 | ** Version 1.2, 18-Dec-92. | ||
32 | ** | ||
33 | ** Change log: | ||
34 | ** - Fixed a stupid bug, where the delta was computed as | ||
35 | ** stepsize*code/4 in stead of stepsize*(code+0.5)/4. | ||
36 | ** - There was an off-by-one error causing it to pick | ||
37 | ** an incorrect delta once in a blue moon. | ||
38 | ** - The NODIVMUL define has been removed. Computations are now always done | ||
39 | ** using shifts, adds and subtracts. It turned out that, because the standard | ||
40 | ** is defined using shift/add/subtract, you needed bits of fixup code | ||
41 | ** (because the div/mul simulation using shift/add/sub made some rounding | ||
42 | ** errors that real div/mul don't make) and all together the resultant code | ||
43 | ** ran slower than just using the shifts all the time. | ||
44 | ** - Changed some of the variable names to be more meaningful. | ||
45 | */ | ||
46 | |||
47 | #include "adpcm.h" | ||
48 | #include <stdio.h> /*DBG*/ | ||
49 | |||
50 | #ifndef __STDC__ | ||
51 | #define signed | ||
52 | #endif | ||
53 | |||
54 | /* Intel ADPCM step variation table */ | ||
55 | static int indexTable[16] = { | ||
56 | -1, -1, -1, -1, 2, 4, 6, 8, | ||
57 | -1, -1, -1, -1, 2, 4, 6, 8, | ||
58 | }; | ||
59 | |||
60 | static int stepsizeTable[89] = { | ||
61 | 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, | ||
62 | 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, | ||
63 | 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, | ||
64 | 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, | ||
65 | 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, | ||
66 | 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, | ||
67 | 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, | ||
68 | 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, | ||
69 | 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 | ||
70 | }; | ||
71 | |||
72 | void | ||
73 | adpcm_coder(indata, outdata, len, state) | ||
74 | short indata[]; | ||
75 | char outdata[]; | ||
76 | int len; | ||
77 | struct adpcm_state *state; | ||
78 | { | ||
79 | short *inp; /* Input buffer pointer */ | ||
80 | signed char *outp; /* output buffer pointer */ | ||
81 | int val; /* Current input sample value */ | ||
82 | int sign; /* Current adpcm sign bit */ | ||
83 | int delta; /* Current adpcm output value */ | ||
84 | int diff; /* Difference between val and valprev */ | ||
85 | int step; /* Stepsize */ | ||
86 | int valpred; /* Predicted output value */ | ||
87 | int vpdiff; /* Current change to valpred */ | ||
88 | int index; /* Current step change index */ | ||
89 | int outputbuffer; /* place to keep previous 4-bit value */ | ||
90 | int bufferstep; /* toggle between outputbuffer/output */ | ||
91 | |||
92 | outp = (signed char *)outdata; | ||
93 | inp = indata; | ||
94 | |||
95 | valpred = state->valprev; | ||
96 | index = state->index; | ||
97 | step = stepsizeTable[index]; | ||
98 | |||
99 | bufferstep = 1; | ||
100 | |||
101 | for ( ; len > 0 ; len-- ) { | ||
102 | val = *inp++; | ||
103 | |||
104 | /* Step 1 - compute difference with previous value */ | ||
105 | diff = val - valpred; | ||
106 | sign = (diff < 0) ? 8 : 0; | ||
107 | if ( sign ) diff = (-diff); | ||
108 | |||
109 | /* Step 2 - Divide and clamp */ | ||
110 | /* Note: | ||
111 | ** This code *approximately* computes: | ||
112 | ** delta = diff*4/step; | ||
113 | ** vpdiff = (delta+0.5)*step/4; | ||
114 | ** but in shift step bits are dropped. The net result of this is | ||
115 | ** that even if you have fast mul/div hardware you cannot put it to | ||
116 | ** good use since the fixup would be too expensive. | ||
117 | */ | ||
118 | delta = 0; | ||
119 | vpdiff = (step >> 3); | ||
120 | |||
121 | if ( diff >= step ) { | ||
122 | delta = 4; | ||
123 | diff -= step; | ||
124 | vpdiff += step; | ||
125 | } | ||
126 | step >>= 1; | ||
127 | if ( diff >= step ) { | ||
128 | delta |= 2; | ||
129 | diff -= step; | ||
130 | vpdiff += step; | ||
131 | } | ||
132 | step >>= 1; | ||
133 | if ( diff >= step ) { | ||
134 | delta |= 1; | ||
135 | vpdiff += step; | ||
136 | } | ||
137 | |||
138 | /* Step 3 - Update previous value */ | ||
139 | if ( sign ) | ||
140 | valpred -= vpdiff; | ||
141 | else | ||
142 | valpred += vpdiff; | ||
143 | |||
144 | /* Step 4 - Clamp previous value to 16 bits */ | ||
145 | if ( valpred > 32767 ) | ||
146 | valpred = 32767; | ||
147 | else if ( valpred < -32768 ) | ||
148 | valpred = -32768; | ||
149 | |||
150 | /* Step 5 - Assemble value, update index and step values */ | ||
151 | delta |= sign; | ||
152 | |||
153 | index += indexTable[delta]; | ||
154 | if ( index < 0 ) index = 0; | ||
155 | if ( index > 88 ) index = 88; | ||
156 | step = stepsizeTable[index]; | ||
157 | |||
158 | /* Step 6 - Output value */ | ||
159 | if ( bufferstep ) { | ||
160 | outputbuffer = (delta << 4) & 0xf0; | ||
161 | } else { | ||
162 | *outp++ = (delta & 0x0f) | outputbuffer; | ||
163 | } | ||
164 | bufferstep = !bufferstep; | ||
165 | } | ||
166 | |||
167 | /* Output last step, if needed */ | ||
168 | if ( !bufferstep ) | ||
169 | *outp++ = outputbuffer; | ||
170 | |||
171 | state->valprev = valpred; | ||
172 | state->index = index; | ||
173 | } | ||
174 | |||
175 | void | ||
176 | adpcm_decoder(indata, outdata, len, state) | ||
177 | char indata[]; | ||
178 | short outdata[]; | ||
179 | int len; | ||
180 | struct adpcm_state *state; | ||
181 | { | ||
182 | signed char *inp; /* Input buffer pointer */ | ||
183 | short *outp; /* output buffer pointer */ | ||
184 | int sign; /* Current adpcm sign bit */ | ||
185 | int delta; /* Current adpcm output value */ | ||
186 | int step; /* Stepsize */ | ||
187 | int valpred; /* Predicted value */ | ||
188 | int vpdiff; /* Current change to valpred */ | ||
189 | int index; /* Current step change index */ | ||
190 | int inputbuffer; /* place to keep next 4-bit value */ | ||
191 | int bufferstep; /* toggle between inputbuffer/input */ | ||
192 | |||
193 | outp = outdata; | ||
194 | inp = (signed char *)indata; | ||
195 | |||
196 | valpred = state->valprev; | ||
197 | index = state->index; | ||
198 | step = stepsizeTable[index]; | ||
199 | |||
200 | bufferstep = 0; | ||
201 | |||
202 | for ( ; len > 0 ; len-- ) { | ||
203 | |||
204 | /* Step 1 - get the delta value */ | ||
205 | if ( bufferstep ) { | ||
206 | delta = inputbuffer & 0xf; | ||
207 | } else { | ||
208 | inputbuffer = *inp++; | ||
209 | delta = (inputbuffer >> 4) & 0xf; | ||
210 | } | ||
211 | bufferstep = !bufferstep; | ||
212 | |||
213 | /* Step 2 - Find new index value (for later) */ | ||
214 | index += indexTable[delta]; | ||
215 | if ( index < 0 ) index = 0; | ||
216 | if ( index > 88 ) index = 88; | ||
217 | |||
218 | /* Step 3 - Separate sign and magnitude */ | ||
219 | sign = delta & 8; | ||
220 | delta = delta & 7; | ||
221 | |||
222 | /* Step 4 - Compute difference and new predicted value */ | ||
223 | /* | ||
224 | ** Computes 'vpdiff = (delta+0.5)*step/4', but see comment | ||
225 | ** in adpcm_coder. | ||
226 | */ | ||
227 | vpdiff = step >> 3; | ||
228 | if ( delta & 4 ) vpdiff += step; | ||
229 | if ( delta & 2 ) vpdiff += step>>1; | ||
230 | if ( delta & 1 ) vpdiff += step>>2; | ||
231 | |||
232 | if ( sign ) | ||
233 | valpred -= vpdiff; | ||
234 | else | ||
235 | valpred += vpdiff; | ||
236 | |||
237 | /* Step 5 - clamp output value */ | ||
238 | if ( valpred > 32767 ) | ||
239 | valpred = 32767; | ||
240 | else if ( valpred < -32768 ) | ||
241 | valpred = -32768; | ||
242 | |||
243 | /* Step 6 - Update step value */ | ||
244 | step = stepsizeTable[index]; | ||
245 | |||
246 | /* Step 7 - Output value */ | ||
247 | *outp++ = valpred; | ||
248 | } | ||
249 | |||
250 | state->valprev = valpred; | ||
251 | state->index = index; | ||
252 | } | ||
diff --git a/core/applets/vmemo/adpcm.h b/core/applets/vmemo/adpcm.h new file mode 100644 index 0000000..9c17ffa --- a/dev/null +++ b/core/applets/vmemo/adpcm.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | ** adpcm.h - include file for adpcm coder. | ||
3 | ** | ||
4 | ** Version 1.0, 7-Jul-92. | ||
5 | */ | ||
6 | |||
7 | struct adpcm_state { | ||
8 | short valprev;/* Previous output value */ | ||
9 | char index; /* Index into stepsize table */ | ||
10 | }; | ||
11 | |||
12 | #ifdef __STDC__ | ||
13 | #define ARGS(x) x | ||
14 | #else | ||
15 | #define ARGS(x) () | ||
16 | #endif | ||
17 | |||
18 | void adpcm_coder ARGS((short [], char [], int, struct adpcm_state *)); | ||
19 | void adpcm_decoder ARGS((char [], short [], int, struct adpcm_state *)); | ||
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index b77e3b8..b5239eb 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -14,6 +14,10 @@ | |||
14 | * $Id$ | 14 | * $Id$ |
15 | */ | 15 | */ |
16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> | 16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> |
17 | extern "C" { | ||
18 | #include "adpcm.h" | ||
19 | } | ||
20 | |||
17 | #include <sys/utsname.h> | 21 | #include <sys/utsname.h> |
18 | #include <sys/time.h> | 22 | #include <sys/time.h> |
19 | #include <sys/types.h> | 23 | #include <sys/types.h> |
@@ -57,6 +61,13 @@ typedef struct _waveheader { | |||
57 | #define WAVE_MONO 1 | 61 | #define WAVE_MONO 1 |
58 | #define WAVE_STEREO 2 | 62 | #define WAVE_STEREO 2 |
59 | 63 | ||
64 | struct adpcm_state encoder_state; | ||
65 | //struct adpcm_state decoder_state; | ||
66 | |||
67 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | ||
68 | #define WAVE_FORMAT_PCM (0x0001) | ||
69 | |||
70 | |||
60 | #include "vmemo.h" | 71 | #include "vmemo.h" |
61 | 72 | ||
62 | #include <qpe/qpeapplication.h> | 73 | #include <qpe/qpeapplication.h> |
@@ -196,8 +207,7 @@ static char * vmemo_xpm[] = { | |||
196 | 207 | ||
197 | 208 | ||
198 | VMemo::VMemo( QWidget *parent, const char *_name ) | 209 | VMemo::VMemo( QWidget *parent, const char *_name ) |
199 | : QWidget( parent, _name ) | 210 | : QWidget( parent, _name ) { |
200 | { | ||
201 | setFixedHeight( 18 ); | 211 | setFixedHeight( 18 ); |
202 | setFixedWidth( 14 ); | 212 | setFixedWidth( 14 ); |
203 | 213 | ||
@@ -213,6 +223,7 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
213 | Config vmCfg("Vmemo"); | 223 | Config vmCfg("Vmemo"); |
214 | vmCfg.setGroup("Defaults"); | 224 | vmCfg.setGroup("Defaults"); |
215 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 225 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
226 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | ||
216 | 227 | ||
217 | qDebug("toggleKey %d", toggleKey); | 228 | qDebug("toggleKey %d", toggleKey); |
218 | 229 | ||
@@ -243,12 +254,10 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
243 | } | 254 | } |
244 | } | 255 | } |
245 | 256 | ||
246 | VMemo::~VMemo() | 257 | VMemo::~VMemo() { |
247 | { | ||
248 | } | 258 | } |
249 | 259 | ||
250 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 260 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
251 | { | ||
252 | qDebug("receive"); | 261 | qDebug("receive"); |
253 | QDataStream stream( data, IO_ReadOnly ); | 262 | QDataStream stream( data, IO_ReadOnly ); |
254 | if (msg == "toggleRecord()") { | 263 | if (msg == "toggleRecord()") { |
@@ -264,14 +273,12 @@ void VMemo::receive( const QCString &msg, const QByteArray &data ) | |||
264 | } | 273 | } |
265 | } | 274 | } |
266 | 275 | ||
267 | void VMemo::paintEvent( QPaintEvent* ) | 276 | void VMemo::paintEvent( QPaintEvent* ) { |
268 | { | ||
269 | QPainter p(this); | 277 | QPainter p(this); |
270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 278 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
271 | } | 279 | } |
272 | 280 | ||
273 | void VMemo::mousePressEvent( QMouseEvent * me) | 281 | void VMemo::mousePressEvent( QMouseEvent * me) { |
274 | { | ||
275 | // just to be safe | 282 | // just to be safe |
276 | if (recording) { | 283 | if (recording) { |
277 | recording = FALSE; | 284 | recording = FALSE; |
@@ -279,8 +286,7 @@ void VMemo::mousePressEvent( QMouseEvent * me) | |||
279 | } | 286 | } |
280 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 287 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
281 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 288 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
282 | if ( me->button() != LeftButton) | 289 | if ( me->button() != LeftButton || me != NULL) |
283 | |||
284 | // if (!systemZaurus && me != NULL) | 290 | // if (!systemZaurus && me != NULL) |
285 | return; | 291 | return; |
286 | 292 | ||
@@ -290,8 +296,7 @@ void VMemo::mousePressEvent( QMouseEvent * me) | |||
290 | stopRecording(); | 296 | stopRecording(); |
291 | } | 297 | } |
292 | 298 | ||
293 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 299 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
294 | { | ||
295 | // if(usingIcon && !recording) | 300 | // if(usingIcon && !recording) |
296 | // stopRecording(); | 301 | // stopRecording(); |
297 | } | 302 | } |
@@ -375,9 +380,10 @@ bool VMemo::startRecording() { | |||
375 | ::close(dsp); | 380 | ::close(dsp); |
376 | return FALSE; | 381 | return FALSE; |
377 | } | 382 | } |
383 | record(); | ||
384 | |||
378 | QString cmd; | 385 | QString cmd; |
379 | cmd.sprintf("mv %s "+fileName,pointer); | 386 | cmd.sprintf("mv %s "+fileName,pointer); |
380 | |||
381 | // move tmp file to regular file here | 387 | // move tmp file to regular file here |
382 | system(cmd.latin1()); | 388 | system(cmd.latin1()); |
383 | 389 | ||
@@ -393,8 +399,6 @@ bool VMemo::startRecording() { | |||
393 | l.setCategories(cats); | 399 | l.setCategories(cats); |
394 | l.writeLink(); | 400 | l.writeLink(); |
395 | 401 | ||
396 | record(); | ||
397 | |||
398 | return TRUE; | 402 | return TRUE; |
399 | } | 403 | } |
400 | 404 | ||
@@ -414,8 +418,7 @@ void VMemo::stopRecording() { | |||
414 | hide(); | 418 | hide(); |
415 | } | 419 | } |
416 | 420 | ||
417 | int VMemo::openDSP() | 421 | int VMemo::openDSP() { |
418 | { | ||
419 | Config cfg("Vmemo"); | 422 | Config cfg("Vmemo"); |
420 | cfg.setGroup("Record"); | 423 | cfg.setGroup("Record"); |
421 | 424 | ||
@@ -467,8 +470,7 @@ int VMemo::openDSP() | |||
467 | return 1; | 470 | return 1; |
468 | } | 471 | } |
469 | 472 | ||
470 | int VMemo::openWAV(const char *filename) | 473 | int VMemo::openWAV(const char *filename) { |
471 | { | ||
472 | track.setName(filename); | 474 | track.setName(filename); |
473 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 475 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
474 | errorMsg=filename; | 476 | errorMsg=filename; |
@@ -484,6 +486,9 @@ int VMemo::openWAV(const char *filename) | |||
484 | wh.chunk_type = WAVE; | 486 | wh.chunk_type = WAVE; |
485 | wh.sub_chunk = FMT; | 487 | wh.sub_chunk = FMT; |
486 | wh.sc_len = 16; | 488 | wh.sc_len = 16; |
489 | if(useADPCM) | ||
490 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | ||
491 | else | ||
487 | wh.format = PCM_CODE; | 492 | wh.format = PCM_CODE; |
488 | wh.modus = channels; | 493 | wh.modus = channels; |
489 | wh.sample_fq = speed; | 494 | wh.sample_fq = speed; |
@@ -499,8 +504,7 @@ int VMemo::openWAV(const char *filename) | |||
499 | return 1; | 504 | return 1; |
500 | } | 505 | } |
501 | 506 | ||
502 | void VMemo::record(void) | 507 | void VMemo::record(void) { |
503 | { | ||
504 | int length=0, result, value; | 508 | int length=0, result, value; |
505 | QString msg; | 509 | QString msg; |
506 | msg.sprintf("Recording format %d", format); | 510 | msg.sprintf("Recording format %d", format); |
@@ -511,84 +515,46 @@ void VMemo::record(void) | |||
511 | 515 | ||
512 | t_timer->start( sRate * 1000+1000, TRUE); | 516 | t_timer->start( sRate * 1000+1000, TRUE); |
513 | 517 | ||
514 | if(systemZaurus) { | 518 | // if(systemZaurus) { |
519 | // } else { // 16 bit only capabilities | ||
515 | 520 | ||
516 | msg.sprintf("Recording format zaurus"); | 521 | msg.sprintf("Recording format other"); |
517 | qDebug(msg); | 522 | qDebug(msg); |
518 | signed short sound[1024], monoBuffer[1024]; | ||
519 | |||
520 | if(format==AFMT_S16_LE) { | ||
521 | |||
522 | 523 | ||
524 | int bufsize=1024; | ||
525 | int bytesWritten=0; | ||
526 | signed short sound[1024], monoBuffer[1024]; | ||
527 | char abuf[bufsize/2]; | ||
528 | short sbuf[bufsize]; | ||
523 | 529 | ||
524 | while(recording) { | 530 | while(recording) { |
525 | 531 | ||
532 | if(useADPCM) | ||
533 | result = read( dsp, sbuf, bufsize); // 8192 | ||
534 | else | ||
526 | result = read(dsp, sound, 1024); // 8192 | 535 | result = read(dsp, sound, 1024); // 8192 |
527 | // int j=0; | 536 | if( result <= 0) { |
528 | 537 | perror("recording error "); | |
529 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 538 | // qDebug(currentFileName); |
530 | monoBuffer[i] = sound[i]; | 539 | QMessageBox::message(tr("Note"),tr("error recording")); |
531 | } | 540 | recording=FALSE;; |
532 | 541 | break; | |
533 | length+=write(wav, monoBuffer, result); | ||
534 | if(length<0) | ||
535 | recording=false; | ||
536 | // for (int i = 0; i < result; i+=2) { | ||
537 | // monoBuffer[j] = sound[i]; | ||
538 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; | ||
539 | |||
540 | // j++; | ||
541 | // } | ||
542 | qApp->processEvents(); | ||
543 | // printf("%d\r",length); | ||
544 | // fflush(stdout); | ||
545 | } | 542 | } |
546 | 543 | ||
547 | } else { //AFMT_U8 | 544 | if(useADPCM) { |
548 | // 8bit unsigned | 545 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
549 | unsigned short sound[1024], monoBuffer[1024]; | 546 | bytesWritten = ::write(wav, abuf, result/4); |
550 | while(recording) { | ||
551 | result = read(dsp, sound, 1024); // 8192 | ||
552 | // int j=0; | ||
553 | |||
554 | // if(systemZaurus) { | ||
555 | 547 | ||
548 | } else { | ||
556 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 549 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
557 | monoBuffer[i] = sound[i]; | 550 | monoBuffer[i] = sound[i]; |
558 | } | 551 | } |
559 | 552 | ||
560 | length+=write(wav, monoBuffer, result); | 553 | length+=write(wav, monoBuffer, result); |
561 | |||
562 | // for (int i = 0; i < result; i+=2) { | ||
563 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; | ||
564 | // j++; | ||
565 | // } | ||
566 | // length+=write(wav, monoBuffer, result/2); | ||
567 | length += result; | ||
568 | // printf("%d\r",length); | ||
569 | // fflush(stdout); | ||
570 | } | ||
571 | |||
572 | qApp->processEvents(); | ||
573 | } | 554 | } |
574 | 555 | length +=bytesWritten; | |
575 | } else { // 16 bit only capabilities | ||
576 | |||
577 | |||
578 | msg.sprintf("Recording format other"); | ||
579 | qDebug(msg); | ||
580 | |||
581 | signed short sound[1024];//, monoBuffer[512]; | ||
582 | |||
583 | while(recording) { | ||
584 | |||
585 | result = read(dsp, sound, 1024); // 8192 | ||
586 | |||
587 | write(wav, sound, result); | ||
588 | length += result; | ||
589 | 556 | ||
590 | if(length<0) { | 557 | if(length<0) { |
591 | |||
592 | recording=false; | 558 | recording=false; |
593 | perror("dev/dsp's is a lookin' messy"); | 559 | perror("dev/dsp's is a lookin' messy"); |
594 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 560 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
@@ -600,7 +566,7 @@ void VMemo::record(void) | |||
600 | // qDebug("file has length of %d lasting %d seconds", | 566 | // qDebug("file has length of %d lasting %d seconds", |
601 | // length, (( length / speed) / channels) / 2 ); | 567 | // length, (( length / speed) / channels) / 2 ); |
602 | // medialplayer states wrong length in secs | 568 | // medialplayer states wrong length in secs |
603 | } | 569 | // } |
604 | 570 | ||
605 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// | 571 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// |
606 | 572 | ||
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h index 823c7b8..167af2a 100644 --- a/core/applets/vmemo/vmemo.h +++ b/core/applets/vmemo/vmemo.h | |||
@@ -36,7 +36,7 @@ public: | |||
36 | QString fileName, errorMsg; | 36 | QString fileName, errorMsg; |
37 | QLabel* msgLabel; | 37 | QLabel* msgLabel; |
38 | QTimer *t_timer; | 38 | QTimer *t_timer; |
39 | bool usingIcon; | 39 | bool usingIcon, useADPCM; |
40 | public slots: | 40 | public slots: |
41 | void record(); | 41 | void record(); |
42 | void mousePressEvent( QMouseEvent * ); | 42 | void mousePressEvent( QMouseEvent * ); |
diff --git a/core/applets/vmemo/vmemo.pro b/core/applets/vmemo/vmemo.pro index f8007b6..6599b52 100644 --- a/core/applets/vmemo/vmemo.pro +++ b/core/applets/vmemo/vmemo.pro | |||
@@ -1,7 +1,7 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= vmemo.h vmemoimpl.h | 3 | HEADERS = vmemo.h vmemoimpl.h adpcm.h |
4 | SOURCES= vmemo.cpp vmemoimpl.cpp | 4 | SOURCES = vmemo.cpp vmemoimpl.cpp adpcm.c |
5 | TARGET = vmemoapplet | 5 | TARGET = vmemoapplet |
6 | DESTDIR =$(OPIEDIR)/plugins/applets | 6 | DESTDIR =$(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |