Skip to content

Commit

Permalink
Adding notes for adding non-gating for SELECTION bias, so the config …
Browse files Browse the repository at this point in the history
…is more strongly felt.
  • Loading branch information
uriel1998 committed Feb 4, 2024
1 parent e6097d9 commit 6d35816
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ means that you can create different instruction files and either copy them to

## 7. TODO

* Check for album artist when artist is not present or empty



* Add loop back in and utilize relay mechanism to change instruction file
* Switch between loop mode and single-run mode
* Add in what to do when all genres run through in logrotate timeperiod
Expand Down
3 changes: 3 additions & 0 deletions mpdq
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ function choose_next_song {
GenreName=""
CurrWeight=""

# need to read in an array of genres to weight; will be its own function
# we could read in an array like we did with the old version, I guess.

#get random number for genre
GenreNumber=$(shuf -i 1-${NUMGENRES} -n 1)
GenreName=$(mpc list genre | head -n ${GenreNumber} | tail -n 1)
Expand Down
80 changes: 80 additions & 0 deletions roadmap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
SCRIPT=$0
InstructionFile=""
DefaultPriority=1
tmp2=$(mktemp)

ModGenre=()
ModValue=()
GenreWeight=()
ChooseGenre=()
SONGLENGTH=10

# initialize choosing array (this will be called from a function, so it can be
# easily added in from relay when we loop the process).
# get default weight
# go through list of genres from mpc/mpd
# is it in our instruction file?
# if not, weight=default
# if so, weight=value from instruction file
# i = 0; while i until $weight;do
# add element to choosing array with GenreName
# done

# in choosing section, get rand# then choose that element. BOSH, done.

ModGenre+=("${IGenre}")





function determine_genre_weights {
#This is not light, but it's only done once a run.
#loop through genre, if not in array ModGenre, then apply DefaultWeight

TotalNumSongs=$(mpc --host $MPD_HOST --port $MPD_PORT listall | wc -l)
for ((i = 0; i < ${#Genre[@]}; i++));do
#determine weight of genre in music directory
if [[ "${MODE}" =~ "song" ]];then
GenreNumSongs[$i]=$(mpc --host $MPD_HOST --port $MPD_PORT find genre "${Genre[$i]}" | wc -l)

GenreSongWeight[$i]=$(printf "%.0f\n" `echo "(${GenreNumSongs[$i]} / $TotalNumSongs)*1000" | bc -l`)
if [ ${GenreSongWeight[$i]} = 0 ];then
GenreSongWeight[$i]=1
fi

for (( i2 = 0; i2 < ${#ModGenre[@]}; i2++ ));do
if [[ "${Genre[$i]}" = "${ModGenre[$i2]}" ]];then
GenreWeight[$i]=$(printf "%.0f\n" `echo "${GenreSongWeight[$i]} * ${ModValue[$i2]}" | bc -l`)
#GenreWeight[$i]=$(echo "${ModValue[$i2]}")
break
else
GenreWeight[$i]=$(printf "%.0f\n" `echo "${GenreSongWeight[$i]} * ${DefaultWeight}" | bc -l`)
fi
done
else # regular weighting without number of songs
for (( i2 = 0; i2 < ${#ModGenre[@]}; i2++ ));do
if [[ "${Genre[$i]}" = "${ModGenre[$i2]}" ]];then
GenreWeight[$i]=$(echo "${ModValue[$i2]}")
fi
done
fi
if [ -z ${GenreWeight[$i]} ];then
GenreWeight[$i]=${DefaultWeight}
fi
loud "${Genre[$i]} - ${GenreWeight[$i]}"
done

#populating the "weighted" array
#add the name GenreWeight times... giving us a sloppy weighting mechanism (and if it's zero, it SHOULD exit before hitting this)
for (( i = 0; i < ${#Genre[@]}; i++));do
if [[ ! -z "${GenreWeight[$i]}" ]];then
for (( i2 = 1; "$i2" <= "${GenreWeight[$i]}"; i2++ ));do
if [ "${GenreWeight[$i]}" != "0" ]; then
ChooseGenre+=("${Genre[$i]}")
fi
done
fi
done
}

0 comments on commit 6d35816

Please sign in to comment.