VS 2015, x64, and Code Cleanup

The white noise generators in other audio tools aren’t perfect either, probably for the same reason. Even in acoustic measurement software like Room Equalization Wizard and ARTA they aren’t perfectly random.

For acoustic measurement it doesn’t matter, as the deviation in the frequency chart is less than 0,15 dB. In testing DSP’s it might matter, I don’t know, as I never do that kind of precise stuff…

Just as a matter of interest, Nyquist includes a function REAL-RANDOM which produces random floating point numbers between specified minimum and maximum values.
I’ve not looked at the C code, but you can see the code in action by running this snippet in the Nyquist Prompt (use the Debug button to see the output)

(setf *float-format* "%.14f")
(dotimes (i 10)
  (print (real-random -1000000 1000000)))

“REAL-RANDOM” is implemented like this:

/* xlrealrand - return random number in [0, 1] */
double xlrealrand() {
    /* always use the random generator from the C library,
       (do not use random() even if USE_RANDOM is defined */
    return (double) rand() / RAND_MAX;
}

To see what the actual implications would be, I implemented a “noiseg” for Nyquist here. It works with VS2015 for both x86 and x64 and Ubuntu 14/GCC 4.8 (further back it looks like there isn’t a pre-built package for wxWidgets 3). There is also a “vs2013” branch there that builds on VS2013 and likely earlier. It does use and while that part is isolated to one file, it does require setting a compiler flag before GCC 5 (where they changed the default). I don’t have access to an OS X box, so I don’t know how things would fare there.

despite the code comment, that just defines the Nyquist function RRANDOM Appendix 3: XLISP: An Object-oriented Lisp
REAL-RANDOM is derived from RRANDOM:

(defun real-random (from to)
  (+ (* (rrandom) (- to from)) from))