xoxosvst

dsp blog for xoxos.net

INT phasors

leave a comment »

i haven’t had time to build this yet, my deep thought for today concerns the irksome float to INT conversion when using phasors for delays. they are expensive.

typical implementation is as such

floatphasor += floatincrement;

if (floatphasor >= 65536) floatphasor -= 65536;

INTphasor = (int)floatphasor;

decimal = floatphasor – (double)INTphasor;

(+ whatever method of interpolation)

the float to int conversion, even with typecasting is nasty stuff (i know this because synthedit displays the cpu consumption of SEM modules made with the SDK).

as i’ve only thought about this, there could be a glaring error. but at present, and happy to blog it, i’m thinking that it would be faster to split the phasor into int and decimal components:

unsigned short int INTphasor, INTincrement;

double decimalphasor, decimalincrement;

INTincrement = (int)increment;

decimalincrement = increment – (double)INTincrement;

loop {

        INTphasor += intincrement;

        decimalphasor += decimalincrement;

        if (decimalphasor >= 1) {

                decimalphasor -= 1;

                INTphasor++;

        }

};

the IF (or a WHILE depending on modulation) is faster than the float to int conversion, i’m sure of it.

off course, the person who is writing this has just inlined their oscillator routine with 32 variations, so they will have to correct all thirty two of them individually in order to implement this in their current project 🙂

Advertisements

Written by xoxosvst

July 28, 2011 at 3:45 pm

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: