1,885
edits
Changes
→Three Approaches
Three approaches to this problem are provided:
# The basic or Naive algorithm (<code>vol1.c</code>). This approach multiplies each sound sample by 0.75, casting from signed 16-bit integer to floating point and back again, which . Casting between integer and floating point can be [[Expensive|expensive]] operations.
# A lookup-based algorithm (<code>vol2.c</code>). This approach uses a pre-calculated table of all 65536 possible results, and looks up each sample in that table instead of multiplying.
# A fixed-point algorithm (<code>vol3.c</code>). This approach uses fixed-point math and bit shifting to perform the multiplication without using floating-point math.