author | llornkcor <llornkcor> | 2002-02-15 02:19:03 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-15 02:19:03 (UTC) |
commit | 77ea163d796ac330ad688210e049ab3763d9dd11 (patch) (unidiff) | |
tree | 397be388960031f19579b2fdd831bc23afa78ff8 /core | |
parent | 99a28ff7d9e2e7a913abb6e573a0ae95b50221d7 (diff) | |
download | opie-77ea163d796ac330ad688210e049ab3763d9dd11.zip opie-77ea163d796ac330ad688210e049ab3763d9dd11.tar.gz opie-77ea163d796ac330ad688210e049ab3763d9dd11.tar.bz2 |
changed header file, and zaurus mono input
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 73bd996..83f19f5 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -30,10 +30,11 @@ typedef struct _waveheader { | |||
30 | u_long main_chunk; /* 'RIFF' */ | 30 | u_long main_chunk; /* 'RIFF' */ |
31 | u_long length; /* filelen */ | 31 | u_long length; /* filelen */ |
32 | u_long chunk_type; /* 'WAVE' */ | 32 | u_long chunk_type; /* 'WAVE' */ |
33 | |||
34 | u_long sub_chunk; /* 'fmt ' */ | 33 | u_long sub_chunk; /* 'fmt ' */ |
35 | u_long sc_len; /* length of sub_chunk, =16 (chunckSize) */ | 34 | u_long sc_len; /* length of sub_chunk, =16 |
35 | (chunckSize) format len */ | ||
36 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 36 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
37 | |||
37 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 38 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
38 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 39 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
39 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 40 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
@@ -41,6 +42,7 @@ typedef struct _waveheader { | |||
41 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 42 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
42 | 43 | ||
43 | u_long data_chunk; /* 'data' */ | 44 | u_long data_chunk; /* 'data' */ |
45 | |||
44 | u_long data_length;/* samplecount */ | 46 | u_long data_length;/* samplecount */ |
45 | } WaveHeader; | 47 | } WaveHeader; |
46 | 48 | ||
@@ -242,7 +244,7 @@ int VMemo::openDSP() | |||
242 | 244 | ||
243 | speed = cfg.readNumEntry("SampleRate", 11025); | 245 | speed = cfg.readNumEntry("SampleRate", 11025); |
244 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 246 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
245 | if (cfg.readNumEntry("SixteenBit", 1)) | 247 | if (cfg.readNumEntry("SixteenBit", 1)==1) |
246 | { | 248 | { |
247 | format = AFMT_S16_LE; | 249 | format = AFMT_S16_LE; |
248 | resolution = 16; | 250 | resolution = 16; |
@@ -254,7 +256,10 @@ int VMemo::openDSP() | |||
254 | } | 256 | } |
255 | 257 | ||
256 | if(systemZaurus) | 258 | if(systemZaurus) |
259 | { | ||
257 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 260 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
261 | channels=1; //zaurus has one input channel | ||
262 | } | ||
258 | else | 263 | else |
259 | dsp = open("/dev/dsp", O_RDWR); | 264 | dsp = open("/dev/dsp", O_RDWR); |
260 | 265 | ||
@@ -301,22 +306,20 @@ int VMemo::openWAV(const char *filename) | |||
301 | 306 | ||
302 | WaveHeader wh; | 307 | WaveHeader wh; |
303 | 308 | ||
304 | wh.main_chunk = RIFF; | 309 | wh.main_chunk = RIFF;// RIFF |
305 | wh.length = 0; | 310 | wh.chunk_type = WAVE;//WAVE |
306 | wh.chunk_type = WAVE; | 311 | wh.sub_chunk = FMT;// fmt |
307 | 312 | wh.sc_len = 16;// format length = 16 | |
308 | wh.sub_chunk = FMT; | 313 | wh.format = PCM_CODE;// PCM |
309 | wh.sc_len = 16; | 314 | wh.modus = channels;// channels |
310 | wh.format = PCM_CODE; | 315 | wh.sample_fq = speed;//samplerate |
311 | wh.modus = channels; | 316 | wh.byte_p_sec = speed * channels * resolution/8;// av bytes per second |
312 | wh.sample_fq = speed; | 317 | wh.byte_p_spl = channels * (resolution / 8); //block align |
313 | wh.bit_p_spl = resolution; | 318 | wh.bit_p_spl = resolution;//bits per sample 8, or 16 |
314 | wh.byte_p_sec = wh.sample_fq * wh.bit_p_spl; | ||
315 | wh.byte_p_spl = channels * (wh.bit_p_spl % 8); | ||
316 | |||
317 | wh.data_chunk = DATA; | 319 | wh.data_chunk = DATA; |
318 | wh.data_length= 0; | 320 | wh.data_length= 0; // <--- |
319 | 321 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | |
322 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | ||
320 | write (wav, &wh, sizeof(WaveHeader)); | 323 | write (wav, &wh, sizeof(WaveHeader)); |
321 | 324 | ||
322 | return 1; | 325 | return 1; |
@@ -337,6 +340,8 @@ void VMemo::record(void) | |||
337 | qApp->processEvents(); | 340 | qApp->processEvents(); |
338 | length += result; | 341 | length += result; |
339 | qApp->processEvents(); | 342 | qApp->processEvents(); |
343 | // printf("%d\r",length); | ||
344 | // fflush(stdout); | ||
340 | } | 345 | } |
341 | 346 | ||
342 | qWarning("VMemo::record() -> Done recording"); | 347 | qWarning("VMemo::record() -> Done recording"); |
@@ -347,6 +352,7 @@ void VMemo::record(void) | |||
347 | write(wav, &value, 4); | 352 | write(wav, &value, 4); |
348 | lseek(wav, 40, SEEK_SET); | 353 | lseek(wav, 40, SEEK_SET); |
349 | write(wav, &length, 4); | 354 | write(wav, &length, 4); |
355 | // qDebug("File length %d, samplecount %d", value, length); | ||
350 | track.close(); | 356 | track.close(); |
351 | 357 | ||
352 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)// ); //tell driver to stop for a while | 358 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)// ); //tell driver to stop for a while |