Re: CPU usage creep in waveIn sample during handling MM_WIM_DATA message



"Bob Masta" <N0Spam@xxxxxxxxxxx> wrote in message
news:4979c031.584057@xxxxxxxxxxxxxxxxxxxxx
On Thu, 22 Jan 2009 18:13:46 -0500, "Chris P."
<msdn@xxxxxxxxxxxx> wrote:

On Thu, 22 Jan 2009 17:55:27 -0400, Mitch Gallant wrote:

Can anyone explain why there is a cpu increase that eventually is 100%
in
this windows proc. message which handles sampled buffers when ready.

Petzold should be ashamed of himself. It's the realloc. The performance
of the realloc will get worse and worse as the amount of memory requested
increases. You will also potentially lose audio samples as the time taken
increases.

3 options.
- Record to file.
- Allocated fixed amount of memory.
- Allocated fixed amount of memory and grow by large fixed increment.

The best approach here depends on what is going to
be done with the data. If you are just going to
look at it on the screen (scope, spectrum
analyzer, etc) then just use a fixed amount of
memory. Make it larger than you need for the
display, and wrap around to the start when it's
full. This is essentially a big circular buffer,
but you will be filling it by waveInAddBuffer
sized chunks.

If you want to save the continuous recording to a
file, you can do the same thing, only do the
writes in big chunks... say, half the overall
buffer size. That way you can keep on recording
and writing indefinitely with a fixed-size file.
(Well, "indefinitely" until you hit the upper
limit of a .WAV file or whatever you are using.)


I think I have enough feedback on this to proceed. Thanks to Bob and Chris.
I'm pretty sure that Daqarta would have some of the functionality I
want/need, but initially at least I would like to have some rudimentary code
that I can modify with complete control. Speaking of which, is there any
possibility to extend the code of Daqarta? (slightly off topic). Also, do
any "sound cards" support actual DC input? (most are of course audio with
lower end rolloff at ~ 10 kHz or similar). One application I'm interested
in is sampling time-based variation of DC input signals .

- Mitch


.



Relevant Pages

  • Re: Buffer or Realloc?
    ... better to allocate memory and realloc it for the size of the what is ... between deciding to use a fixed size buffer or allocating memory ... so for the string I've got to prepare as part of a message to the UK Government gateway where the specification says the string has a maximum length of 10 characters I should not use a fixed size buffer but a reallocating buffer? ... with the realloc() approach -- obviously ...
    (comp.lang.c)
  • Re: CPU usage creep in waveIn sample during handling MM_WIM_DATA message
    ... It's the realloc. ... Allocated fixed amount of memory. ... Allocated fixed amount of memory and grow by large fixed increment. ... This is essentially a big circular buffer, ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: CPU usage creep in waveIn sample during handling MM_WIM_DATA message
    ... It's the realloc. ... Allocated fixed amount of memory. ... I found that increasing the pWaveHdr buffer from 16kB to 64 kB improved the ... I modified it to use stereo, 16 bit and 22050 Hz sampling rate so the same ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: callocs, call by ref and function returning in C
    ... Realloc does not guarantee that the memory stays in the same location. ... So all pointers into the buffer become invalid. ... If the user passes the buffer by reference to the function I can't ...
    (comp.programming)
  • Re: Discovering variable types...
    ... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ...
    (comp.lang.pascal.delphi.misc)

Loading