Advertisement

How does a 64-bit OS affect performance of floats vs doubles?

Started by August 21, 2008 11:57 AM
10 comments, last by Chadivision 16 years, 1 month ago
Quote: Original post by Chadivision
There are some types of modules that could benefit from using doubles, but most of them would only need to use doubles internally and could then convert the output to a float. Or I could write two versions of some modules--one that outputs a float and one that outputs a double.
Have you considered delta coding the samples? That ought to do wonders for the precision if you're storing sounds as floats yet processing them internally as doubles, assuming the the sounds are "reasonable" anyway.
You'd have to be careful not to let the encoder and decoders' views of what the current value is drift out of sync though. Specifically convincing the compiler not to optimize away the float casts might prove to be a bit tricky.
I hadn't really thought about delta coding. There are a couple of situations that it could work for in my application, but I'm a little hesitant to have the modules output any kind of compressed signal. What I'm going for is to create a truly modular syntesizer--one where the output of any module can be plugged into the input of any other module, and I wouldn't want to have only certain modules be able to work with compressed signals.

I guess I could have a decompression function built into the base class that all of my modules will derive from, but I could run into a situation where the signal is being compressed and decompressed each time it runs through another module. That might be a little more complexity than I really need, but I am going to think about it. It might not be a bad way to go.

What I was thinking about was to have each module generate either a double or a float (chosen by the designer of the module) for each of its outputs and send them to an object that stores all of the outputs for all modules. When a module wants to use that value as an input, it calls a function on that object to retrieve the value. In that function call, I could specify whether I'm requesting a double or a float (depending upon the level of precision needed for that particular module), and the object could return the appropriate type (doing a conversion if necessary).

That would make it so that I could still patch any output into any input, regardless of whether it's a double or a float. Obviously taking a double output into a float input would sacrifice some precision, but there are a lot of modules where that wouldn't create an audible difference. I could have the user interface notify the user that a conversion has taken place, and then the user could decide whether it's important enough to worry about.
Atari 2600 Homebrew Author - Someone who is smart enough to learn 6502 assembly language but dumb enough to actually want to use it.

This topic is closed to new replies.

Advertisement