소스 검색

improve artist shuffle order

Thomas B 8 달 전
부모
커밋
b3fb54bb00
1개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  1. 9
    7
      osci-pi.py

+ 9
- 7
osci-pi.py 파일 보기

@@ -39,7 +39,7 @@ import RPi.GPIO as GPIO
39 39
 from PIL import ImageFont
40 40
 
41 41
 basevol = "70"
42
-debouncems = 200
42
+debouncems = 100
43 43
 
44 44
 #fontfile = "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf"
45 45
 fontfile = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
@@ -81,14 +81,15 @@ def get_artist(fn):
81 81
 
82 82
 #originalsongs = os.listdir(basedir)
83 83
 originalsongs = []
84
-artists = []
84
+originalartists = []
85 85
 for fn in glob.iglob(os.path.join(basedir, '**', '*.wav'), recursive=True):
86 86
     originalsongs.append(fn)
87 87
 
88 88
     artist = get_artist(fn)
89
-    if artist not in artists:
90
-        artists.append(artist)
89
+    if artist not in originalartists:
90
+        originalartists.append(artist)
91 91
 
92
+artists = originalartists.copy()
92 93
 random.shuffle(artists)
93 94
 currentartist = artists[0]
94 95
 
@@ -208,10 +209,11 @@ def switch_artist():
208 209
     global artists
209 210
     global currentartist
210 211
 
211
-    ca = currentartist
212
-    while currentartist == ca:
212
+    if len(artists) <= 0:
213
+        artists = originalartists.copy()
213 214
         random.shuffle(artists)
214
-        currentartist = artists[0]
215
+
216
+    currentartist = artists.pop()
215 217
 
216 218
     switch_track()
217 219
 

Loading…
취소
저장