Answers.Body: <p>To make the answer simple and hoping that I understand your question correctly, note first that</p>
  <ul>
  <li>You have given max SPL input level of 126 dB.</li>
  <li>Your plots are dB relative to max input level.</li>
  </ul>
  <p>Consequently simply add 126 dB to your plot levels to get dB SPL values.</p>
  <p>Edit: If the plots are reference to peak signal power (as indicated by comment) and not to max input level (i.e. full ADC level) than the difference between the two level must be taken care off.</p>
  <p>How to do that in R?, there could be multiple options, but a save option is to multiply the normalized input data by 10^(126/20)</p>
  <p>Obviously there is also a long way, using sensitivity, amplifier gains and ADC reference voltage, but the calculation should end up to max SPL input level</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-07T11:36:07.427Z
Answers.Text: Thanks for the suggestions. I noticed however that the 0 relative dB didn’t always correspond to the 126 dB SPL. Relative 0 corresponded to the loudest sound in my recordings. Calculating the Peak Power in each recording (using Raven Pro), I could then use that as the 0 reference. For example, if my Peak Power was -16, I added 110 (maximum input 126 - 16) to the values in my graphs. That way I could get a standardised quantification of sound across my spectrograms.
Answers.UserDisplayName: Andrea
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-07T15:52:16.343Z
Answers.Text: Well, having different reference values for different data makes live difficult, but I reccon you got your answer. I update my answer accordingly
Answers.UserDisplayName: WMXZ
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-06T15:32:14.057Z
Answers.LastActivityDate: 2023-12-07T15:55:55.960Z
Answers.LastEditDate: 2023-12-07T15:55:55.960Z
Answers.UserDisplayName: WMXZ
Answers.Body: <p>The color dimension on your spectrogram, labelled (as &quot;Amplitude (dB)), should already be a Sound Pressure Level (SPL) at a given frequency interval. I guess what you are looking for is the reference constant to apply to your dB amplitude to make it a SPL with a specific reference or at least with a reference common to all your recordings.</p>
  <h1>If you just want a common reference to all your recordings</h1>
  <p>From what I can see in the <a href="https://rug.mnhn.fr/seewave/HTML/MAN/spectro.html" rel="nofollow noreferrer"><em>spectro</em> help</a>, there is no normalization which could affect each recording differently, so you can compare your spectrograms if all of them were made using the same <strong>dBref</strong> value, provided that your full recording chain was kept the same (distance of the mic to the source, analog and digital gains).</p>
  <h1>If you want a standard 20 µPa reference for air SPL</h1>
  <p>In the case of air SPL (for you bird sound case), the standard is the sea-level atmospheric pressure <span class="math-container">$2 \cdot 10^{-5}$</span> Pa or Pascal (pressure unit), however, it should always be stated somewhere when reporting your value to avoid any ambiguity, e.g. 10 dB SPL (ref 20 µPa). However, a non-arbitrary dB SLP reference makes sense only if your full acoustic measurement chain is calibrated. This is the case for instance in sound level meters. In general, SPL are not calibrated and then the reference is unknown (i.e. the dB SPL should be labelled as &quot;dB SPL (arbitrary reference)&quot;).</p>
  <p>You can estimate the constant to add to your signal in order to make it close to a dB SPL (ref 20µPa), however this depends not only on the microphone sensitivity (which rules the Pressure-to-voltage conversion), but also on all the other amplitude gains between your microphone and your displayed signal:</p>
  <ul>
  <li>the analog amplifier gain, if any (e.g. from the sound interface)</li>
  <li>the digital gains, if any, from the:
  <ul>
  <li>sound interface</li>
  <li>recording software</li>
  <li>sound processing (e.g. if the spectrogram automatically normalizes the spectrum amplitude by the highest one within the recording, or if it plots something else)</li>
  </ul>
  </li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-07T15:26:25.343Z
Answers.LastActivityDate: 2023-12-07T15:26:25.343Z
Answers.UserDisplayName: Noil
Body: <p>Similarly to this discussion (<a href="https://bioacoustics.stackexchange.com/questions/1276/is-it-common-to-have-a-negative-positive-db-range-in-underwater-spectrograms">Is it common to have a negative-positive dB range in underwater spectrograms?</a>), I used the 'seewave' R package to plot the below spectrograms.</p>
  <p><a href="https://i.sstatic.net/Acihc.jpg" rel="noreferrer"><img src="https://i.sstatic.net/Acihc.jpg" alt="enter image description here" /></a></p>
  <p>I limited the coloured amplitude to 0,-60 and the rest as transparent (the full range was between 0,-144. I used the following R code to generate each spectrogram:</p>
  <pre><code>ggspectro(specs, f = 44100) +
    geom_raster(aes(fill = (amplitude)), interpolate = T) +
    scale_fill_gradientn(name = &quot;Amplitude\n(dB)\n&quot;, 
                         limits = c(-60,0), 
                         breaks = c(-60,0), 
                         na.value = &quot;transparent&quot;, 
                         colours = spectro.colors(30)) +
    scale_x_continuous(expand = c(0, 0)) +
    scale_y_continuous(expand = c(0, 0)) +
    theme_pubr()
  </code></pre>
  <p>Recordings were collected on land using SM4 (Wildlife Acoustics, Inc.) with the following mic specs:</p>
  <p>Sensitivity: -35 ±4 dB (0 dB=1V/pa@1kHz)</p>
  <p>Signal to Noise Ratio: 80 dB Typ. at 1kHz (1 Pa, A weighted network)</p>
  <p>Max Input Sound Level: 126 dB SPL Typ.</p>
  <p>The negative scale on the spectrograms should be relative, but I am interested in quantifying the mean, max, and min dB SPL. I am unsure about the reference for dB (dBref argument in <em>spectro</em>), left it <code>NULL</code> as default, although function documentation suggests 2*10e-5 for a 20 microPa reference (I understand that also depends on the mic's sensitivity). Can I use a specific formula to convert my values to dB SPL?</p>
  
Tags: <r><microphone><spectrogram><spl><db>
Title: How to convert relative db to db SPL knowing microphone specifications?
ThreadText: # How to convert relative db to db SPL knowing microphone specifications?
  
  (Asked by: username_0 on 2023-12-06)
  
  Similarly to this discussion (Is it common to have a negative-positive dB range in underwater spectrograms?), I used the 'seewave' R package to plot the below spectrograms.
  
  I limited the coloured amplitude to 0,-60 and the rest as transparent (the full range was between 0,-144. I used the following R code to generate each spectrogram:
  ggspectro(specs, f = 44100) +
    geom_raster(aes(fill = (amplitude)), interpolate = T) +
    scale_fill_gradientn(name = "Amplitude\n(dB)\n", 
                         limits = c(-60,0), 
                         breaks = c(-60,0), 
                         na.value = "transparent", 
                         colours = spectro.colors(30)) +
    scale_x_continuous(expand = c(0, 0)) +
    scale_y_continuous(expand = c(0, 0)) +
    theme_pubr()
  
  Recordings were collected on land using SM4 (Wildlife Acoustics, Inc.) with the following mic specs:
  Sensitivity: -35 ±4 dB (0 dB=1V/pa@1kHz)
  Signal to Noise Ratio: 80 dB Typ. at 1kHz (1 Pa, A weighted network)
  Max Input Sound Level: 126 dB SPL Typ.
  The negative scale on the spectrograms should be relative, but I am interested in quantifying the mean, max, and min dB SPL. I am unsure about the reference for dB (dBref argument in spectro), left it NULL as default, although function documentation suggests 2*10e-5 for a 20 microPa reference (I understand that also depends on the mic's sensitivity). Can I use a specific formula to convert my values to dB SPL?
  
  **Tags:** r, microphone, spectrogram, spl, db
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-12-06. Score: 3 | Accepted answer
  
  To make the answer simple and hoping that I understand your question correctly, note first that
  
  * You have given max SPL input level of 126 dB.
  * Your plots are dB relative to max input level.
  
  Consequently simply add 126 dB to your plot levels to get dB SPL values.
  
  Edit: If the plots are reference to peak signal power (as indicated by comment) and not to max input level (i.e. full ADC level) than the difference between the two level must be taken care off.
  
  How to do that in R?, there could be multiple options, but a save option is to multiply the normalized input data by 10^(126/20)
  
  Obviously there is also a long way, using sensitivity, amplifier gains and ADC reference voltage, but the calculation should end up to max SPL input level
  
  > **Comments:**
  > **username_0**: Thanks for the suggestions. I noticed however that the 0 relative dB didn’t always correspond to the 126 dB SPL. Relative 0 corresponded to the loudest sound in my recordings. Calculating the Peak Power in each recording (using Raven Pro), I could then use that as the 0 reference. For example, if my Peak Power was -16, I added 110 (maximum input 126 - 16) to the values in my graphs. That way I could get a standardised quantification of sound across my spectrograms.  
  > **username_1**: Well, having different reference values for different data makes live difficult, but I reccon you got your answer. I update my answer accordingly  
  
  ---
  
  ### Answer by username_2 on 2023-12-07. Score: 1
  
  The color dimension on your spectrogram, labelled (as "Amplitude (dB)), should already be a Sound Pressure Level (SPL) at a given frequency interval. I guess what you are looking for is the reference constant to apply to your dB amplitude to make it a SPL with a specific reference or at least with a reference common to all your recordings.
  
  # If you just want a common reference to all your recordings
  
  From what I can see in the [*spectro* help](https://rug.mnhn.fr/seewave/HTML/MAN/spectro.html), there is no normalization which could affect each recording differently, so you can compare your spectrograms if all of them were made using the same **dBref** value, provided that your full recording chain was kept the same (distance of the mic to the source, analog and digital gains).
  
  # If you want a standard 20 µPa reference for air SPL
  
  In the case of air SPL (for you bird sound case), the standard is the sea-level atmospheric pressure $2 \cdot 10^{-5}$ Pa or Pascal (pressure unit), however, it should always be stated somewhere when reporting your value to avoid any ambiguity, e.g. 10 dB SPL (ref 20 µPa). However, a non-arbitrary dB SLP reference makes sense only if your full acoustic measurement chain is calibrated. This is the case for instance in sound level meters. In general, SPL are not calibrated and then the reference is unknown (i.e. the dB SPL should be labelled as "dB SPL (arbitrary reference)").
  
  You can estimate the constant to add to your signal in order to make it close to a dB SPL (ref 20µPa), however this depends not only on the microphone sensitivity (which rules the Pressure-to-voltage conversion), but also on all the other amplitude gains between your microphone and your displayed signal:
  
  * the analog amplifier gain, if any (e.g. from the sound interface)
  * the digital gains, if any, from the:
    + sound interface
    + recording software
    + sound processing (e.g. if the spectrogram automatically normalizes the spectrum amplitude by the highest one within the recording, or if it plots something else)
  
  
  ---
  
  