<I want to create an audio waveform view and I wan...
# stackoverflow
r
I want to create an audio waveform view and I want to synchronize it with the audio playback position so I am trying to create an audio editor fun generateWaveformBitmap(pcmFile: File, width: Int, height: Int): Bitmap { val pcmData = pcmFile.readBytes() val bytesPerSample = 2 // 16-bit PCM data val samples = pcmData.size / bytesPerSample val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) val canvas = android.graphics.Canvas(bitmap) val paint = Paint().apply { color = android.graphics.Color.BLACK strokeWidth = 2f } val maxAmplitude = 32768 // max value for 16-bit...