Using Wolfram to Play Functions

53 views Asked by At

As a blind person, I am curious as to whether or not I can use Wolfram to play functions. For example, if I were to plugg in y = x squared from -10 to 10, I would expect to hear a decreasing tone as the function flattens out, then a normal tone at the origin, then tones of increasing pitch as the function moves towards positive infinity.

2

There are 2 answers

1
Edmund On

You may use Play. However, you would not get much of a sound with that function. You should try a sine or cosine function to start.

0
Algorithmic Canary On

Using the play function and sine you can create a function that does what you want mostly ( using amplitude instead of frequency).

sinPlay[f_, { start_, end_},  baseFreq_] := EmitSound[ Play[Sin[x *baseFreq]* f[x], {x,start,end}]]

This function maps the height of the function to amplitude. Note that because it scales sound to from silence to moderately loud, y=1 sounds the same as y=5, likewise y=2x sound the same as y=5x.

It is called like this (the x^2 function):

sinPlay[#*#  &, { 0, 2}, 1000]

#*# & is an anonymous function (into to them) that takes one number and squares it. {0, 2} is the part of the function you want to listen to in seconds. So {0, 2} generates a two second clip.

This is the square root function:

sinPlay[Sqrt[#] &, { 0,10}, 1000]

And this is the sine function:

sinPlay[Sin[#] &, { 0,10}, 1000]

Note the silence is because those are bottoms of the sine function which have been scaled to silence.

Using Frequency Instead

In theory is would be possible to use frequency instead. The function would look something like this:

 sinPlay[f_, { start_, end_},  baseFreq_] := EmitSound[ Play[Sin[x *baseFreq* f[x]], {x,start,end}]]

But then changes in frequency would also cause changes in time from the sine function. Perhaps something could be done using derivatives to fix this problem, but I have haven't worked it out. Wolfram supplies a function to calculate derivatives for you