Listening function Voice: Mathematica's sound function test

Source: Internet
Author: User


You can see in this blog that Mathematica replaces complex computing in many places. Mathematica is a powerful mathematical software. Many netizens can't wait to install Mathematica after seeing some demos on this blog. Mathematica has many more functions than you think. Today, let's look at an interesting Mathematica function-the play function. We will use Mathematica to do some simple experiments on functions and sound.
The essence of sound is the wave function. Defines the range of A wave function and a defined domain. Mathematica can play the sound it represents. Run this statement in Mathematica:
Play[Sin[4000 t], {t, 0, 2}]

================================= I am a cute splitting line ======================== =

In the above example, 4000 represents the cycle size of the function, that is, the tone of the sound. Change 4000 to 8000. You can hear a higher tone:
Play[Sin[8000 t], {t, 0, 2}]

The function shape determines the tone. For different periodic functions, the sound is different. Try the following three different functions:
Play[Sin[5000 t], {t, 0, 2}]
Play[Tan[5000 t], {t, 0, 2}]
Play[Mod[5000 t, 50], {t, 0, 2}]

What if our function is not a periodic function? I remember that in a music lesson, the teacher once told us the difference between music and noise.
Play[Random[], {t, 0, 2}]

================================= I am a cute splitting line ======================== =

The volume is controlled by the amplitude, which means the size of the function value. Run the following three statements and you will find that the function can be expressed in sound. You can even let others guess what function you are playing based on the volume change.
Play[Sin[4000t] t, {t, 0, 2}]
Play[Sin[4000t] t^2, {t, 0, 2}]
Play[Sin[4000t] Log[t], {t, 0, 2}]
Play[Sin[4000t] Sin[8t], {t, 0, 2}]
Play[Sin[4000t] Mod[t,0.4], {t, 0, 2}]


When a Composite Function appears, something really interesting begins. Let's imagine what the sin (x ^ 2) image looks like. The larger the absolute value of X, the faster the value of x ^ 2 changes. The shorter the wavelength, the higher the tone. That is to say, the shape of x ^ 2 has a direct relationship with the pitch. So what you will hear is a sound that immediately reminds you of quadratic functions:
Play[Sin[5000 t^2], {t, -1, 1}]

Before running the following statement, you can first imagine the sound of each function:
Play[Sin[5000/t], {t, 0, 2}]
Play[Sin[5000 * Sqrt[t]], {t, 0, 2}]
Play[Sin[5000 * Sin[4t]], {t, 0, 2}]
Play[Sin[2000 t * Sin[8t]], {t, 0, 2}]

================================= I am a cute splitting line ======================== =

What is the result of adding two functions? The following two examples are quadratic functions plus sine functions, and reciprocal functions plus noise. You can immediately observe that the addition of a function is the addition of sound.
Play[Sin[5000 (t-1)^2] + Sin[5000 * Sin[4t]], {t, 0, 2}]
Play[Sin[5000/t] + Random[], {t, 0, 2}]

We can also give some other examples to illustrate this phenomenon. For example, if sin [5000 t] And cos [5000 t] have the same sound, the cycle of the function sin [5000 t] + cos [5000 t] must be the same as that of the original one, only the amplitude is larger.

Let's look at the example below. Why can't I hear the sound of the MOD function but the sound of the sine function?
Play[Sin[5000 t] + Mod[5000 t, 50], {t, 0, 2}]
The reason is simple. Among the above two functions, the amplitude of the MOD function is greater, so its sound is much greater than that of the sin function, so the sin function can only be drowned in the noise of the MOD. If the sin function is multiplied by a coefficient of 50, the two functions have the same sound:
Play[50 * Sin[5000 t] + Mod[5000 t, 50], {t, 0, 2}]

Add the reciprocal function to 1/5 of the noise to produce a "reciprocal function sound" with slight noise ".
Play[Sin[5000/t] + Random[]/5, {t, 0, 2}]

================================= I am a cute splitting line ======================== =

Of course, sound can be added and subtracted. For sound mixing of multiple functions, minus a specific function, you can play the corresponding sound from the sound mixing. These scenes often appear in movies, so we can use computers to eliminate the special background sound in the captured audio. From the perspective of functions, such a thing is theoretically feasible. For example, you secretly recorded the conversation between your mm and her ex-boyfriend, but the most important one was covered by a sudden phone call. Now, you only need to get a sample of a phone ringtone, And then subtract the phone ringtone from the original sound. Phone ringtones are very simple wave functions. You can generate one by yourself. Science fiction movies often see similar things: the secret weapon produced by a super boss can emit harmful Wave Functions f (x ), then, the talented scientists tried to compress the-f (x) function in a race against the negative and negative amount of harmful waves. Adding a-f (x) to a wide variety of wave functions is actually equivalent to subtracting f (x) from a "hybrid wave ).
A few days ago, when I asked mm in the department for music accompaniment for the gala, I suddenly thought of an interesting question: is it possible to calculate the difference between a Song's original sound and its own singing? In theory, this provides an interesting music cancellation algorithm, which is equivalent to an equally interesting replaying similarity evaluation standard (to see how many voices are left in the difference ).

================================= I am a cute splitting line ======================== =

Do not think that the sound of a function is so ugly. You can use appropriate theoretical knowledge and skills to make sound sounds. Mathematica's official website has a simple and beautiful sound function, which is written here for your appreciation:
Play[(2 + Cos[50 t])*Sin[2000*(1 + Round[2 t])*t], {t, 0, 3}]

Matrix67 original
Please indicate the source of the post
For the first time, many things involved in this aspect are self-made guesses, and there may be theoretical errors. please correct me!
At the same time, we look forward to seeing more interesting inferences through the Mathematica experiment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.