#!/usr/bin/env python
# coding: utf-8
# # Oscillations and sound
#
# ### Experiments
# The oscillations of a body can generate sound waves in air. This is the case of musical instruments, but is also the case of other objects, as we can see in the following experiment.
# In[1]:
from IPython.display import Video
Video('./video/KostaBoda.mp4', width = 600)
# The sound produced depends on the characteristics of the body, which behaves as the source of mechanical waves.
#
#
# In[14]:
from IPython.display import Video
Video('./video/Kristall.mp4', width = 600)
# ### Analysis
#
# Now we can analyze the sound. To this aim we can use the Audacity app.
#
#
#
#
#
# We can import the file and look at the signal that has been recorded. The audio wave forces the membrane of the microphone to vibrate. The microphone acts as a **transducer**, generating a time dependent voltage that is proportional to the displacement of the membrane.
#
#
# Looking in greater detail, we observe a kind of complex fluctuation.
#
# For comparison, using Audacity, we show it in the figure here below, along with a pure sinusoidal function.
#
#
# We can describe the recorded sound as a superposition of different sinusoidal functions, applying the **Fourier analyis**.
#
#
#
# This plots (obtained using Audacity) represents the amplitude of the sinusoidal functions at different frequencies, whose sum will better describe the given signal.
#
# We can observe that the sound has an intense component at about 823 Hz, and other components at 342 Hz, and 1440 Hz, respectively.
# ### A surprising effect
#
# #### Resonance
#
# Now we can use te Audacity App to generate a continuous wave at 823 Hz, and play this sound close to the object that we have considered above. Suppose that we play the sound for 3 seconds
#
# * When the sound at 823 Hz is turned off **we can still ear a weak sound at the same pitch, coming from the object**
# * What is going on?
#
# > We have put the object in oscillation. The sound wave makes the object vibrate at this particular frequency, that is a frequency at which that body **can** oscillate. Once the body oscillates, it can itself generate a sound wave at that frequency, since it can transfer its motion to the air molecules near to its walls.
#
#
# ### Copyright and License
# --------------------------
# (c) 2022 Andrea Mandanici, Giuseppe Mandaglio, Giovanni Pirrotta, Valeria Conti Nibali, Giacomo Fiumara. All content is under Creative Common Attribution CC BY 4.0
# and all code is under [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
# In[ ]: