##// END OF EJS Templates
Backport PR #5488: Added missing require and jquery from cdn....
Backport PR #5488: Added missing require and jquery from cdn. For some reason (I suppose some changes at the css level) the font size inside the input cells was fixed at 14 px... making the fonts really small in the reveal slideshows. This is really annoying... As a plus, I have also added the missing calls for require and jquery (as the full html template does). I think these fixes belong to 2.0, but I also know we are on the edge... so I hope to get it inside :wink: Cheers.

File last commit:

r16120:24b93a1d
r16230:ba262623
Show More
Beat Frequencies.ipynb
181 lines | 160.7 KiB | text/plain | TextLexer

Exploring Beat Frequencies using the Audio Object

This example uses the Audio object and Matplotlib to explore the phenomenon of beat frequencies.

In [9]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
In [10]:
from IPython.html.widgets import interactive
from IPython.display import Audio, display
import numpy as np
In [11]:
def beat_freq(f1=220.0, f2=224.0):
    max_time = 3
    rate = 8000
    times = np.linspace(0,max_time,rate*max_time)
    signal = np.sin(2*np.pi*f1*times) + np.sin(2*np.pi*f2*times)
    print(f1, f2, abs(f1-f2))
    display(Audio(data=signal, rate=rate))
    return signal
In [12]:
v = interactive(beat_freq, f1=(200.0,300.0), f2=(200.0,300.0))
display(v)
(220.0, 224.0, 4.0)
In [13]:
v.kwargs
Out[13]:
{u'f1': 220.0, u'f2': 224.0}
In [14]:
f1, f2 = v.children
f1.value = 255
f2.value = 260
plt.plot(v.result[0:6000])
(255.0, 260.0, 5.0)
Out[14]:
[<matplotlib.lines.Line2D at 0x1087ee990>]
No description has been provided for this image