Multiplying mix is meant to be used in multiple uses.
Multiply with constant = change volume
Multiply with linear function = linear fade
Multiply with cubic spline¹ = cubic spline fade
Multiply with 200Hz sine wave = “harsh & unmusical” distortion
Multiply with 1000Hz sine wave = bigger “harsh & unmusical” distortion
Multiply two different songs = undecipherable effect!!!
¹ can be achieved by generating it in a programming language, then converting to bytes, then converting to a file which can be opened raw by Audacity
Multiply with constant = change volume [ got amplify for that ]
Multiply with linear function = linear fade [ got fade for that ]
Multiply with cubic spline¹ = cubic spline fade [got adjustable fade for that ]
Multiply with 200Hz sine wave = “harsh & unmusical” distortion [ got ring-modulator for that ]
Multiply with 1000Hz sine wave = bigger “harsh & unmusical” distortion [ got ring-modulator for that ]
Multiply two different songs = undecipherable effect!!! [ a very rare requirement, but achievable via Nyquist Prompt ]
Indeed, one of the main reasons for the Nyquist Prompt is to provide a means of performing unusual effects that are otherwise unlikely to implemented. A few other audio editors have a similar feature, such as GoldWave’s “script” feature. or Cakewalk Cal scripts, but I’ve not come across any that can match Audacity’s Nyquist scripting.
I believe Adjustable Fade… only provides linear and sine/cosine fades. While it is possible to duplicate, fade, multiply (must be done with a third party plug-in; Amplify… cannot be used as it doesn’t have a direct volume factor input) by constant and mix to create any polynomial including the four pieces of the cubic spline, not all fades can be done like this and it is sometimes more convenient to multiply with an existing wave instead.
This image shows the result of multiplying by a cubic spline. This result can be stacked in intervals of 1⁄4 its length to produce a continuous tone (as long as the tone frequency is aligned). It can also be stacked in the same intervals but with linearly increasing volume, and this cubic spline has the property of a continuous linear increase in this case. It can be useful for a sample of 0.25 seconds for an audio editor where it’s possible to place notes every 0.0625 seconds.
Nyquist does provide a multiplication function that works on number, sounds and multi-channel sounds (See: MULT http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index618), which is convenient because multiplication is commonly used with sounds.
To perform division on sounds, you need to write your own function.
If you are dealing with very short sounds, then probably the easiest way would be to grab the sounds as arrays of sample values, and loop through the arrays. For longer sounds it will be more efficient to use logarithmic arithmetic operations or the RECIP function: http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index570)
Note that when using RECIP, you still have to guard against division by zero.
Division is not generally useful in itself as a sound effect, because as the divisor approaches zero, the result can become extremely large (far in excess of 0 dB).
So when this is used on a value of 0 it returns an error, the sample is deleted, stays 0, becomes NaN or what?
Classic floating point division says:
• a positive number divided by 0 is Infinity
• a positive number divided by -0 is -Infinity
• a negative number divided by 0 is -Infinity
• a negative number divided by -0 is Infinity
• ±0 divided by ±0 is NaN
which is what I would expect from a properly working division function. After all it’s possible for samples to be Infinity, -Infinity or NaN in Audacity, making sample views sometimes show as a big blue screen.
But floating point isn’t the same as the mathematical “𝖱𝖾𝖺𝗅 𝗇𝗎𝗆𝖻𝖾𝗋𝗌” and don’t necessarily follow the same rules. Please stop saying the same misconception about floating point division by zero.
The IEEE floating-point standard, supported by almost all modern floating-point units, specifies that every floating point arithmetic operation, including division by zero, has a well-defined result. The standard supports signed zero, as well as infinity and NaN (not a number). There are two zeroes: +0 (positive zero) and −0 (negative zero) and this removes any ambiguity when dividing. In IEEE 754 arithmetic, a ÷ +0 is positive infinity when a is positive, negative infinity when a is negative, and NaN when a = ±0. The infinity signs change when dividing by −0 instead.
In mathematics, division by zero is division where the divisor (denominator) is zero. Such a division can be formally expressed as a/0 where a is the dividend (numerator). In ordinary arithmetic, the expression has no meaning, as there is no number which, when multiplied by 0, gives a (assuming a ≠ 0), and so division by zero is undefined.
This discussion has diverged away from anything to do with Audacity. For discussion about mathematics and/or IEEE 754, this is not the appropriate forum.
No. I disapproved your post because it had nothing to do with Audacity, and this is the Audacity forum.
I had already told you that this is not an appropriate forum for discussion about mathematics and/or IEEE 754, but you decided to send another post that has nothing to do with Audacity, so I disapproved it in accordance with forum policy.