{
 "metadata": {
  "name": "",
  "signature": "sha256:be6cfcdd1ec9b91debb9cd9886337318485f67d942cd35bab648a2c9c40acdbe"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Onset Detection"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Automatic detection of musical events in an audio signal is one of the most fundamental tasks in music information retrieval. Here, we will show how to detect an *onset*, the start of a musical event.\n",
      "\n",
      "For more reading, see [this tutorial on onset detection by Juan Bello](https://files.nyu.edu/jb2843/public/Publications_files/2005_BelloEtAl_IEEE_TSALP.pdf)."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Load the audio file `simpleLoop.wav` into the NumPy array `x` and sampling rate `fs`. "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from essentia.standard import MonoLoader\n",
      "x = MonoLoader(filename='simpleLoop.wav')()\n",
      "print x.shape"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(132300,)\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot the signal:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fs = 44100.0\n",
      "t = arange(len(x))/fs\n",
      "plot(t, x)\n",
      "xlabel('Time (seconds)')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 21,
       "text": [
        "<matplotlib.text.Text at 0x5333590>"
       ]
      },
      {
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEMCAYAAADDMN02AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt8FNWhB/DfkoRHeARQCJBEg00w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759+Oqrr3DjjTci\nIyMD8+bNa3OnVAA4dOhQyzOhASA1NRV33HEH3n77bYSFhQEA1qxZg/nz5yMjIwNjxozBxYsXcejQ\nIXz88ccoKipCly7iK9SvXz/s3bsXQ4cORUJCAgBg2rRp2LBhQ8vyf/aznwEQNwyrrKwEAGzcuBFT\npkwBAIwfP77l1tCpqalYu3YtZs+ejU2bNqFPnz4tyxkyZEjL/ycKhjk6Nok6oWvXrgDEHQsjIiJa\n3u/SpQsaGxuhKApGjBiBLVu2dLgsz1NcJSUl2LBhAz788EPMmzcPX3zxBQBg+fLlSExM9Pt/gbZ3\nQ1QUpdV73bp1AwCEhYW1dEn5Wg4AJCYmYseOHSgpKcFjjz2GsWPH4vHHH2+ZX+5wiILBTw9ZSiBj\nEa688kocO3YMW7duBSDu3Ojr/uuXX355S9+/oig4dOgQcnJyMH/+fJw+fRrnzp1DXl5eqxOpO3bs\nAADk5ubi5ZdfRlNTEwDg5MmTGDZsGCorK/HNN98AAP7+97/j+uuv91vX0aNH45133gEArF69GidP\nngQg7s/SvXt33HnnnXjkkUdQUVHR8n+OHDmCyy+/vMO/A1F7GPxkWrK17HK5fL72nMfz54iICCxb\ntgy/+93vkJ6ejoyMDHz66adtln/ddde13N62sbERU6dORWpqKjIzM/Hggw8iKioKjz/+OBoaGpCa\nmoqRI0fiiSeeAADcfffduOyyy5Camor09HQsXrwY3bt3x6JFi/CLX/wCqampCA8Pxz333NOmnp7r\n8MQTT2DDhg0YOXIkVqxY0RLoX3zxBbKyspCRkYEnn3yypbXf0NCA6upqJCUlqf8Dk2NxOCc5lhzO\nuW3btpbuI7Nbs2YNSkpK8PzzzxtdFbIwtvjJsVwuF2bOnIm3337b6KoE7LXXXsNDDz1kdDXI4tji\nJyJyGLb4iYgchsFPROQwDH4iIodh8BMROQyDn4jIYRj8REQO8/9AXMq8UQcBKgAAAABJRU5ErkJg\ngg==\n",
       "text": [
        "<matplotlib.figure.Figure at 0x5188550>"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Listen:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from IPython.display import Audio\n",
      "Audio(x, rate=fs)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "\n",
        "                <audio controls=\"controls\" >\n",
        "                    <source src=\"data:audio/wav;base64,[encoded data, 352860 characters]\" type=\"audio/wav\" />\n",
        "                    Your browser does not support the audio element.\n",
        "                </audio>\n",
        "              "
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 22,
       "text": [
        "<IPython.lib.display.Audio at 0x532fe50>"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "`essentia.standard.OnsetRate`"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The easiest way in Essentia to detect onsets given a time-domain signal is using [`OnsetRate`](http://essentia.upf.edu/documentation/reference/std_OnsetRate.html). It returns a list of onset times and the onset rate, i.e. number of onsets per second."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from essentia.standard import OnsetRate\n",
      "find_onsets = OnsetRate()\n",
      "onset_times, onset_rate = find_onsets(x)\n",
      "print onset_times\n",
      "print onset_rate"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "[ 0.01160998  0.48761904  0.98684806  1.24226761  1.48607707]\n",
        "1.66666662693\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "`essentia.standard.AudioOnsetsMarker`"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "To verify our results, we can use [`AudioOnsetsMarker`](http://essentia.upf.edu/documentation/reference/std_AudioOnsetsMarker.html) to add a sound at the moment of each onset."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from essentia.standard import AudioOnsetsMarker\n",
      "onsets_marker = AudioOnsetsMarker(onsets=onset_times, type='beep')\n",
      "x_beeps = onsets_marker(x)\n",
      "Audio(x_beeps, rate=fs)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "\n",
        "                <audio controls=\"controls\" >\n",
        "                    <source src=\"data:audio/wav;base64,[encoded data, 352860 characters]\" type=\"audio/wav\" />\n",
        "                    Your browser does not support the audio element.\n",
        "                </audio>\n",
        "              "
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 24,
       "text": [
        "<IPython.lib.display.Audio at 0x5154d90>"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Sounds good!\n",
      "\n",
      "For more control over the onset detection algorithm, see [`OnsetDetection`](http://essentia.upf.edu/documentation/reference/std_OnsetDetection.html), [`OnsetDetectionGlobal`](http://essentia.upf.edu/documentation/reference/std_OnsetDetectionGlobal.html), and [`Onsets`](http://essentia.upf.edu/documentation/reference/std_Onsets.html)."
     ]
    }
   ],
   "metadata": {}
  }
 ]
}