title: Python audioop.rms() values from power to amplitude?
body: <p>My goal is to compare amplitude measurements from a sound level meter (in <em>dB SPL</em>) with simultaneously-recorded audio clips. </p>
  
  <p><a href="https://i.stack.imgur.com/6fLvI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6fLvI.jpg" alt="audio recording system diagram"></a></p>
  
  <p>I've been using <code>audioop.rms()</code> to summarize the wav audio clips.</p>
  
  <p>I wrote a quick function to convert from the raw sample power to decibels full scale:</p>
  
  <pre><code>def valueDBFS(value, sampleWidth):
  
      # use the sample width to look up the appropriate maximum sample size
      lookupBitDepth = {3: 8388607 , 2: 32768}
  
      return 10*np.log10(abs(value)/lookupBitDepth[sampleWidth])
  </code></pre>
  
  <p><a href="http://www.indiana.edu/~emusic/acoustics/amplitude.htm" rel="nofollow noreferrer">Unfortunately the resulting ratio of powers is proportional to the square of Sound Pressure Level, a ratio of amplitudes</a>.  </p>
  
  <p>I could fix the problem by taking the square-root of <em>dBFS</em>, but the units would become totally arcane. I'd much rather use a well-known relative scale to produce a linear comparison between the instruments. </p>
  
  <hr>
  
  <p>QUESTIONS:</p>
  
  <ol>
  <li><p>Is there an alternative to using <code>audioop.rms()</code> such that
  I can summarize the pressure amplitude of a wav file? </p></li>
  <li><p>Or, alternatively, is there a way to modify my function such that it
  transforms rms power values into pressure and returns them on a well-known decibel scale? </p></li>
  </ol>