you will want to use inline assembly. (the math intrinsics are just that anyways.) many of the math instructions set a status bit on overflow/saturate. unfortunately 32x32 to a dreg is not one of them. couple options off the top of my head:
- multiply to one of the 40-bit accumulators, sets status bit if exceeds 32b boundary.
- before performing the 32x32, perform a 16x16 with the MSBs and check the status bit.
- do the clipping check some place where you're mixing signals, use a saturated ADD.
see the Blackfin Programming Reference for details (p. 600, 641 and elsewhere)
hm, i'm not totally sure what application you're talking about. like, feedback in a delay line? i made a 2-pole highpass that might be helpful, its in the
dsp folder and i used it on white noise for
dsyn. the lowpass form is stubbed in bt i didn't bother to fill out coeffecients for it since we weren't using it anywhere.
zero = 0
when oversampling for plugins (distortion and SVF) i have gone the common route of zero-padding followed by FIR interpolator. this works well for most things, and i recommend it over zero-order hold. i have seen some clever tricks to skip the zero-padding step by flipping between sets of FIR taps. (sorry for being vague but it's been a long time and i can't find a good reference online right now.) bear in mind that this adds latency, maybe lots of latency if you want that high an upsampling ratio (use polyphase FIR.)
bear in mind too that it is theoretically possible to just run the aleph's audio codec at a higher sampling rate in the first place (up to 192k.) this will involve sending some control registers to the AD1939 over SPI at startup (see the ad1939 datasheet and put the code after codec reset in
init.c) this is what i would try really. better with block processing (it really does work, i promise, i just have not done anything with it!)
cool, but i'm curious why? LUTs are cheap and simple. linear interpolation on a 512-point LUT is surely accurate enough. (smaller probably fine too.) and you can build in a taper to zero at the bottom, which you probably want.
the problem with approximations, say taylor series, is that they are gonna require a lot of calculations anyways, and in fixed-point it will be problematic. for example
ln(x) ~= (x-1) - (((x-1)^2) /2) + (((x-1)^3) /3) - ...
you will want, i dunno, 4 or 5 of these terms at least, and each mul/div will lose precision because on avr32 you will essentially need to limit the operands to 16b and shift the result. the cumulative error could be pretty bad.