{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Room Impulse Responses (RIRs)\n", "\n", "[return to main page](index.ipynb)\n", "\n", "To measure the impulse response of a room\n", "(more precisely: the impulse response from one specific point in the room to another specific point in the room),\n", "the room can be excited with an impulse (or bang) and the result (= the impulse response) can be recorded with a microphone." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A Very Simple Measurement Procedure\n", "\n", "In this unit we will measure the impulse response of our seminar room.\n", "There are several possibilities to excite the room - bursting balloons, gunshots, electrical spark discharges, ...;\n", "for simplicity (and for safety reasons), we use two wooden boards which we clap together.\n", "\n", "![Two Wooden Boards](images/wooden_boards.jpg)\n", "\n", "That's not ideal - ideally all frequencies should be excited equally - but it\n", "shall be sufficient for demonstration purposes.\n", "\n", "We will record the room response with the software [Audacity](http://web.audacityteam.org/) and export the result as WAV file (using the menu \"File\" $\\to$ \"Export Audio...\" or \"Export Selected Audio...\").\n", "\n", "As we will see in a later unit, there are *much better* ways to measure room impulse responses!\n", "\n", "If you are not able to join us for the measurement, you can still try the following exercises with this example room impulse response:\n", "\n", "[data/rir_clap.wav](data/rir_clap.wav)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Listening to the Room Impulse Response\n", "\n", "*Exercise:* Listen to the WAV file containing the impulse response.\n", "Do you get a clear impression about the recorded room?\n", "\n", "*Exercise:* Convolve the measured impulse response with different audio signals (see the [`data/`](data/) directory for some example WAV files) and listen to the respective results.\n", "\n", "Does it sound like the measured room? If not, what's different?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the resulting signal is too soft or too loud, you can normalize it with the function `tools.normalize()` (defined in [tools.py](tools.py))." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import tools" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tools.normalize?" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## Plotting the Room Impulse Response\n", "\n", "*Exercise:* Plot the impulse response; once with linear amplitude and once in decibel.\n", "Which is more meaningful?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A Function for Plotting\n", "\n", "*Exercise:* Write a function called `plot_impulse_response()`, which plots a given impulse response with the following properties:\n", "\n", "* The x-axis shall be labelled with the time in milliseconds.\n", "\n", "* The y-axis shall be labelled with the amplitude in dB, in a way that the absolute maximum of the impulse response is at 0 dB." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Estimating the Reverberation Time\n", "\n", "*Exercise:* Just by looking at the figure, try to estimate the reverberation time $T$ (sometimes also called $RT$).\n", "This is the time in which the level has decreased by 60 dB after the maximum level (corresponding to the direct sound component).\n", "If the SNR isn't good enough, you might also look at the time until -30 dB are reached and multiply this time by 2 (this is called $T_{30}$)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's do it in a more systematic way.\n", "The time profile of the energy can be represented by the normalized _energy decay curve_ (EDC) defined as\n", "\n", "$$\n", "L(t) := \\frac{\\int_{t}^{\\infty} h^2({\\tau}) d\\tau}{\\int_{0}^{\\infty} h^2({\\tau}) d\\tau}.\n", "$$\n", "\n", "Note that the denominator normalizes the energy so that $L(t)$ is unity (0 dB) at $t=0$.\n", "In practice, the integrals can be evaluated only within a limited time interval, so $\\infty$ needs to be replaced by a practical value $t_\\rm{end}$.\n", "\n", "*Exercise:* Complete the function `energy_decay_curve`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def energy_decay_curve(ir):\n", " L = np.zeros_like(ir)\n", "\n", "# ???\n", "\n", " return L / L[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*Exercise:* Plot the energy_decay curve of the impulse response in decibel.\n", "Since $L(t)$ represents the energy of the impulse response, $10\\log_{10}(\\cdot)$ should be used instead of $20\\log_{10}(\\cdot)$." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Please check the following.\n", "* Does $L(t)$ decrease monotonically?\n", "* Is it 0 dB at $t=0$?\n", "* Is it easier to estimate the reverberation time $T$ by visual inspection?\n", "\n", "_Exercise:_ Compute reverberation time RT20 by using the function `tools.rt20`. Try different values for `t0` and see how the resulting reverberation time changes." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to the stardard [ISO 3382](https://www.iso.org/obp/ui/#iso:std:iso:3382:-1:ed-1:v1:en), the reverberation time has to be computed for 1 or 1/3-octave bands.\n", "Also the results must be averaged for several source and receiver positions.\n", "Here we estimated the reverberation time from a single impulse response and the whole audible frequency range was considered for conveience." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Surfing the Web\n", "\n", "In the interwebs, there are many places where you can find room impulse responses.\n", "\n", "A few suggestions:\n", "* Pori Concert Hall\n", "\n", " * overview http://www.acoustics.hut.fi/projects/poririrs/\n", " \n", " * download http://legacy.spa.aalto.fi/projects/poririrs/wavs/omni.zip\n", " \n", " * extract `s1_r1_o.wav`\n", " \n", " * convert from stereo to mono\n", " \n", "* SpACE-Net\n", "\n", " * overview http://www.space-net.org.uk/index-22592.html\n", " \n", " * Maes Howe http://www.space-net.org.uk/node/51/index.html\n", " \n", " * download [B-format: W and X Channels](http://www.space-net.org.uk/files/MH3_000_WX_48k.wav), but only use the \"W\" channel\n", " \n", " * Hamilton Mausoleum http://www.space-net.org.uk/node/52/index.html\n", " \n", " * download [B-format: W and X Channels](http://www.space-net.org.uk/files/HM2_000_WX_48k.wav), but only use the \"W\" channel\n", "\n", " * St Andrew's Church http://www.space-net.org.uk/node/53/index.html\n", " \n", " * download [B-format: W and X Channels](http://www.space-net.org.uk/files/Lyd3_000_WX_48k.wav), but only use the \"W\" channel\n", " \n", " * York Minster http://www.space-net.org.uk/node/54/index.html\n", " \n", " * download [B-format: W and X Channels](http://www.space-net.org.uk/files/Minster1_000_WX_48k.wav), but only use the \"W\" channel\n", "\n", "* EMES Virtual Rooms\n", "\n", " * a few free IRs http://www.emes.de/pageseng/products/Impulsresponse/eimpulse.htm\n", "\n", " * information http://www.emes.de/pdf/Freesampletxt2-1.pdf\n", "\n", " * one example WAV http://www.emes.de/impulsefiles/Gothic%20Church.wav\n", " \n", " * convert from stereo to mono\n", " \n", "* Aachen Impulse Response Database\n", "\n", " * http://www.ind.rwth-aachen.de/en/research/tools-downloads/aachen-impulse-response-database/\n", " \n", "* The World's Longest Reverb\n", "\n", " * article: http://www.independent.co.uk/news/science/now-weve-heard-it-all-acoustic-scientists-shatter-the-world-record-for-longest-ever-echo-9062134.html\n", " \n", " * soundcloud: https://soundcloud.com/sonicwonderland/sonic-wonderland-worlds\n", "\n", "*Exercise:* Download some of them (maybe not the world's longest reverb), listen to them, plot them and estimate their reverberation time $T$.\n", "\n", "Can you recognize the *direct sound*, the *early reflections* and the *late reverb*?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solutions\n", "\n", "If you had problems solving some of the exercises, don't despair!\n", "Have a look at the [example solutions](rir-solutions.ipynb)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", " \n", " \"CC0\"\n", " \n", "
\n", " To the extent possible under law,\n", " the person who associated CC0\n", " with this work has waived all copyright and related or neighboring\n", " rights to this work.\n", "

" ] } ], "metadata": { "kernelspec": { "display_name": "Python [default]", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.4" } }, "nbformat": 4, "nbformat_minor": 1 }