discordrb 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of discordrb might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8edaf61a0d0837db5dd14c5c276d222586752ebe
4
- data.tar.gz: ffe050f90456b21d9ca960e540c2206b60cf8bd1
3
+ metadata.gz: 7c24aa0e70b78435b64e446ed2994c17bc640657
4
+ data.tar.gz: 345f9fd977ea9745702bc63db5060f2ee9967584
5
5
  SHA512:
6
- metadata.gz: 3ff12cfbf0756c5f2d41c807cda2c0c6b27e8835a00b109af02a4bb7f2daf70be5f89774e7bdebf53f1c602749181ae2c1ff6efedf6cb4462d553ad2ab9436dc
7
- data.tar.gz: ad825713c559a666b95c352ae0d3ce23ee77aeacf83b22d100d3d51238a631994e69535f544026102c5aebc9774939dd6ccec709b0a3795595be22125ffbc3fe
6
+ metadata.gz: fa3b3a0572b2888a1501fad97229035f10b3eae029e942b58d28a5e769be1806852a0f7fc964666bd2673bb91a4a29babbe28dae87e898effe1d83596d51c192
7
+ data.tar.gz: 1e8f66d0595dd6064dd0ac211d14fdb835746efed28ace5ee923ec8ca076f010e23ea9bbaf0a0bd1d2d92d2871169fb88d6b4452f256151d0722afb8ffbed9b2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.3
4
+ * Voice bot length adjustments are now configurable using `bot.voice.adjust_interval` and `bot.voice.adjust_offset` (make sure the latter is less than the first, or no adjustment will be performed at all)
5
+ * Length adjustments can now be made more smooth using `bot.voice.adjust_average` (true allows for more smooth adjustments, *may* improve stutteriness but might make it worse as well)
6
+
3
7
  ## 1.5.2
4
8
  * `bot.voice_connect` can now use a channel ID directly.
5
9
  * A reader `bot.volume` now exists for the corresponding writer.
@@ -40,7 +44,7 @@
40
44
  * `Message` now has a useful `to_s` method that just returns the content.
41
45
 
42
46
  ### Bugfixes
43
- * The `TypingEvent` `user` property is now initialized correctly (#29, thanks @purintal)
47
+ * The `TypingEvent` `user` property is now initialized correctly (#29, thanks @purintai)
44
48
 
45
49
  ## 1.4.6
46
50
  *Bugfix-only release.*
@@ -1,4 +1,4 @@
1
1
  # Discordrb and all its functionality, in this case only the version.
2
2
  module Discordrb
3
- VERSION = '1.5.2'
3
+ VERSION = '1.5.3'
4
4
  end
@@ -12,6 +12,7 @@ module Discordrb::Voice
12
12
  # A voice connection consisting of a UDP socket and a websocket client
13
13
  class VoiceBot
14
14
  attr_reader :stream_time, :encoder
15
+ attr_accessor :adjust_interval, :adjust_offset, :adjust_average
15
16
 
16
17
  def initialize(channel, bot, token, session, endpoint)
17
18
  @bot = bot
@@ -20,6 +21,10 @@ module Discordrb::Voice
20
21
 
21
22
  @sequence = @time = 0
22
23
 
24
+ @adjust_interval = 100
25
+ @adjust_offset = 10
26
+ @adjust_average = false
27
+
23
28
  @encoder = Encoder.new
24
29
  @ws.connect
25
30
  end
@@ -91,14 +96,14 @@ module Discordrb::Voice
91
96
 
92
97
  self.speaking = true
93
98
  loop do
94
- break unless @playing
95
- break unless @io
96
-
97
- if count % 100 == 10
99
+ if count % @adjust_interval == @adjust_offset
98
100
  # Starting from the tenth packet, perform length adjustment every 100 packets (2 seconds)
99
101
  @length_adjust = Time.now.nsec
100
102
  end
101
103
 
104
+ break unless @playing
105
+ break unless @io
106
+
102
107
  # Read some data from the buffer
103
108
  buf = nil
104
109
  begin
@@ -135,7 +140,12 @@ module Discordrb::Voice
135
140
  # Difference between length_adjust and now in ms
136
141
  ms_diff = (Time.now.nsec - @length_adjust) / 1_000_000.0
137
142
  if ms_diff >= 0
138
- @length = IDEAL_LENGTH - ms_diff
143
+ if @adjust_average
144
+ @length = (IDEAL_LENGTH - ms_diff + @length) / 2.0
145
+ else
146
+ @length = IDEAL_LENGTH - ms_diff
147
+ end
148
+
139
149
  @bot.debug("Length adjustment: new length #{@length}")
140
150
  end
141
151
  @length_adjust = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discordrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - meew0