0

I am using noise meter to read noise in decibels. When I run the app it is recording almost 120 readings per second. I don't want those many recordings. Is there any way to specify that I want only one or two recordings per second like that. Thanks in advance. noise_meter package. I am using code from git hub which is already written using noise_meter github repo noise_meter example

I tried to calculate no. of samples using sample rate which is 40100 in the package. but I can't understand it.

yellesh
  • 1
  • 1

1 Answers1

0

As you see in the source code , audio streamer uses a fixed size buffer of a new thousand and an audio sample rate of 41000, and includes this comment Uses a buffer array of size 512. Whenever buffer is full, the content is sent to Flutter. So, small audio blocks will arrive at the consumer frequently (as you might expect from a streamer). It doesn't seem possible to adjust this.

The noise meter package simply takes each block of audio and calculates the noise level, so the rate of arrival of those is exactly the same as rate of arrival of audio blocks from the underlying package.

Given the simplicity of the noise meter calculation, you could replace it with your own code directly on top of audio streamer. You just need to collect multiple blocks of audio together before performing the simple decibel calculation.

Alternatively you could simply discard N out of each N+1 samples.

Richard Heap
  • 48,344
  • 9
  • 130
  • 112
  • Thanks for your reply, but I am not able to put exactly in the code. So I found a different way and its working but is it a good way to use it. that is (inside setstate) ------ _timer = Timer.periodic(Duration(seconds: 10), (timer){ setState(() { maxDB; }); }); ------ Before this app used to record around 100 decibel readings per second, now it is recording around 10 recordings per second. What is your view on this – yellesh Nov 04 '22 at 11:40