#!/usr/bin/env python # coding: utf-8 # # The sound Of Hydrogen # Inspired by [minutephysics](https://www.youtube.com/watch?v=qyi5SvPlMXc), and the explanation do do it in mathematica: [The sound of hydrogen](https://www.youtube.com/watch?v=IhvW8yZdE5A). # # The goal of this notebook is to show how one can play a sound file in notebook, using Html5 <audio> tag to play it dirrectly inside the browser. # # To do this we use the spectrum of hydrogen that we shift the into the audible range. You can listen to it in the last cell of this notebook. # Wait a few second if you are on nbviewer, the notebook is not light (someone to update it to use mp3? ogg? or a compressed format?) # # Please be aware that the html5 player is not working on some old browser and IE. # \[Edit\] apparently the process of converting something not audible into sound have diffent naming: sonify, # sonification or auralizing according to the comment on twitter. # In[1]: get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: from __future__ import division, print_function, absolute_import import scipy.constants as const import numpy as np import scipy from matplotlib.pyplot import plot from scipy.io import wavfile from IPython.core.display import HTML, display # In[3]: # this is a wrapper that take a filename and publish an html