How does a function sound?

Periodic functions are a great model for sounds. Sounds are physical vibrations in the air, which can be described very well with the right functions. Physically, the independent variable is always time t. However, Math-Nodes can also output sounds if you choose x as the independent variable, for example. In the following examples, we will take a look at how you can generate sounds with functions and change their pitch and sound step by step.

1 The first sound

To generate a sound in Math-Nodes, you need at least 3 cards: One card for the independent variable, one function machine, and the audio card. The sine function in this example oscillates back and forth \(440\) times per second, so it goes through \(2 \pi\) for \(t = 1\) 440 times. The resulting sound has a frequency of \(440\) Hz. Click on Sound On/Off in the audio machine, start the animation of the independent variable, and see if you can hear anything.

2 The influence of parameters

If you have made it this far, you have created your first sound. Great! Here is your first research assignment: Investigate the influence of the parameters \(a,b,c,d\) on what you hear, i.e., your auditory impression. To do this, change the values of the parameters on the corresponding cards. What happens with negative values?

3 Linking machines and analyzing with the graph module

In this task, you should first compare the function \(f(t) = a \cdot \sin(b \cdot 2 \pi \cdot t)\) with the function \(g(f(t)) = (a \cdot \sin(b \cdot 2 \pi \cdot t))^2\) graphically and then audibly. Do you have a hypothesis about the influence of the function \(g\) on the sound? Write it down in the workbook. Then listen to the functions. Sketch the graph of \(g(f(t))\) in the workbook.

4 The Piano-Card

A new input card is available for generating sounds: the piano. The card has a keyboard that can be controlled either with the mouse or with the letters A to L on the keyboard.

What happens to the values for \(f\) and \(t\) when you press a key for a longer period of time? Describe it in the workbook.

Compare the values for f when you press A4 and A5.

Additional question: What happens if you press a second key before releasing the first one or press multiple keys simultaneously?

Build an Instrument

If you set different frequencies for the parameter \(f\) and animate the independent variable \(t\), you can generate sounds like with a real instrument.

To avoid having to set new frequencies each time and manually animate the independent variable \(t\), you can use the piano card. Connect it to the function \(g\) so that you can play different sounds.

5 Piano or Violin?

An important characteristic of an instrument is how the volume of a sound changes after it is played. For example, violins start quietly and get louder as they are bowed. A dampened piano, on the other hand, starts loud and quickly gets quieter.

Try to change the volume envelope of your sounds using the given machines. In subtask b, you can view a sample solution.

Functions like \(g\) in subtask b are also called envelopes. Can you imagine why?

    Tip: Enter Functions Yourself

    In the next task, you will create your own function machines. Use the free input for this. Here are some important rules:

    Function name: Every function needs a name, e.g., \(k\) and a variable, e.g., \(t\). Then write: \(k(t) = ...\)

    Parameters: You can use additional parameters, e.g., \(k(t) = a \cdot t^2 + b\). Don't forget to include the multiplication symbols!

    Special functions: Square root = \textbackslash sqrt(), Absolute value = \textbackslash abs()

    Connections: The independent variable at the top of the machine must have the same name as in your function. All parameters must be connected.

    Piano card: Always has the variable \(t\) and the parameter \(f\) for the pitch.

    6 Word to sound

    Create a patch such that the resulting sound corresponds to the following descriptions. Provide the function equations in your workbook.

    a) The sound starts quietly and gets louder and louder.

    b) The sound starts loud, then gets quieter, and after a certain time gets louder again.

    c) The sound starts loud and gets quieter and quieter until it is no longer audible. At the same time, the volume fluctuates periodically.

    7 Timbre

    Different instruments sound different, even if they have the same pitch and volume. This is because the vibrations of the instruments can be described by periodic functions, but these are not pure sine functions.

    One way to generate such more complex periodic functions is to chain a sine function with other functions. Try out the given machines and describe in your workbook how the sound differs. Also refer to the graph.

    8 Instrument Workshop

    Create an instrument of your choice. Vary the timbre and volume curve. Describe the sound of your instrument in your workbook and how you created it. Sketch your patch and the graph of a sound.