Add some comment
This commit is contained in:
parent
a83630169e
commit
5320bd06c2
4 changed files with 13 additions and 3 deletions
|
|
@ -21,11 +21,13 @@ sealed interface VoiceMessageState {
|
||||||
val showCursor: Boolean,
|
val showCursor: Boolean,
|
||||||
val playbackProgress: Float,
|
val playbackProgress: Float,
|
||||||
val time: Duration,
|
val time: Duration,
|
||||||
|
// Values are between 0 and 1
|
||||||
val waveform: ImmutableList<Float>,
|
val waveform: ImmutableList<Float>,
|
||||||
) : VoiceMessageState
|
) : VoiceMessageState
|
||||||
|
|
||||||
data class Recording(
|
data class Recording(
|
||||||
val duration: Duration,
|
val duration: Duration,
|
||||||
|
// Values are between 0 and 1
|
||||||
val levels: ImmutableList<Float>,
|
val levels: ImmutableList<Float>,
|
||||||
) : VoiceMessageState
|
) : VoiceMessageState
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,19 @@ sealed interface VoiceRecorderState {
|
||||||
* The recorder is currently recording.
|
* The recorder is currently recording.
|
||||||
*
|
*
|
||||||
* @property elapsedTime The elapsed time since the recording started.
|
* @property elapsedTime The elapsed time since the recording started.
|
||||||
* @property levels The current audio levels of the recording as a fraction of 1.
|
* @property levels The current audio levels of the recording as a fraction of 1. All values are between 0 and 1.
|
||||||
*/
|
*/
|
||||||
data class Recording(val elapsedTime: Duration, val levels: List<Float>) : VoiceRecorderState
|
data class Recording(
|
||||||
|
val elapsedTime: Duration,
|
||||||
|
val levels: List<Float>,
|
||||||
|
) : VoiceRecorderState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The recorder has finished recording.
|
* The recorder has finished recording.
|
||||||
*
|
*
|
||||||
* @property file The recorded file.
|
* @property file The recorded file.
|
||||||
* @property mimeType The mime type of the file.
|
* @property mimeType The mime type of the file.
|
||||||
* @property waveform The waveform of the recording.
|
* @property waveform The waveform of the recording. All values are between 0 and 1.
|
||||||
* @property duration The total time spent recording.
|
* @property duration The total time spent recording.
|
||||||
*/
|
*/
|
||||||
data class Finished(
|
data class Finished(
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ class DefaultVoiceRecorder(
|
||||||
private var outputFile: File? = null
|
private var outputFile: File? = null
|
||||||
private var audioReader: AudioReader? = null
|
private var audioReader: AudioReader? = null
|
||||||
private var recordingJob: Job? = null
|
private var recordingJob: Job? = null
|
||||||
|
|
||||||
|
// List of Float between 0 and 1 representing the audio levels
|
||||||
private val levels: MutableList<Float> = mutableListOf()
|
private val levels: MutableList<Float> = mutableListOf()
|
||||||
private val lock = Mutex()
|
private val lock = Mutex()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
package io.element.android.libraries.voicerecorder.impl.audio
|
package io.element.android.libraries.voicerecorder.impl.audio
|
||||||
|
|
||||||
|
import androidx.annotation.FloatRange
|
||||||
|
|
||||||
interface AudioLevelCalculator {
|
interface AudioLevelCalculator {
|
||||||
/**
|
/**
|
||||||
* Calculate the audio level of the audio buffer.
|
* Calculate the audio level of the audio buffer.
|
||||||
|
|
@ -14,5 +16,6 @@ interface AudioLevelCalculator {
|
||||||
* @param buffer The audio buffer containing 16bit PCM audio data.
|
* @param buffer The audio buffer containing 16bit PCM audio data.
|
||||||
* @return A float value between 0 and 1 proportional to the audio level.
|
* @return A float value between 0 and 1 proportional to the audio level.
|
||||||
*/
|
*/
|
||||||
|
@FloatRange(from = 0.0, to = 1.0)
|
||||||
fun calculateAudioLevel(buffer: ShortArray): Float
|
fun calculateAudioLevel(buffer: ShortArray): Float
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue