aboutsummaryrefslogtreecommitdiff
path: root/app/js/services.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/js/services.js')
-rw-r--r--app/js/services.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/js/services.js b/app/js/services.js
index a7f4eda..622717a 100644
--- a/app/js/services.js
+++ b/app/js/services.js
@@ -31,11 +31,14 @@ app.service('pathService', function() {
//select the songs
var selection = [];
var tuning = .5;
- songListCopy.sort(function(song){
- return (tuning + tuning*Math.random())*song.minDist;}
- );
+ angular.forEach(songListCopy, function(song){
+ song.rand = (tuning + tuning*Math.random())*song.minDist;
+ });
+ songListCopy.sort(function(a,b){return a.rand-b.rand;});
+ //take from the sorted list util we reach the desired duration
while(duration > 0 && songListCopy.length > 0){
var removed = songListCopy.splice(0, 1);
+ console.log(removed[0].minDist);
selection.push(removed[0]);
duration -= 10;
}