forked from MirrorHub/mautrix-whatsapp
Use dynamic multiplier when bridging waveform
This commit is contained in:
parent
be68203056
commit
77bef42ace
1 changed files with 12 additions and 2 deletions
14
portal.go
14
portal.go
|
@ -1983,9 +1983,19 @@ func (portal *Portal) convertMediaMessageContent(intent *appservice.IntentAPI, m
|
|||
var waveform []int
|
||||
if audioMessage.Waveform != nil {
|
||||
waveform = make([]int, len(audioMessage.Waveform))
|
||||
max := 0
|
||||
for i, part := range audioMessage.Waveform {
|
||||
// TODO is 4 the right multiplier?
|
||||
waveform[i] = int(part) * 4
|
||||
waveform[i] = int(part)
|
||||
if waveform[i] > max {
|
||||
max = waveform[i]
|
||||
}
|
||||
}
|
||||
multiplier := 1024 / max
|
||||
if multiplier > 32 {
|
||||
multiplier = 32
|
||||
}
|
||||
for i := range waveform {
|
||||
waveform[i] *= multiplier
|
||||
}
|
||||
}
|
||||
extraContent["org.matrix.msc1767.audio"] = map[string]interface{}{
|
||||
|
|
Loading…
Reference in a new issue