flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

[BUG]: Decibels max 69

Open shootpark opened this issue 11 months ago • 20 comments

Bonjour, Au vu d'un projet j'ai besoin d'un sonometre. J'utilise FlutterSound, malheureusement quelques soit le son je suis bloqué à 69 db, hors via un vrai sonometre les sons tester vont de 80 à 105 decibels. Avez vous une solution ?

Cordialement

shootpark avatar Feb 04 '25 16:02 shootpark

  • what is your codec ?
  • which platform? iOS, android or web?
  • do you record to file, to buffer or to stream ?
  • how many channels? Stereo?

Larpoux avatar Feb 04 '25 16:02 Larpoux

quel est ton codec ? -> pas de codec quelle plateforme ? -> Android enregistrez-vous dans un fichier, dans un tampon ou en streaming ? -> pas d'enregistrement, j'ai repris ce code : https://pub.dev/packages/noise_meter/exampleLe mar. 4 févr. 2025 à 17:48, Larpoux @.***> a écrit : what is your codec ?which platform?do you record to file, to buffer or to stream ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

shootpark avatar Feb 04 '25 19:02 shootpark

Sorry, I can’t help. I really need the codec used, and the destination of your recorder.

Larpoux avatar Feb 04 '25 19:02 Larpoux

we don't record the sound, everything is local but Noise_Meter after testing gets stuck at 89 decibels and never goes aboveLe mar. 4 févr. 2025 à 20:35, Larpoux @.***> a écrit : Sorry, I can’t help. I really need the codec used, and the destination of your recorder.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

shootpark avatar Feb 04 '25 20:02 shootpark

There are some bad things in this area, inside Flutter Sound. I can work on that tomorrow and the next few days. But I really need your code. Specially the `startRecorder() parameter that you use.

Larpoux avatar Feb 04 '25 22:02 Larpoux

I am sorry, but there is no attachment with you GitHub post. Probably because you sent it from your mailbox and not from the GitHub site. And the web link that you sent yesterday is a dead page, so I don’t have any idea of what you try to do. Please, send your post from GitHub.

Larpoux avatar Feb 05 '25 04:02 Larpoux

Voici les screen du code qui mebloque à 69db via fluttersound :

Image Image

Image Image

shootpark avatar Feb 05 '25 08:02 shootpark

Ici on peut voir notre limite de 69db qui ne sont jamais depassé par l'application, je precise que le téléphone peut capter sans probleme des sons entre 105 et 110db et que le son a ete mesurer au sonometre au moment du screen ou il est bloquer à 69db max, via le sonometre nous etions à 97 db

Image Image

shootpark avatar Feb 05 '25 09:02 shootpark

Thank you @shootpark . I think I can fix your issue. I understand the problem and I will work on that in a few days. I will post something to let you know how things are going.

Larpoux avatar Feb 05 '25 09:02 Larpoux

Also: do you have several channels? If stereo, do you need a peak level for each channel?

Larpoux avatar Feb 05 '25 09:02 Larpoux

Je n’ai qu’un seul canal, le principe de l’application sera uniquement de capter des sons d’assez grande intensité via le téléphone

shootpark avatar Feb 05 '25 13:02 shootpark

I will work on this issue tomorrow. I will release a new Flutter Sound version before the end of the week. I think you will be glad.

Larpoux avatar Feb 05 '25 17:02 Larpoux

Je vous remercie infiniment ! 🙏

shootpark avatar Feb 05 '25 17:02 shootpark

@shootpark, Flutter Sound 9.22.0 is released. The DB level on Android should be better. Please note the foollowing points:

  • Actually you call recorder.setSubscriptionDuration(100ms). You can play with this duration. Longer it is, and more the peak level will be flatten. I tried 10ms with success
  • If you need to have a very quick and accurate peak level, you can lower the bufferSize parameter of startRecorder which is by default 8192. I used bufferSize: 128 with success
  • I am not sure that you have to call your function convertToDecibels because flutter Sound provides already Decibels in its callback
  • Il est possible que tu doives calibrer ou étalonner ton microphone

9.22.0

  • iOS : DB Peak level for codec == Codec.pcm16 and codec == Codec.pcmFloat32

  • android : DB Peak level for codec == Codec.pcm16 and codec == Codec.pcmFloat32

  • Fix a bug when recording pcmWAV on android and channels > 1

  • On Web : The error "OnLoad error" was not correctely diagnosed

  • TODO

    • pcmFloat32 and pcmFloat32WAV on Android
    • Playback OpusWEBM and VorbisWEBM with remote files on Android
    • Volume Control for pcm codecs (all platforms)
    • Example Pan control
    • Pause/Rresume for PCM codecs
    • On iOS, the peak level is more than 100 db
    • On iOS : Streams Int16 non interleaved
    • On Android : Record/Playback PCMFloat32
    • On Web : isEncoderSupported() and isDecoderSupported() are not implemented
    • On Web : playback OpusOGG does nnot work
    • On Web : PCM16 Dart Stream not OK
    • On Wev : Record/playback AAC/MP4 and OpusWEB to buffer
    • On Web : Record PCMFloat32 : DartError: Assertion failed: file:///Volumes/mac-H/larpoux/proj/flutter_sound/flutter_sound_web/lib/flutter_sound_recorder_web.dart:279:14
    • https://tau.canardoux.xyz/danku/extract/02-opus.webm Not found
    • https://tau.canardoux.xyz/danku/extract/03-vorbis.webm Not found
    • Playback Asset PCM Float32 : onloaderror
    • On Web : Record/Playback PcmFloat32 not interleaved : NeedSomeFood : DartError: Bad state: Future already completed
    • On Web : startPlayer FromURI : _flutter_sound.wav : No file extension was found. Consider using the "format" property or specify an extension.
    • On Web : Implement Streams Int16
    • On Web : Implement Stream interleaved.
    • On iOS : codec==Codec.pcm16WAV -- startRecorder() -- The frames are not correctely coded with int16 but float32. This must be fixed.
    • On iOS : codec==Codec.pcm32WAV -- The peak level is not computed correctly. This must be fixed.
    • On iOS : Codec.pcmINT16 not interleaved
    • Implement Float32 on Android
    • Implement stream not interleaved on Android
    • Flutter Sound should not depend on Audio_Session
    • MacOS support

Larpoux avatar Feb 07 '25 11:02 Larpoux

Merci infiniment je vais regarder cela dans le Weekend, cependant qu’est ce que vous voulez dire par calibrer le microphone du téléphone ? Merci

shootpark avatar Feb 07 '25 15:02 shootpark

Avec cette nouvelle mise à jour, combien avez vous captez en décibels au maximum ?

shootpark avatar Feb 08 '25 14:02 shootpark

I have not tested large decibels. I count on you to do the tests 😄

Larpoux avatar Feb 09 '25 05:02 Larpoux

Bonjour, on a tout retester avec la nouvelkle version magres le calibrage nous avons toujours le meme probleme, les decibels ne sont pas bon, avec un calibrage X nous obtenons pour un petit bruit 89db et pour un bruit assez fort 92db, cependant un bruit tres fort sera aussi limité à 92db. Le probleme ne vient pas du téléphone puisq'il a été tester mais j'aimerais savoir si dans votre programme il y a deux intervalles limite exemple : de 0 à 90db ?

Je peux vous envoyé le fichier APK en privé si vous le souhaiter pour voir par vous meme et le code egalement.

shootpark avatar Feb 11 '25 15:02 shootpark

Hi man. I don't really understand why you have an issue. I find the greatest PCM sample, and I convert it to Decibel using this simple algorythm:

	double maxAmplitude = recorder.getMaxAmplitude();

	// Calculate db based on the following article.
	// https://stackoverflow.com/questions/10655703/what-does-androids-getmaxamplitude-function-for-the-mediarecorder-actually-gi
	//
	double ref_pressure = 51805.5336;
	double p = maxAmplitude / ref_pressure;
	double p0 = 0.0002;

	db = 20.0 * Math.log10(p / p0);

	// if the microphone is off we get 0 for the amplitude which causes
	// db to be infinite.
	if (Double.isInfinite(db)) {
		db = 0.0;
	}

Of course you don't call yourself a LOG() , because it is already done by me. If you have any suggestion, I will be happy to do something.

Larpoux avatar Feb 11 '25 16:02 Larpoux

I don’t have any knowledge about computing db level from pcm samples. Your issue can have 3 causes:

  • The algorithm that I use is not good
  • I have a bug in my code
  • you don’t use the correct values that I give you

If you have any pr to suggest, I will be very glad to merge it inside Flutter Sound

Larpoux avatar Feb 18 '25 01:02 Larpoux