- commit
- 133fab3eb0e22993ddc65d11d6b3a78e6fa5c077
- parent
- b279e58680bf8aa3f6f568eb946acb89f9b481a6
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2021-07-04 11:05
print progress
Diffstat
| M | README.md | 3 | --- |
| M | player.py | 17 | +++++++++++++++++ |
2 files changed, 17 insertions, 3 deletions
diff --git a/README.md b/README.md
@@ -28,9 +28,6 @@ Any help would be appreciated 28 28 possible, e.g. to prevent the song from looping through the same part again 29 29 and again. 30 3031 -1 - **Visual Feedback.** The original infinite jukebox has a great UI. This one32 -1 has currently none.33 -134 31 - **No Stereo.** This one is probably not that hard to fix. I just skipped it 35 32 because there were more interesting problems to think about. 36 33
diff --git a/player.py b/player.py
@@ -5,6 +5,7 @@ import argparse 5 5 import gzip 6 6 import os 7 7 import pickle -1 8 import shutil 8 9 9 10 from PIL import Image 10 11 import librosa @@ -17,6 +18,21 @@ with open(os.path.join(BASE_DIR, 'timbre.pickle'), 'rb') as fh: 17 18 TIMBRE_PATTERNS = pickle.load(fh) 18 19 19 20 -1 21 def print_progress(i, n): -1 22 cols, lines = shutil.get_terminal_size() -1 23 pos = i * (cols - 5) // n -1 24 s = '' -1 25 for x in range(cols - 5): -1 26 if x == pos: -1 27 s += '|' -1 28 elif x < pos: -1 29 s += '=' -1 30 else: -1 31 s += '-' -1 32 s += f' {i:>4}' -1 33 print(s, end='\r') -1 34 -1 35 20 36 def enhance_diagonals(jumps, weight=0.2, steps=1): 21 37 for i in range(steps): 22 38 # combine each cell with its diagonal neighbors @@ -130,6 +146,7 @@ def play(buffers, sample_rate, jumps): 130 146 with soundcard.default_speaker().player(samplerate=sample_rate) as sp: 131 147 while True: 132 148 sp.play(buffers[i]) -1 149 print_progress(i, n) 133 150 134 151 i = get_next_position(i, jumps) 135 152 if i >= n: