infinity-player

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

commit
60ddec6b064493c89aa7d6ee859b322837c24a40
parent
362f475b05f4f2ab701d84137f5c475b34c6f511
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2021-07-04 09:47
rm jumps, use R directly

Diffstat

M player.py 17 ++++-------------

1 files changed, 4 insertions, 13 deletions


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

@@ -115,16 +115,8 @@ def normalize(R, threshold):
  115   115     return R_norm * (R_norm > 0)
  116   116 
  117   117 
  118    -1 def compute_jumps(R):
  119    -1     jumps = []
  120    -1     for row in R:
  121    -1         new_jumps = [(i, p) for i, p in enumerate(row) if p > 0]
  122    -1         jumps.append(sorted(new_jumps, key=lambda ip: -ip[1]))
  123    -1     return jumps
  124    -1 
  125    -1 
  126    -1 def get_next_position(i, jumps):
  127    -1     for j, p in jumps[i]:
   -1   118 def get_next_position(i, R):
   -1   119     for j, p in sorted(enumerate(R[i]), key=lambda jp: -jp[1]):
  128   120         if p > random():
  129   121             return j + 1
  130   122     return i + 1
@@ -162,15 +154,14 @@ def main():
  162   154     y, sample_rate, beat_frames, R = load(args.filename, args.force)
  163   155     R = normalize(R, args.threshold)
  164   156     buffers = compute_buffers(y, beat_frames)
  165    -1     jumps = compute_jumps(R)
  166    -1     jump_count = sum(len(row) for row in jumps)
   -1   157     jump_count = sum(sum(R > 0))
  167   158 
  168   159     print('Detected {} jump opportunities on {} beats'.format(
  169   160         jump_count, len(buffers)
  170   161     ))
  171   162 
  172   163     print('Playing… (Press Ctrl-C to stop)')
  173    -1     play(buffers, sample_rate, jumps)
   -1   164     play(buffers, sample_rate, R)
  174   165 
  175   166 
  176   167 if __name__ == '__main__':