msp C – buffer inside the perform method

Feb 24, 2006 at 1:14am

msp C – buffer inside the perform method

Hi, I’m still crunching away at my comb filter replica, and I’ve got it all nearly perfectly down except that I’m getting some distortion that I can’t pinpoint.

After trying a million little things, I’ve decided that perhaps it’s just that my buffering within the perform loop is taking up too much processor time as I’ve got calls to the object structure inside of it.

Can anybody point me to some examples of efficient buffering (at least ten milliseconds of samples) and access routines that I can experiment with?

or any advice, or willingness to critique my actual code would also be welcome.

thanks for all the help,

dan mcanulty

#24592
Feb 24, 2006 at 2:29am

If you would like to mail the source, I’ll take a look at it. Maybe
you’re making a blocking call at interrupt time, which is a no-no.

You might be interested in profiling your code as well, to attach to
Max on os x you’ll need to run your patcher in the Max Runtime. I
haven’t seen any good tutorials for profiling max externals, perhaps
it’s time someone checked into that.

_Mark

#71386
Feb 24, 2006 at 8:41am

Hi,

you can use Shark from Apple CHUD. It’s easy and convenient. Objects to
profile should be compiled with all debug symbols.
Shark can attach to MaxMsp. hen just press start/stop mesuring and see
the results.

Regards,
Chris

#71387
Feb 24, 2006 at 10:43am

On around Feb 24, 2006, at 2:14, daniel e mcanulty said something like:
> After trying a million little things, I’ve decided that perhaps it’s
> just that my buffering within the perform loop is taking up too much
> processor time as I’ve got calls to the object structure inside of it.

What, as in

while (n– > 0) {

myObj->buffer[i++] = something;

}

??

Never access structure components inside the perform loop. Always put
addresses into registers before entering the loop:

float* bufptr = myObj->buffer + m;

while (n– > 0) {

bufptr++ = something;

}

You will need some extra logic to wrap your buffer around when you hit
the end, but you needed that for the index (m) in the previous example.

That said, a good optimizing compiler will do the above for you if you
let it (ie, you are using the optimization flags?).

That said, I find it hard to credit that this would cause clicks on any
PPC processor >~100MHz.

A good source for best practice in DSP coding is the list archive at
http://www.musicdsp.org. I would particularly recommend James McCartney’s
posts. Not everything there is great, but James’ contributions are
definitely worthwhile.

Good luck,
Peter

————– http://www.bek.no/~pcastine/Litter/ ————–
Peter Castine | ^
| Litter Power & Litter Bundle for Jitter
pcastine@gmx.net |
pcastine@bek.no | iCE: Sequencing, Recording, and Interface Building
4-15@kagi.com | for Max/MSP
| Extremely cool
| http://www.dspaudio.com
| http://www.dspaudio.com/software/software.html

#71388

You must be logged in to reply to this topic.