eopeter / flutter_dtmf

DTMF Tone Generator for Flutter Applications.
MIT License
11 stars 20 forks source link

Make the sound louder #12

Closed GaelleJoubert closed 10 months ago

GaelleJoubert commented 10 months ago

I tried this library on two of my phone, and I feel like even with max volume (volume = 1), the sound is not realy loud. It feels like maybe to sound is generated like in a call, so you have to have you ear on the phone to hear it.

Would it be possible, to make the sound louder, like maybe played like when you phone is on "speaker mode" ? That would be very usefull to me, thanks you very much !

GaelleJoubert commented 10 months ago

I mannage to make it louder by changing the "max volume" to "100". But I don't know if I should change it in the library ... ?

Here is the code with the change :

private fun playTone(digits: String, durationMs: Int, volume: Double?) {
    val streamType = AudioManager.STREAM_DTMF
    val maxVolume = 100//audioManager.getStreamMaxVolume(streamType)
    var targetVolume = audioManager.getStreamVolume(streamType).toDouble()
    if (volume != null) {
      // Set the volume level as a percentage
      targetVolume = volume * maxVolume// maxVolume
    }
GaelleJoubert commented 10 months ago

@eopeter should I do a pull request for that ? It does not change the way that you can set the volume, it just change the max volume possible to much louder.