As always, the sources are in the jar file It’s pretty well-organised, but it’s not particularly re-usable. – I designed it as more of a self-contained “sound box”. There’s not much more I want to add to this program, a filter envelope would be nice to have.
I wrote it in mostly fixed point arithmetic, because I had J2ME at the back of my mind, but also because fixed point makes more sense when interpolating. It’s noticably quicker, probably because indexing an array with a float requires both a modulo-division and a cast-to-int, which is quite heavy compared to a left shift.
( EDIT: Sorry, just occured to me, indexing the array doesn’t need modulo-division, but getting at the fractional part in order to eg. linear-interpolate between two samples does … )
And then there’s the prospect of denormalisation. When the FPU encounters a really small number, it switches into a different mode, which can really kill performance, apparently. Not a problem when interpolating, but it needs to be considered, you don’t want a denormalised number in one of your filter coefficients, for example.
I got the filter code from musicdsp.org, and that has so far resisted my attempts to integerize it. I managed to make it work using long integers with 24-bit fractional accuracy, but the sound quality was not as good – it’s quite flat and muddy. The code is also really ugly compared to the floating point version, although it seems to run at about the same speed, possibly slightly faster. I think I’ll bite the bullet and go to floating point where it makes sense in this program, ie. keeping the oscillators in fixed-point but replacing the use of sine/log tables with floating point – it will make the code more readable.
erikd: I can’t promise I’ll do anything with it, but by all means send me the library. Maybe I’ll have a go at wiring the MIDI code up to it