Lots of blip rate fixes:

Remove qElapsedTimer method of blip earrape protection due to major inconsistency issues with this method (the same message would produce wildly different blip sounds - consistency is preferred)
More sophisticated blip earrape prevention is calculated in the chat ticker function itself, it also properly adjusts itself depending on the blip_rate used.
This commit is contained in:
Crystalwarrior 2020-09-11 23:38:36 +03:00
parent 8cc067dee4
commit d00d0769a9
3 changed files with 15 additions and 11 deletions

View File

@ -22,12 +22,9 @@ public:
int m_cycle = 0; int m_cycle = 0;
private: private:
const int max_blip_ms = 60;
QWidget *m_parent; QWidget *m_parent;
AOApplication *ao_app; AOApplication *ao_app;
qreal m_volume; qreal m_volume;
QElapsedTimer delay;
void set_volume_internal(qreal p_volume); void set_volume_internal(qreal p_volume);

View File

@ -26,10 +26,6 @@ void AOBlipPlayer::set_blips(QString p_sfx)
void AOBlipPlayer::blip_tick() void AOBlipPlayer::blip_tick()
{ {
if (delay.isValid() && delay.elapsed() < max_blip_ms)
return;
delay.start();
int f_cycle = m_cycle++; int f_cycle = m_cycle++;
if (m_cycle == 5) if (m_cycle == 5)

View File

@ -2943,7 +2943,17 @@ void Courtroom::chat_tick()
// I am you // I am you
// ! ! ! ! // ! ! ! !
// where ! is the blip sound // where ! is the blip sound
if (blip_ticker % blip_rate == 0) { int b_rate = blip_rate;
// Earrape prevention without using timers, this method is more consistent.
if (msg_delay != 0 && msg_delay <= 25) {
// The default blip speed is 40ms, and if current msg_delay is 25ms,
// the formula will result in the blip rate of:
// 40/25 = 1.6 = 2
// And if it's faster than that:
// 40/10 = 4
b_rate = qMax(b_rate, qRound(static_cast<float>(message_display_speed[3])/msg_delay));
}
if (blip_ticker % b_rate == 0) {
// ignoring white space unless blank_blip is enabled. // ignoring white space unless blank_blip is enabled.
if (!formatting_char && (f_character != ' ' || blank_blip)) { if (!formatting_char && (f_character != ' ' || blank_blip)) {
blip_player->blip_tick(); blip_player->blip_tick();
@ -2958,9 +2968,10 @@ void Courtroom::chat_tick()
++blip_ticker; ++blip_ticker;
} }
// Punctuation delayer // Punctuation delayer, only kicks in on speed ticks less than }}
if (punctuation_chars.contains(f_character)) { if (current_display_speed > 1 && punctuation_chars.contains(f_character)) {
msg_delay *= punctuation_modifier; // Making the user have to wait any longer than 150ms per letter is downright unreasonable
msg_delay = qMin(150, msg_delay * punctuation_modifier);
} }
// If this color is talking // If this color is talking