Dynamic audio level indicator
This commit is contained in:
parent
ac59dec5aa
commit
e6223b6a11
24 changed files with 323 additions and 123 deletions
24
ts/calling/truncateAudioLevel.ts
Normal file
24
ts/calling/truncateAudioLevel.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// See https://github.com/signalapp/Signal-Android/blob/b527b2ffb94fb82a7508c3b33ddbffef28085349/app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.kt#L87-L100
|
||||
const LOWEST = 500 / 32767;
|
||||
const LOW = 1000 / 32767;
|
||||
const MEDIUM = 5000 / 32767;
|
||||
const HIGH = 16000 / 32767;
|
||||
|
||||
export function truncateAudioLevel(audioLevel: number): number {
|
||||
if (audioLevel < LOWEST) {
|
||||
return 0;
|
||||
}
|
||||
if (audioLevel < LOW) {
|
||||
return 0.25;
|
||||
}
|
||||
if (audioLevel < MEDIUM) {
|
||||
return 0.5;
|
||||
}
|
||||
if (audioLevel < HIGH) {
|
||||
return 0.75;
|
||||
}
|
||||
return 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue