lincollincol / Amplituda

Audio processing library, which provides waveform data
Apache License 2.0
222 stars 31 forks source link

Output samples per second is 10 irrespective of the `preferredSamplesPerSecond` given #65

Open thedroiddiv opened 1 year ago

thedroiddiv commented 1 year ago

Describe the bug Output samples per second is 10 irrespective of the preferredSamplesPerSecond given

To Reproduce Steps to reproduce the behavior:

  1. I'm using this helper class
    object AudioManager {
    private lateinit var amplituda: Amplituda
    fun getAmplitudes(context: Context, audioFilePath: String): Pair<List<Int>, Long> {
        if (!::amplituda.isInitialized) {
            amplituda = Amplituda(context)
        }
        var amplitudes = listOf<Int>()
        var duration = 0L
        amplituda.processAudio(audioFilePath, Compress.withParams(Compress.AVERAGE, 50))
            .get({
                amplitudes = it.amplitudesAsList()
                Log.d("TAG", "getAmplitudes: ${it.amplitudesForSecond(1).size}")
                duration = it.getAudioDuration(AmplitudaResult.DurationUnit.MILLIS)
            }, { e ->
                Log.e("AudioManager::", "getAmplitudes: ", e)
            })
        return Pair(amplitudes, duration)
    }
    }

Expected behavior Expected Log: getAmplitudes: 50

Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2023-11-07 at 6 19 16 PM (2)

Smartphone (please complete the following information):