" Type `help parsesig`, `help imagesc`, and `help abs` for more information.\n",
"prompt_number": 3
"\n",
},
" This step gives you some visual intuition about how sounds (might) overlap.\n",
{
"\n",
"cell_type": "markdown",
"4. Let's separate sources!\n",
"metadata": {},
"\n",
"source": [
" K = 2;\n",
"Plot the spectrogram:"
" [y, W, H] = sourcesep(x, fs, K);\n",
]
"\n",
},
" Type `help sourcesep` for more information.\n",
{
"\n",
"cell_type": "code",
"5. Plot and listen to the separated signals.\n",
"collapsed": false,
"\n",
"input": [
" plot(t, y)\n",
"import librosa\n",
" xlabel('Time (seconds)')\n",
"librosa.stft?\n",
" legend('Signal 1', 'Signal 2')\n",
"librosa.display.specshow?"
" sound(y(:,1), fs)\n",
],
" sound(y(:,2), fs)\n",
"language": "python",
"\n",
"metadata": {},
" Feel free to replace `Signal 1` and `Signal 2` with `Kick` and `Snare` (depending upon which is which). \n",
"outputs": [],
"\n",
"prompt_number": 4
"6. Plot the outputs from NMF.\n",
},
"\n",
{
" figure\n",
"cell_type": "markdown",
" plot(W(1:200,:))\n",
"metadata": {},
" legend('Signal 1', 'Signal 2')\n",
"source": [
" figure\n",
"Use NMF to decompose the spectrogram:"
" plot(H')\n",
]
" legend('Signal 1', 'Signal 2')\n",
},
"\n",
{
" What do you observe from `W` and `H`? \n",
"cell_type": "code",
"\n",
"collapsed": false,
" Does it agree with the sounds you heard?\n",
"input": [
"\n",
"from sklearn.decomposition import NMF\n",
"7. Repeat the earlier steps for different audio files.\n",
"NMF?"
"\n",
],
" * `125BOUNC-mono.WAV`\n",
"language": "python",
" * `58BPM.WAV` \n",
"metadata": {},
" * `CongaGroove-mono.wav`\n",
"outputs": [],
" * `Cstrum chord_mono.wav`\n",
"prompt_number": 5
"\n",
},
" ... and more.\n",
{
"\n",
"cell_type": "markdown",
"8. Experiment with different values for the number of sources, `K`. \n",
"metadata": {},
"\n",
"source": [
" Where does this separation method succeed? \n",
"Plot the decomposed matrices:"
"\n",
]
" Where does it fail?\n",
},
"\n",
{
"\n",
"cell_type": "code",
"Section 2: Noise Robustness\n",
"collapsed": false,
"---------------------------\n",
"input": [],
"\n",
"language": "python",
"1. Begin with `simpleLoop.wav`. Then try others.\n",
"metadata": {},
"\n",
"outputs": []
" Add noise to the input signal, plot, and listen.\n",
},
"\n",
{
" xn = x + 0.01*randn(length(x),1);\n",
"cell_type": "markdown",
" plot(t, xn)\n",
"metadata": {},
" sound(xn, fs)\n",
"source": [
"\n",
"Use the inverse STFT to synthesize the separated sources:"
"2. Separate, plot, and listen.\n",
]
"\n",
},
" [yn, Wn, Hn] = sourcesep(xn, fs, K);\n",
{
" plot(t, yn)\n",
"cell_type": "code",
" sound(yn(:,1), fs)\n",
"collapsed": false,
" sound(yn(:,2), fs)\n",
"input": [
" \n",
"librosa.istft?"
" How robust to noise is this separation method? \n",
],
"\n",
"language": "python",
" Compared to the noisy input signal, how much noise is left in the output signals? \n",
"metadata": {},
"\n",
"outputs": [],
" Which output contains more noise? Why?\n"
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the columns of the matrix, $W$, otherwise known as *spectral atoms*, 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": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Bonus"
]
},
{
"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)...]`."