# Quick Curves - Transcendental Optimisations

Floating-point arithmetic is a precise and powerful way to model real-world curves, but some such operations are disproportionately expensive. Transcendental mathematical functions are often required in 3D audio runtimes, to apply psychoacoustic curves or convert between loudness, pitch and coordinate representations, and can eat up a lot of processing cycles.

This chapter includes audio-friendly ways to speed those up while still staying accurate enough for audio control purposes. Example C++ and SIMD intrinsic code computes logarithms, exponentials, sines, cosines, arctangents and four distinct sorts of 'random' numbers faster than standard library routines. It also illustrates nuances which technical audio designers benefit from understanding in principle, even if the exact details pass them by.

Concepts: gain and decibel attenuations, rectangular and polar coordinates, bulk conversions, trigonometry, PI, pitch randomisation, shuffling, normal distribution, pseudorandom distributions, 'designer random', compiler arithmetic intrinsics, edge-cases, optimisation-investigation and speed-up settings, IEEE-754 numeric representation, 32- and 64 bit integers, single- and double-precision floating-point values, square roots, Newton-Raphson, processor pipelines, data dependencies and latency.

Platforms and machine architectures discussed: Android, ARM NEON, ARM64, C++20, Clang, GCC, Intel, MIPS, POSIX, SSE, Visual Studio, VMX.

## Sample dialogue

Programmer: Which random would you like?

Designer: (puzzled) Normal random, what d'ya mean, which?

Programmer: Can the same thing play twice in a row?

Designer: (puzzleder) Course not, that's not random, is it?

This plot of quadraphonic Ambisonic panning coefficients was drafted in QL SuperBASIC. A professionally-drawn vector-graphic version appears in the book itself, along with fast code to implement it and an explanation of how it works.