<phyphox xmlns="https://phyphox.org/xml" version="1.19">
  <title>Audio Amplitude</title>
  <category>Acoustics</category>
  <icon format="base64">iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAABASSURBVHic7d19sF1VecfxtcNLIi8hgFSBSIhgxqngVAQFxcIMoijaKSC+4GDDFAXUgmR0RhFapB11QEWqBSwWHJ1aVFCJIFhRglZArHVGKzUkM0iJgRCBkCYhCbn32z9W0rnennv275yz1n72Xuf5/Jm5Z6/neU7OOftlrWeF4JxzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzzjnn2qWyDsA1C5gTQlhqHYeBd1ZVtXbQF+2cIxLXajuHEE60DsLAnGFeNCt1FM6VxD8gzvXhHxDn+vBrkPHzTAjh9dZBGHjcOgDnnHPOORdCGOFBIbBTCGFRCOHA7f+0KoSwoqqqiRSBuXyAPUIIh4UQ9gghbAshLK+q6lHbqAoAVMAbgJuATfx/G4EbgddZx+r+ELAH8F7gp8BEj/duFXAF8CLrWDsJOAL4SY/CzuQu4HDruF0IwFnAavF92wp8DtjLOu7OAM4Htgzw4djhGeAc6/jHFTAX+MYQ7xvASuAI6xxaD/jbIQs81VWAT4xs0PYPx30jvm8bgZOsc2kt4LJRPxlTfMo6n3FBvN4Y5HS4ny3ACdY5tQ5wcaICT3W2dV6lA+YAdyd+354EFlnn1hrEO1WTiYsM8QLweOv8SgZcneF9A1gO7G2dnzlgf2BNpiIDPAEcWB+JGxRwWsb3DeB2xvlaEpgF/GCAgj0MfAT4KPE+umocV7RlBSwgngqp7gLeR/zFGeQO5V9a52oGuGCAQt0C7DnltfOA2wZ4/RmWuZYG+KFY90nggmmvfRnwiPj6pxjHMwDgecA6sUhLgV17HGMX4FbxGGuB/SxyLQ3wN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NgN/ZR1/ZwBzgavQLwB/R0s2CB13wOHECYuqH2G4c1WnETuTXE7v1YjbiO1Nz8OnkLQOcCLwL/Q+Zd4AfI0h7lR1e4upjIibf744hLBzCGF9COE/q6raZBuVq0N80LcohDB/+z/9LoTwYFVVE3ZROeecc84555zGL9LHDLAghDBwk4qO21RV1VAPBf0DMmaAY0MIP7aOo2FPVlU1VFfL8Z377pzAPyDO9eEfEOf6GKrlpuu034YQxm0bBp8B4ZxzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzrlv+F8Vv8rVHE3oWAAAAAElFTkSuQmCC</icon>
  <description>Get the amplitude of sounds.

        This experiments simply records short intervals from the microphone and calculates the sound pressure level (SPL). Note that this calculation is a very naive approach and the results may be rather imprecise. Also, you will have to give a reference to calibrate the measurement.</description>
  <link label="Wiki">http://phyphox.org/wiki/index.php?title=Experiment:_Audio_Amplitude</link>
  <data-containers>
    <container size="4800">recording</container>
    <container size="4800">recordingSquared</container>
    <container>sum</container>
    <container>mean</container>
    <container>dbUncal</container>
    <container>lnMean</container>
    <container>userCalibration</container>
    <container static="true">ln10</container>
    <container size="0">time</container>
    <container>now</container>
    <container init="0">t0</container>
    <container init="0">resetTime</container>
    <container size="0">dB</container>
    <container init="0">calibration</container>
    <container init="60">target dB</container>
    <container>newCal</container>
  </data-containers>
  <input>
    <audio>
      <output component="out">recording</output>
    </audio>
  </input>
  <analysis sleep="0.1">
    <timer>
      <output as="out" append="true">now</output>
    </timer>
    <if equal="true">
      <input as="a" keep="true">resetTime</input>
      <input type="value" as="b">1</input>
      <input as="true" keep="true">now</input>
      <output>t0</output>
    </if>
    <append>
      <input type="value">0</input>
      <output>resetTime</output>
    </append>
    <subtract>
      <input keep="true">now</input>
      <input keep="true">t0</input>
      <output append="true">time</output>
    </subtract>
    <power>
      <input as="base" keep="true">recording</input>
      <input as="exponent" type="value">2</input>
      <output>recordingSquared</output>
    </power>
    <integrate>
      <input as="in" keep="true">recordingSquared</input>
      <output>sum</output>
    </integrate>
    <divide>
      <input>sum</input>
      <input type="value">2400</input>
      <output>mean</output>
    </divide>
    <log>
      <input as="value" keep="true">mean</input>
      <output>lnMean</output>
    </log>
    <log>
      <input as="value" type="value">10</input>
      <output>ln10</output>
    </log>
    <divide>
      <input keep="true">lnMean</input>
      <input keep="true">ln10</input>
      <input type="value">0.1</input>
      <output>dbUncal</output>
    </divide>
    <add>
      <input keep="true">dbUncal</input>
      <input keep="true">calibration</input>
      <output append="true">dB</output>
    </add>
    <subtract>
      <input keep="true">target dB</input>
      <input keep="true">dbUncal</input>
      <output>newCal</output>
    </subtract>
  </analysis>
  <views>
    <view label="Amplitude">
      <value label="Status">
        <input>calibration</input>
        <map min="0" max="0">NOT calibrated</map>
        <map>calibrated</map>
      </value>
      <value size="3" precision="1" unit="[[unit_short_decibel]]" label="Sound pressure level">
        <input>dB</input>
      </value>
      <separator height="1"/>
      <graph label="History" aspectRatio="1" labelX="Time" labelY="[[quantity_short_sound_pressure_level]]" unitX="[[unit_short_second]]" unitY="[[unit_short_decibel]]">
        <input axis="x">time</input>
        <input axis="y">dB</input>
      </graph>
      <button label="Clear history">
        <input type="empty"/>
        <output>dB</output>
        <input type="empty"/>
        <output>time</output>
        <input type="value">1</input>
        <output>resetTime</output>
      </button>
      <separator height="1"/>
      <info label="Please see the calibration tab to get proper results."/>
    </view>
    <view label="Calibration">
      <info label="This experiment uses a rather naive approach to determine the sound pressure level (SPL). You will need a reference sound with a known amplitude in dB. For example, you could set up a constant noise source and measure its sound pressure level with an external device. Enter the measured level as the reference SPL and push &apos;calibrate&apos; while the experiment is running."/>
      <separator height="1"/>
      <edit unit="[[unit_short_decibel]]" label="Reference SPL">
        <output>target dB</output>
      </edit>
      <button label="Calibrate">
        <input type="buffer">newCal</input>
        <output>calibration</output>
      </button>
      <value unit="[[unit_short_decibel]]" label="Calibration offset">
        <input>calibration</input>
      </value>
      <separator height="1"/>
      <info label="If you have done this before or on an identical device you may just enter the calibration offset from your previous calibration directly and press &apos;set offset&apos;."/>
      <separator height="1"/>
      <edit unit="[[unit_short_decibel]]" label="Custom offset">
        <output>userCalibration</output>
      </edit>
      <button label="Set offset">
        <input type="buffer">userCalibration</input>
        <output>calibration</output>
      </button>
    </view>
    <view label="FAQ">
      <info label="How accurate are these results?"/>
      <info label="For teaching and exploring? Probably good enough. For serious studies? Probably not, but other apps might perform better (see below). For scientific or health-related applications? Certainly not, get a dedicated device for this."/>
      <separator height="1"/>
      <info label="Why isn&apos;t this already calibrated?"/>
      <info label="phyphox is available on more than 10000 devices. Most of them have different microphones, different electronics and different software - all affecting their response to sound. We cannot calibrate them all, but in some cases there are apps which only target a limited number of devices (like apps specific to iPhones) which can calibrate these few devices. If you are interested in better results without calibration, you should check out specific apps for your device."/>
      <separator height="1"/>
      <info label="Why can&apos;t we get a better calibration?"/>
      <info label="We wanted a simple procedure to allow students to get comparable data across different devices. With decent equipment you could calibrate the frequency dependency of your microphone as well and maybe even compensate for non-linear responses. If you have such equipment and want to try it, please let us know - we already have phyphox-experiments that allow for more advanced calibration techniques."/>
    </view>
  </views>
  <export>
    <set name="Amplitudes">
      <data name="Time (s)">time</data>
      <data name="Sound pressure level (dB)">dB</data>
    </set>
    <set name="Calibration">
      <data name="calibration offset (dB)">calibration</data>
    </set>
  </export>
</phyphox>