Changed the way the random indices are chosen

Only the offset is random. The indices are then spaced evenly.
This commit is contained in:
kkapsner 2018-06-30 23:34:59 +02:00
parent b4a8507140
commit 22fda1eac7
2 changed files with 10 additions and 5 deletions

View File

@ -65,16 +65,21 @@
}
function forEachIndex(array, prefs, callback){
var l = array.length;
var length = array.length;
var rate = getAudioFakeRate(array, prefs);
var indexRng = randomSupply.getIndexRng(rate, l, window);
var start = 0;
forEachFixedIndex(prefs, function(index){
callback(index, start);
start += 1;
});
for (var i = start; i < rate; i += 1){
callback(indexRng(i), i);
if (start < rate){
var delta = Math.floor(length / (rate - start));
var indexRng = randomSupply.getIndexRng(1, length - delta * (rate - start - 1), window);
var offset = indexRng(0);
for (var i = start; i < rate; i += 1){
callback(offset, i);
offset += delta;
}
}
}

View File

@ -169,7 +169,7 @@
},
{
name: "audioFakeRate",
defaultValue: "10",
defaultValue: "100",
options: ["1", "10", "100", "1000", "0.1%", "1%"]
},
{