# Audio, read decibel for specific bin in MonitorSpectralNode

**URL:** <https://discourse.libcinder.org/t/audio-read-decibel-for-specific-bin-in-monitorspectralnode/1768>\
**Category:** Using Cinder\
**Created:** [February 12, 2021, 2:20pm UTC](https://discourse.libcinder.org/t/audio-read-decibel-for-specific-bin-in-monitorspectralnode/1768 "2021-02-12T14:20:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomestlack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/tomestlack/32/881_2.png) [@tomestlack](https://discourse.libcinder.org/u/tomestlack)\
**Post date:** [February 12, 2021, 2:20pm UTC](https://discourse.libcinder.org/t/audio-read-decibel-for-specific-bin-in-monitorspectralnode/1768/1 "2021-02-12T14:20:21Z")

</div>

Hello. I am building a project using the InputAnalyzer (@rich.e) sample. I’m interested in reading specific decibel levels of individual bins in MonitorSpectralNode. For example, I want to see if a range of frequencies between 100 and 110 are being picked up through the microphone. Here:

mMonitorSpectralNode-\>getFreqForBin(5);

This will report that Bin 5 is reading a frequency of roughly 107.666hz.  
I am not sure how to go about reading amplitude or decibel levels for bin 5 (or any other bins).  
Thank you for any input.

---

<div class="post-metadata">

**Author:** ![tomestlack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/tomestlack/32/881_2.png) [@tomestlack](https://discourse.libcinder.org/u/tomestlack)\
**Post date:** [February 13, 2021, 5:07pm UTC](https://discourse.libcinder.org/t/audio-read-decibel-for-specific-bin-in-monitorspectralnode/1768/2 "2021-02-13T17:07:43Z")

</div>

A Mention that detecting pitch is something Cinder might be rather challenged to make happen.

[https://forum.libcinder.org/topic/real-time-pitch-detection](https://forum.libcinder.org/topic/real-time-pitch-detection)

---

<div class="post-metadata">

**Author:** ![rich.e](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/rich.e/32/1025_2.png) [@rich.e](https://discourse.libcinder.org/u/rich.e)\
**Post date:** [February 16, 2021, 5:31pm UTC](https://discourse.libcinder.org/t/audio-read-decibel-for-specific-bin-in-monitorspectralnode/1768/3 "2021-02-16T17:31:00Z")

</div>

Hi there,

You’d use `auto spectrum mMonitorSpectralNode->getMagSpectrum();`, and then look at the fifth bin in that for your magnitude. You’d then convert that from linear to decibel how you see fit - there is a helper `audio::linearToDecibel()` that uses the Pure Data convention of normalizing decibels in the range of 0:100 for ease, but you could do it the traditional way where the value ranges from -60 or so to 0. You can see the way I did it in the InputAnalyzer sample [here](https://github.com/cinder/Cinder/blob/c50b7cec747a280d7831180d1fe4bb7bd83dd469/samples/_audio/InputAnalyzer/src/InputAnalyzerApp.cpp#L136).

Concerning pitch detection, as I wrote in that forum post 6 years ago, it is completely doable just difficult to generalize into a built-in node. I suggested that you do it in an `audio::Node` subclass. Though I do think if someone came up with one that worked well in common cases and didn’t have external dependencies then we could include it. For example, Pure Data includes a pitch detector external (`signmund~`), but you’ll find it in the ‘extra’ folder.

cheers,  
Rich

---

<div class="post-metadata">

**Author:** ![tomestlack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/tomestlack/32/881_2.png) [@tomestlack](https://discourse.libcinder.org/u/tomestlack)\
**Post date:** [February 18, 2021, 8:52pm UTC](https://discourse.libcinder.org/t/audio-read-decibel-for-specific-bin-in-monitorspectralnode/1768/4 "2021-02-18T20:52:17Z")

</div>

Thank you for your insight. The more I looked into some of the subclasses, I started to see what was going on there.
