diff options
author | Nicolas Bornand <nicolas74@gmail.com> | 2014-05-11 10:54:55 +0200 |
---|---|---|
committer | Nicolas Bornand <nicolas74@gmail.com> | 2014-05-11 10:54:55 +0200 |
commit | 481dc29aa7225d7aa7a00b2690165245a4065252 (patch) | |
tree | a126488543379874bb1163754ff632f5e4951fa1 /app/js/services.js | |
parent | 64b7faae30bb530b7fb4bd839735e8d4b3d6decb (diff) | |
parent | 9e579f32a7818f78f568089638fdcf8a06f579e6 (diff) | |
download | playGraph-481dc29aa7225d7aa7a00b2690165245a4065252.tar.gz playGraph-481dc29aa7225d7aa7a00b2690165245a4065252.tar.bz2 playGraph-481dc29aa7225d7aa7a00b2690165245a4065252.zip |
Merge origin/master
Conflicts:
app/js/services.js
Diffstat (limited to 'app/js/services.js')
-rw-r--r-- | app/js/services.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/js/services.js b/app/js/services.js index b661da7..79d4c40 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -11,9 +11,11 @@ app.service('pathService', function() { }, computePlaylist: function(songList, constrainList, duration) { //compute distances from the constrain path + var songListCopy = songList.slice(0); var maxDistOverall = Number.MIN_VALUE; angular.forEach(songListCopy, function(song){ + song.selected = false; song.minDist = Number.MAX_VALUE; for(var i=0; i<constrainList.length;i++){ var point = constrainList[i]; @@ -32,17 +34,27 @@ app.service('pathService', function() { var selection = []; var tuning = .5; angular.forEach(songListCopy, function(song){ - song.rand = (tuning + tuning*Math.random())*song.minDist; + 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; + removed[0].selected = true; } + selection.sort(function(a,b){ return a.closestIndex-b.closestIndex;}); + + //clean points + angular.forEach(songList, function(song) { + delete song.minDist; + delete song.closest; + delete song.closestIndex; + delete song.rand; + }); + return selection; } }; |