From 8cc067dee42ede24614f1a7bccef7f8752f56a01 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 11 Sep 2020 22:17:13 +0300 Subject: [PATCH 1/3] More accurate/consistent blip rate functionality inspired by https://youtu.be/Min0hkwO43g --- include/courtroom.h | 2 +- src/courtroom.cpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 5b5ff6c1a..31ab41c6b 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -311,7 +311,7 @@ class Courtroom : public QMainWindow { int real_tick_pos = 0; // used to determine how often blips sound int blip_ticker = 0; - int blip_rate = 1; + int blip_rate = 2; int rainbow_counter = 0; bool rainbow_appended = false; bool blank_blip = false; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 04c625fea..3e00158e5 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2938,11 +2938,23 @@ void Courtroom::chat_tick() ui_vp_message->ensureCursorVisible(); - // Blip player and real tick pos ticker - if (!formatting_char && (f_character != ' ' || blank_blip)) { - if (blip_ticker % blip_rate == 0) { + // We blip every "blip rate" letters. + // Here's an example with blank_blip being false and blip_rate being 2: + // I am you + // ! ! ! ! + // where ! is the blip sound + if (blip_ticker % blip_rate == 0) { + // ignoring white space unless blank_blip is enabled. + if (!formatting_char && (f_character != ' ' || blank_blip)) { blip_player->blip_tick(); + ++blip_ticker; } + } + else + { + // Don't fully ignore whitespace still, keep ticking until + // we reached the need to play a blip sound - we also just + // need to wait for a letter to play it on. ++blip_ticker; } From d00d0769a9bf325df5bb25d7a7a4bd376b539b3c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 11 Sep 2020 23:38:36 +0300 Subject: [PATCH 2/3] 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. --- include/aoblipplayer.h | 3 --- src/aoblipplayer.cpp | 4 ---- src/courtroom.cpp | 19 +++++++++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h index 4d3b5f145..a11e29db1 100644 --- a/include/aoblipplayer.h +++ b/include/aoblipplayer.h @@ -22,12 +22,9 @@ class AOBlipPlayer { int m_cycle = 0; private: - const int max_blip_ms = 60; - QWidget *m_parent; AOApplication *ao_app; qreal m_volume; - QElapsedTimer delay; void set_volume_internal(qreal p_volume); diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 5b4d625cd..6607d4633 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -26,10 +26,6 @@ void AOBlipPlayer::set_blips(QString p_sfx) void AOBlipPlayer::blip_tick() { - if (delay.isValid() && delay.elapsed() < max_blip_ms) - return; - - delay.start(); int f_cycle = m_cycle++; if (m_cycle == 5) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3e00158e5..13a9a6b70 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2943,7 +2943,17 @@ void Courtroom::chat_tick() // I am you // ! ! ! ! // 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(message_display_speed[3])/msg_delay)); + } + if (blip_ticker % b_rate == 0) { // ignoring white space unless blank_blip is enabled. if (!formatting_char && (f_character != ' ' || blank_blip)) { blip_player->blip_tick(); @@ -2958,9 +2968,10 @@ void Courtroom::chat_tick() ++blip_ticker; } - // Punctuation delayer - if (punctuation_chars.contains(f_character)) { - msg_delay *= punctuation_modifier; + // Punctuation delayer, only kicks in on speed ticks less than }} + if (current_display_speed > 1 && punctuation_chars.contains(f_character)) { + // 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 From c392bb3415ca8a01dbfc5129527af25ae6de9c08 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 11 Sep 2020 23:39:32 +0300 Subject: [PATCH 3/3] Revert the meme of instant text. Instant text using }}} is not only meme-worthy in how limited it is in practice, it also makes the blip ticker completely confused how and when to play the blips (to make instant text possible, the entire system needs rewriting (again) --- include/courtroom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/courtroom.h b/include/courtroom.h index 31ab41c6b..38621c824 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -275,7 +275,7 @@ class Courtroom : public QMainWindow { bool message_is_centered = false; int current_display_speed = 3; - int message_display_speed[7] = {0, 10, 25, 40, 50, 70, 90}; + int message_display_speed[7] = {5, 10, 25, 40, 50, 70, 90}; // The character ID of the character this user wants to appear alongside with. int other_charid = -1;