# complex sine wave oscillator in Gen -> precision question about Max, MSP and Gen

Edwin van der Heide

Aug 04 2012 | 2:49 pm

I've started experimenting with making a complex sine wave oscillator in gen~. It is based on the feedback of a complex cartesian vector that is multiplied (complex) with an angular increase vector (also cartesian). As long as the vector has a length of 1. the amplitude of the oscillator should stay (almost) constant. This means that high precision calculations are a requirement.
I have been calculating the angular vector (in cartesian coordinates) with cos and sine functions in Max, MSP and Gen~. It turns out there is a real difference in precision between the 3 worlds. In Max it is the least precise, in MSP more and Gen even more. This led me to the following questions:
- Why is there a difference in precision between cosx~ and sinx~ in MSP and cos and sin Gen~? Isn't MSP 64 bit since Max 6?
- What about the precision of floats in Max 6. Are they single precision (32 bit) or double precision (64 bit)?
I would of course prefer to calculate the angular increase vector in Max because this would be the least cpu intensive (as long as it's not needed to modulate the oscillator's frequency at signal rate).

Below follows an example patch.

best!

Edwin