infinity-player

infinite jukebox clone using librosa
git clone https://git.ce9e.org/infinity-player.git

commit
36d3de7cb8f5b45f426c777eee7f791fd1a5b25b
parent
cc4a251aa7e40ba0f71df200ee11d6a1e44dac20
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2021-07-04 10:06
get_next_position

Diffstat

M player.py 15 ++++++++-------

1 files changed, 8 insertions, 7 deletions


diff --git a/player.py b/player.py

@@ -120,6 +120,13 @@ def compute_jumps(R):
  120   120     return jumps
  121   121 
  122   122 
   -1   123 def get_next_position(i, jumps):
   -1   124     for j, p in jumps[i]:
   -1   125         if p > random():
   -1   126             return j + 1
   -1   127     return i + 1
   -1   128 
   -1   129 
  123   130 def play(buffers, sample_rate, jumps):
  124   131     # https://larsimmisch.github.io/pyalsaaudio/libalsaaudio.html#pcm-objects
  125   132     pcm = alsaaudio.PCM()
@@ -133,13 +140,7 @@ def play(buffers, sample_rate, jumps):
  133   140         data, duration = buffers[i]
  134   141         pcm.write(data)
  135   142 
  136    -1         for j, p in jumps[i]:
  137    -1             if p > random():
  138    -1                 i = j
  139    -1                 break
  140    -1 
  141    -1         i = i + 1
  142    -1 
   -1   143         i = get_next_position(i, jumps)
  143   144         if i >= n:
  144   145             i = 0
  145   146