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

Edwin van der Heide's icon

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!

Max Patch
Copy patch and select New From Clipboard in Max.

Edwin

Roman Thilenius's icon

no idea why you see a difference between MPS and gen, but numbers are still 32 bit.

maybe you can try to press various calculation all into one [expr] to get a somewhat higher precise output.

Gregory Taylor's icon

While MSP is, indeed, 64-bit, Max float datatypes are currently 32-bit. That will be changing in the future, but at the moment I would expect that this would explain any differences you may be seeing.

Edwin van der Heide's icon

Hi Gregory, Thanks for the answer! The precision difference between Max and MSP & Gen is clear now.
- why are sin and cos in Gen nevertheless more precise then cosx~ and sinx~ in MSP? My patch above will illustrate this because you'll see that the amplitude of the oscillator is less constant (depending on the frequency) when cosx~ and sinx~ are used.
- are there any future plans to incorporate 64 bit floats as Max datatype?

Timothy Place's icon

I've addressed sinx~ computing at 32-bit instead of 64-bit resolution for a future version of Max.
And, yes, there will be a future version of Max that will pass 64-bit floats.

Cheers,
Tim

Edwin van der Heide's icon

That's great news!

Cheers, Edwin