Detect microphone volume (blowing into microphone)

@rony_sha: Sorry, this is not possible in Corona at the moment. [import]uid: 6787 topic_id: 4708 reply_id: 50075[/import]

hi snarla,

I tried out your code and got the same effect as shredder. The values are just all over - no matter if I shout, put the iphone in front of loud music or in a silent room.

Do you know why this is? [import]uid: 75358 topic_id: 4708 reply_id: 50082[/import]

As I said, you need to convert to dB and process the data in some way to detect features. You cannot use the raw values in any kind of absolute way. [import]uid: 6787 topic_id: 4708 reply_id: 50249[/import]

@shedder, your inputs are welcome and there is a forum specifically for the roadmap and feature requests. [import]uid: 6787 topic_id: 4708 reply_id: 50252[/import]

@snarla, thanks for the example. Just to be sure I compiled and tried again on 3 devices (iPhone 3G, iPad 1st gen, iPod touch 4g) as well as the simulator.
I also decided to print the v value ( v = 20 * 0.434 * math.log(v) ) and the raw r:getTunerVolume() to see what’s happening.

From my tests the v value does indeed change when it detects a volume level change. The default values are different on each device I tested, but react correctly.

The problem is that, I think, getTunerVolume reacts to a volume change from complete silence to very tiny noises, but it’s not correctly measuring louder levels.

For example, if in complete silence I got a value at around 0.3/0.4, then I turn on gradually a speaker playing white noise, the value rises suddenly to 0.5/0.6… and then it stays there.
It definitely looks like it’s saturating or capping the input level.

A very different result from the Voice Memos app that respond beautifully.

Please, give a look to this other post:
http://developer.anscamobile.com/forum/2011/08/06/gettunervolume-not-returning-expected-values

Duff333 is playing a white noise sound that start silent and get gradually louder and recording getTunerVolume values. The value starts rapidly rising and then it just stop at 0.58. Definitely looks like a saturated input.

snarla, can you tell me if that looks correct to you?
[import]uid: 9158 topic_id: 4708 reply_id: 50315[/import]

Hi Snarla,

I’m happy more developers joined this discussion and appreciate your time to reply. But I don’t understand how it is possible that everyone reports similar problems and observations, while you are saying it works for you.

  • I don’t know in what environment you are testing, in an absolutely quiet laboratory or a normal office. But the absolute value of the getTunerVolume function is around 0.55 to 0.6 in the office I work. There are just a few desktop computers running while nobody is even talking, no music etc. If I go to a very quiet room, the value is still around 0.3. So as I said already back in January and others mentioned as well, the function is totally oversensitive to even small noise in the background (or saturated, however you call it).

  • As I wrote in my 2 bug report filings (cases 2579 and 7388): if the input is already saturated around 0.55 - 0.6 and start to blow into the microphone the value from getTunerVolume gets even *lower*. Can you please explain me, how is this possible? I tested on iPhone 3G and iPod touch 4th generation with built-in microphones and a iPod touch 3rd generation with external microphone. All behave the same.

  • What about the issue that it is not possible on iOS to record sound and play sound simultaneously? Is there any plan to fix this issue?

You wrote in one of your answers: “Ansca may eventually be able to devote resources to developing more powerful audio analysis features, but for now we have to make do with what we have, i.e. the Tuner API (which was designed for pitch detection, not for general audio analysis).”

To me it sounds like the API is ok if you are trying to detect the pitch of the input, for example for tuning up a music instrument. But for doing anything about volume detection, the API is just not there yet. If we can all agree on this, then it would be a nice move from Ansca to write this clearly in the API documentation.

I’m sorry for my sour tone, I do like Corona in a lot of ways. But this is one of the cases that frustrate me a lot. I just cannot understand why Ansca is providing this API if it is not working properly as many are reporting, but just saying take it or leave it (while strangely, it works so much better on Android). If Ansca doesn’t have the resources or time to fix it then at least state clearly that it is broken and update the documentation. Because we developers also have clients or employers we need to answer to.

I mean look at the excellent thread Shedder pointed to (big thanks for that), do we really need any other indications that the funcktion is broken on iOS right now?
http://developer.anscamobile.com/forum/2011/08/06/gettunervolume-not-returning-expected-values

Ok, now I feel a bit better :-). Snarla, please don’t take any offence, that’s not my intention. But Ansca really should take a clear stance on this issue.

Best,
Thomas [import]uid: 8111 topic_id: 4708 reply_id: 50348[/import]

As Thomas said, definitely we don’t want to offend anyone.
It’s just that the getTunerVolume problem has been reported many months ago, and at today, there hasn’t been a clear explanation from Ansca.

Honestly, I think getTunerVolume is broken.
But, if that’s not the case and the problem is that somehow we are doing it wrong, don’t know how to correctly adjust the parameters or how to interpret the raw data coming from the API, please Ansca, write a new blog post with some code showing the DB level or even better, a VU meter that works exactly like the Voice Memo App.

That would definitely, once and for all, put a stop to the getTunerVolume issue. [import]uid: 9158 topic_id: 4708 reply_id: 50353[/import]

I agree with the people here. The sample code does not work on the device. If you can, please give a more detailed explanation and example on how we can use the output of getTunerVolume… instead of just telling us that we are doing it wrong. That would be greatly appreciated.
Thanks [import]uid: 75358 topic_id: 4708 reply_id: 50356[/import]

Can you define precisely what it would mean to “work”? How precisely would you measure this?

If you could try to see if you can identify precisely what your technical needs are and then let us know, that would help a lot more than just saying “I want to make a cool app that does (some fancy thing)” (although that is good to hear about too)

Our stance is that we make stuff available to you to see if you can do cool stuff with it. YMMV :slight_smile: We’re always listening to your helpful feedback. We can’t always act on it immediately. [import]uid: 6787 topic_id: 4708 reply_id: 50359[/import]

Hi Snarla,

Could you please have a look at the analysis from duff333 in this thread? I think it shows quite well, why we all think the getTunerVolume output is not useful.

http://developer.anscamobile.com/forum/2011/08/06/gettunervolume-not-returning-expected-values

“I want to make a cool app that does (some fancy thing)”

Honestly I think none of us was writing anything like that. On the contrary, I feel I spend a lot of time to write precise questions and findings from the testing, but you never bother to really answer to each of them. I list them in bullet points to make them very easily identifiable.

As I said, I think Corona is doing a lot of things right, that’s why many developers are quite happy with it. But saying “Our stance is that we make stuff available to you to see if you can do cool stuff with it” while not fixing things that are apparently broken (please, proof us otherwise if we are all wrong) is quite a statement for paying customers.

Thomas [import]uid: 8111 topic_id: 4708 reply_id: 50365[/import]

Hi Snarla,

This is one thing that doesnt “work” ( well for me ):
http://developer.anscamobile.com/content/simple-tuner

What I expected from this is, that it will read out the volume of the sounds that the microphone detects. Person shouting on the microphone= 10. No person shouting and just background noise= 5. Something like that.

But the volume on this example just goes up and down within a certain range, even if I blow, shout, speak, put it infront of the speakers when playing music.

If what I expected this application to do is wrong, please let me know.
There is no cool stuff happening here, I just want to know how to use Corona.

[import]uid: 75358 topic_id: 4708 reply_id: 50367[/import]

It sounds like you are looking for a VU metering function. The tuner’s getVolume function is not designed to be a VU meter and the project is intended to demonstrate how to use the Tuner API for pitch detection. [import]uid: 6787 topic_id: 4708 reply_id: 51412[/import]

The Simple Tuner example, besides frequency, is also showing “volume”.
In the code that line is commented with “-- convert to db” .
Is it showing decibels detected by the iPhone? If that so, the values are wrong.

Gettunerfrequency returns the frequency, but GetTunerVolume what is supposed to do?
What is exactly returning?
How are we supposed to use it in real world apps?

I could definitely build a VU meter if it didn’t saturate the input level like explained in this topic:
http://developer.anscamobile.com/content/simple-tuner

But anyway… I give up, clearly there’s no interest by Ansca to acknowledge or resolve this problem (hey, there’s NO problem, right?) [import]uid: 9158 topic_id: 4708 reply_id: 51431[/import]

Hi Snarla,

If that is the case, I believe that the “volume” should be removed from the example. I don’t know if the other developers were mislead to thinking that it detects the volume correctly - but I sure was.

Thanks [import]uid: 75358 topic_id: 4708 reply_id: 51608[/import]

yes… that feature is a joke… sorry to say…

also i tried the test above.

sitting here in front of my iMac and testing.

just by typing it often gives me full value, or a small background noise from a barking dog.

that should not be compared to ‘full blowing’ into a mic.

i tested with my native iOS app i did once, checking peak volume.

my typing, the dog in the background gives me around 0.2 from 1.0
full blowing starts at around 0.9

the getTunerVolume() is just jumping from nothing to 90% thats useless.
Please have a look into that asap … I saw ‘many’ other requests months ago and it looks
nothing changed.

and by all excused that I had to read here (different devices etc…) its definitely a huge different to the native Peak Level detectors on iOS, there all work accurate. :slight_smile:

EDIT: @ snarla you asked how it should act to declare as proper working.
just as we get the ‘proper’ data from the AVFoundation in iOS… nothing special… not trick not analyzing, just the same Volume Peak value passed through the Corona framework!

chris
[import]uid: 4795 topic_id: 4708 reply_id: 57278[/import]

Hi

Any news on this topic?

I need to detect the volume of sound picked up by the microphone for:

1 - Enable recording from a particular volume.

2 - Detecting a blow on the microphone.

So I’m reading in the forum, it is not possible with the Corona API, isn’t it? [import]uid: 141611 topic_id: 4708 reply_id: 105265[/import]

unfortunatly … none from the support team answer on that.
also lots of posts complain about same… but nothing happen.

from my own experience, i like to do the same as you, it does NOT work.
when i speak very silent i get a little value… when i speak louder
its same as i blow into the mic… so i can’t differentiate if its loud or just blown.

i dont understand why nobody is investigating in that… as lots of different apps
are possible with that.

hope our posts will be heard now :slight_smile:

chris
[import]uid: 4795 topic_id: 4708 reply_id: 106321[/import]

Tuner example show wrong notes…I have a keyboard and play a continuos sound, and it never show the same letter.

And with all my respect snarla, that is not a polite way to answer to people who are paying for a product.In this post there are people who have spent lot of time testing, probably more than you checking it. [import]uid: 113117 topic_id: 4708 reply_id: 109291[/import]

+1

i confirm, it seems none of ansca is really interested in that topic.

:frowning:

chris
[import]uid: 4795 topic_id: 4708 reply_id: 109339[/import]

+1

I miss better functios to manage audio, images and video

Not all are 2D games [import]uid: 113117 topic_id: 4708 reply_id: 109367[/import]