mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Update SDK to 25.10.21 (#4642)
* update sdk * fix normalized waveform * added a comment on normalization * running on MacOS-26 * Revert "running on MacOS-26" This reverts commit 1c8ececf0b84200193eaa2ab205094215b168060.
This commit is contained in:
@@ -127,17 +127,17 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
||||
await previewAudioPlayerState?.updateState(progress: progress)
|
||||
}
|
||||
|
||||
func buildRecordingWaveform() async -> Result<[UInt16], VoiceMessageRecorderError> {
|
||||
func buildRecordingWaveform() async -> Result<[Float], VoiceMessageRecorderError> {
|
||||
guard let url = audioRecorder.audioFileURL else {
|
||||
return .failure(.missingRecordingFile)
|
||||
}
|
||||
// build the waveform
|
||||
var waveformData: [UInt16] = []
|
||||
var waveformData: [Float] = []
|
||||
let analyzer = WaveformAnalyzer()
|
||||
do {
|
||||
let samples = try await analyzer.samples(fromAudioAt: url, count: 100)
|
||||
// linearly normalized to [0, 1] (1 -> -50 dB)
|
||||
waveformData = samples.map { UInt16(max(0, (1 - $0) * 1024)) }
|
||||
waveformData = samples.map { max(0, 1 - $0) }
|
||||
} catch {
|
||||
MXLog.error("Waveform analysis failed. \(error)")
|
||||
return .failure(.waveformAnalysisError)
|
||||
|
||||
Reference in New Issue
Block a user