Commit b06d6158 authored by Steve Tjoa's avatar Steve Tjoa

nmf

parent c8186a80
...@@ -12028,7 +12028,6 @@ div#notebook { ...@@ -12028,7 +12028,6 @@ div#notebook {
<li><a href="pca.html">Principal Component Analysis</a> (<a href="pca.ipynb">ipynb</a>)</li> <li><a href="pca.html">Principal Component Analysis</a> (<a href="pca.ipynb">ipynb</a>)</li>
<li><a href="nmf.html">Nonnegative Matrix Factorization</a> (<a href="nmf.ipynb">ipynb</a>)</li> <li><a href="nmf.html">Nonnegative Matrix Factorization</a> (<a href="nmf.ipynb">ipynb</a>)</li>
<li><a href="hpss.html">Harmonic-Percussive Source Separation</a> (<a href="hpss.ipynb">ipynb</a>)</li> <li><a href="hpss.html">Harmonic-Percussive Source Separation</a> (<a href="hpss.ipynb">ipynb</a>)</li>
<li><a href="nmf_source_separation.html">Exercise: Source Separation using NMF</a> (<a href="nmf_source_separation.ipynb">ipynb</a>)</li>
</ol> </ol>
</div> </div>
......
...@@ -204,8 +204,7 @@ ...@@ -204,8 +204,7 @@
"source": [ "source": [
"1. [Principal Component Analysis](pca.html) ([ipynb](pca.ipynb))\n", "1. [Principal Component Analysis](pca.html) ([ipynb](pca.ipynb))\n",
"1. [Nonnegative Matrix Factorization](nmf.html) ([ipynb](nmf.ipynb))\n", "1. [Nonnegative Matrix Factorization](nmf.html) ([ipynb](nmf.ipynb))\n",
"1. [Harmonic-Percussive Source Separation](hpss.html) ([ipynb](hpss.ipynb))\n", "1. [Harmonic-Percussive Source Separation](hpss.html) ([ipynb](hpss.ipynb))"
"1. [Exercise: Source Separation using NMF](nmf_source_separation.html) ([ipynb](nmf_source_separation.ipynb))"
] ]
}, },
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy, scipy, matplotlib.pyplot as plt, librosa, urllib, IPython.display"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exercise: Source Separation using NMF"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Goals:\n",
"\n",
"1. Separate sources using NMF.\n",
"2. Analyze and classify separated sources."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Download an audio file:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"urllib.urlretrieve?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Load an audio file:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"librosa.load?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the spectrogram:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"librosa.stft?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"librosa.logamplitude?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"librosa.display.specshow?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use NMF to decompose the spectrogram:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"librosa.decompose.decompose?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the spectral profiles and temporal activations of each component individually:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plt.subplot?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the inverse STFT to synthesize the separated sources. (`librosa.istft` expects a full, complex-valued spectrogram. Therefore, you will need to include the phase of the original spectrogram in your reconstruction. See [the notebook on NMF](nmf.html) for more details.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"librosa.istft?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the reconstructed outputs as inputs into the kick/snare classifier that you created in an earlier exercise. Observe the results; are you able to automatically classify the separated sources?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## For Further Exploration"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use different audio files."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Alter the rank of the decomposition, `n_components`. What happens when `n_components` is too large? too small?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"NMF is a useful preprocessor for MIR tasks such as music transcription. Using the steps above, build your own simple transcription system that returns a sequence of note events, `[(onset time, class label, volume/gain)...]`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[&larr; Back to Index](index.html)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment