#4096 - Added locked mode transition and animations, locked recording mode and real time waveform.

This commit is contained in:
Stefan Ceriu
2021-06-18 15:49:58 +03:00
parent 220b9df8ec
commit d9293e7d2d
21 changed files with 504 additions and 156 deletions
@@ -17,6 +17,8 @@
import Foundation
import AVFoundation
private let silenceThreshold: Float = -50.0
protocol VoiceMessageAudioRecorderDelegate: AnyObject {
func audioRecorderDidStartRecording(_ audioRecorder: VoiceMessageAudioRecorder)
func audioRecorderDidFinishRecording(_ audioRecorder: VoiceMessageAudioRecorder)
@@ -104,11 +106,7 @@ class VoiceMessageAudioRecorder: NSObject, AVAudioRecorderDelegate {
}
private func normalizedPowerLevelFromDecibels(_ decibels: Float) -> Float {
if decibels < -60.0 || decibels == 0.0 {
return 0.0
}
return powf((powf(10.0, 0.05 * decibels) - powf(10.0, 0.05 * -60.0)) * (1.0 / (1.0 - powf(10.0, 0.05 * -60.0))), 1.0 / 2.0)
return decibels / silenceThreshold
}
}