mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added fallback of waveform data to transcribed round messages.
This commit is contained in:
parent
af6ca8d4f1
commit
3078a94404
1 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "history/view/media/history_view_document.h"
|
#include "history/view/media/history_view_document.h"
|
||||||
|
|
||||||
|
#include "base/random.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -74,6 +75,24 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FillWaveform(VoiceData *roundData) {
|
||||||
|
if (!roundData->waveform.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto &size = ::Media::Player::kWaveformSamplesCount;
|
||||||
|
auto randomBytes = bytes::vector(size);
|
||||||
|
base::RandomFill(randomBytes.data(), randomBytes.size());
|
||||||
|
roundData->waveform.resize(size);
|
||||||
|
for (auto i = 1; i < size; i += 2) {
|
||||||
|
const auto peak = uchar(randomBytes[i]) % 31;
|
||||||
|
roundData->waveform[i - 1] = char(std::max(
|
||||||
|
0,
|
||||||
|
peak - (uchar(randomBytes[i - 1]) % 3 + 2)));
|
||||||
|
roundData->waveform[i] = char(peak);
|
||||||
|
}
|
||||||
|
roundData->wavemax = *ranges::max_element(roundData->waveform);
|
||||||
|
}
|
||||||
|
|
||||||
void PaintWaveform(
|
void PaintWaveform(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const PaintContext &context,
|
const PaintContext &context,
|
||||||
|
@ -674,6 +693,9 @@ void Document::draw(
|
||||||
p.save();
|
p.save();
|
||||||
p.translate(nameleft, st.padding.top() - topMinus);
|
p.translate(nameleft, st.padding.top() - topMinus);
|
||||||
|
|
||||||
|
if (_transcribedRound) {
|
||||||
|
FillWaveform(_data->round());
|
||||||
|
}
|
||||||
PaintWaveform(p,
|
PaintWaveform(p,
|
||||||
context,
|
context,
|
||||||
_transcribedRound ? _data->round() : _data->voice(),
|
_transcribedRound ? _data->round() : _data->voice(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue