# VS 2015, x64, and Code Cleanup

**URL:** <https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218>\
**Category:** Compiling Audacity\
**Created:** [January 17, 2016, 10:19pm UTC](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218 "2016-01-17T22:19:08Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![cyrano](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@cyrano](https://forum.audacityteam.org/u/cyrano)\
**Post date:** [January 27, 2016, 3:04pm UTC](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218/21 "2016-01-27T15:04:47Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [February 1, 2016, 5:11pm UTC](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218/22 "2016-02-01T17:11:23Z")

</div>

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)

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

```

---

<div class="post-metadata">

**Author:** ![henric](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/h/6a8cbe/32.png) [@henric](https://forum.audacityteam.org/u/henric)\
**Post date:** [February 2, 2016, 6:00pm UTC](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218/23 "2016-02-02T18:00:28Z")

</div>

> [@steve](#):
>
> 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)
> 
> ```plaintext
> (setf *float-format* "%.14f")
> (dotimes (i 10)
> (print (real-random -1000000 1000000)))
> 
> ```

“REAL-RANDOM” is implemented like this:

```plaintext
/* 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;
}

```

---

<div class="post-metadata">

**Author:** ![henric](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/h/6a8cbe/32.png) [@henric](https://forum.audacityteam.org/u/henric)\
**Post date:** [February 2, 2016, 6:06pm UTC](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218/24 "2016-02-02T18:06:46Z")

</div>

> [@henric](#):
>
> > [@Robert J. H](#):
> >
> > Sorry, I’ve been talking about the noise creation in Nyquist.
> 
> If one wanted to change this, using a better RNG at least on Windows and adding a new function to do Gaussian noise, the right place to do so would probably be upstream in the original [Nyquist library](http://www.cs.cmu.edu/~music/nyquist/). Adding a “snd-whiten” or “snd-whiteg” function wouldn’t be all that intrusive to the Nyquist code; I think adding a line to [sndfnintptrs.h](https://github.com/audacity/audacity/blob/master/lib-src/libnyquist/nyquist/nyqsrc/sndfnintptrs.h) would do it. Still, upstream is better.

To see what the actual implications would be, I implemented a “noiseg” for Nyquist [here](https://github.com/henricj/audacity/tree/vs2015eol). 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.

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [February 2, 2016, 7:30pm UTC](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218/25 "2016-02-02T19:30:25Z")

</div>

> [@henric](#):
>
> “REAL-RANDOM” is implemented like this:
> 
> ```plaintext
> /* 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;
> }
> 
> ```

despite the code comment, that just defines the Nyquist function RRANDOM [Appendix 3: XLISP: An Object-oriented Lisp](http://www.cs.cmu.edu/~rbd/doc/nyquist/part19.html#index1617)  
REAL-RANDOM is derived from RRANDOM:

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

```

[Previous page](https://forum.audacityteam.org/t/vs-2015-x64-and-code-cleanup/41218.md?page=1)
