Browse Source

improve artist shuffle order

Thomas B 10 months ago
parent
commit
b3fb54bb00
1 changed files with 9 additions and 7 deletions
  1. 9
    7
      osci-pi.py

+ 9
- 7
osci-pi.py View File

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

Loading…
Cancel
Save