encrypt 4 years ago
parent
commit
881905a4b3
1 changed files with 11 additions and 19 deletions
  1. 11 19
      mumble-bot/bot.py

+ 11 - 19
mumble-bot/bot.py

@@ -32,35 +32,27 @@ cursor_time = None
 cursor_time = time.time() - BUFFER
 
 while mumble.is_alive():
-
-    if cursor_time < time.time() - BUFFER:  # it's time to check audio
+    if cursor_time < time.time() - BUFFER: 
         base_sound = None
 
         try:
-            for user in mumble.users.values():  # check the audio queue of each user
-                while ( user.sound.is_sound() and
-                        user.sound.first_sound().time < cursor_time):
-                    user.sound.get_sound(FLOAT_RESOLUTION)  # forget about too old sounds
-                
+            for user in mumble.users.values():  # check the audio queue of each user                
                 if user.sound.is_sound():
-                    if ( user.sound.first_sound().time >= cursor_time and
-                         user.sound.first_sound().time < cursor_time + FLOAT_RESOLUTION ):
-                        # available sound is to be treated now and not later
-                        sound = user.sound.get_sound(FLOAT_RESOLUTION)
-                        stereo_pcm = audioop.tostereo(sound.pcm, 2, 1, 1)
-                        if base_sound == None:
-                            base_sound = stereo_pcm
-                        else:
-                            base_sound = audioop.add(base_sound, stereo_pcm, 2)
+                    # available sound is to be treated now and not later
+                    sound = user.sound.get_sound(FLOAT_RESOLUTION)
+                    stereo_pcm = audioop.tostereo(sound.pcm, 2, 1, 1)
+                    if base_sound == None:
+                        base_sound = stereo_pcm
+                    else:
+                        base_sound = audioop.add(base_sound, stereo_pcm, 2)
         except RuntimeError:
             eprint("ignored exception in stderr...")
             
         if base_sound:
             sys.stdout.buffer.write(base_sound)
         else:
-            sys.stdout.buffer.write(silent)
-            
+            sys.stdout.buffer.write(silent)                        
+
         cursor_time += FLOAT_RESOLUTION
     else:
         time.sleep(FLOAT_RESOLUTION)
-