#!/usr/bin/env python # coding: utf-8 # > This is one of the 100 recipes of the [IPython Cookbook](http://ipython-books.github.io/), the definitive guide to high-performance scientific computing and data science in Python. # # # 3.5. Using interactive widgets: a piano in the notebook # You need to download the *Piano* dataset on the book's website. (http://ipython-books.github.io) # # This dataset contains synthetized piano notes obtained on `archive.org` (CC0 1.0 Universal licence). (https://archive.org/details/SynthesizedPianoNotes) # 1. Let's import a few modules. # In[ ]: import numpy as np import os from IPython.display import Audio, display, clear_output from IPython.html import widgets from functools import partial # 2. To create a piano, we will draw one button per note. The corresponding note plays when the user clicks on the button. This is implemented by displaying an `