infinity-player

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

commit
f10ad3d5ea7451176238de87d69ce729e18067a4
parent
316582d93af10967a26914c234a59f93319dfd2e
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2017-10-20 17:59
enhance diagonals

Diffstat

M player.py 11 +++++++++++

1 files changed, 11 insertions, 0 deletions


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

@@ -10,6 +10,15 @@ import librosa
   10    10 import numpy
   11    11 
   12    12 
   -1    13 def enhance_diagonals(R, weight=0.2, steps=1):
   -1    14     for i in range(steps):
   -1    15         # combine each cell with its diagonal neighbors
   -1    16         R1 = numpy.roll(R, (1, 1), (0, 1))
   -1    17         R2 = numpy.roll(R, (-1, -1), (0, 1))
   -1    18         R = (weight * (R1 + R2) + (1 - weight) * R) / 2
   -1    19     return R
   -1    20 
   -1    21 
   13    22 def iter_beat_slices(y, beat_frames):
   14    23     beat_samples = librosa.frames_to_samples(beat_frames)
   15    24     yield 0, beat_samples[0]
@@ -58,6 +67,8 @@ def compute_buffers(y, beat_frames):
   58    67 
   59    68 
   60    69 def normalize(R, threshold):
   -1    70     R = enhance_diagonals(R, 0.8, 4)
   -1    71 
   61    72     x_max = R.max()
   62    73     x_min = x_max * threshold
   63    74     y_max = (x_max + 0.5) / 2