mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 03:53:07 +00:00
Minor doc fixes in PatternGenerator
This commit is contained in:
parent
205c438511
commit
8949efcd21
1 changed files with 4 additions and 4 deletions
|
@ -117,16 +117,16 @@ function* randomOnce<T>(numValues: number): IterableIterator<number> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Randomly choose to walk up or down 1 index in the values array
|
* Randomly choose to walk up or down 1 index
|
||||||
*/
|
*/
|
||||||
function* randomWalk<T>(numValues: number): IterableIterator<number> {
|
function* randomWalk<T>(numValues: number): IterableIterator<number> {
|
||||||
// randomly choose a starting index in the values array
|
// randomly choose a starting index
|
||||||
let index = Math.floor(Math.random() * numValues);
|
let index = Math.floor(Math.random() * numValues);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
index++; // at bottom of array, so force upward step
|
index++; // at bottom, so force upward step
|
||||||
} else if (index === numValues - 1) {
|
} else if (index === numValues - 1) {
|
||||||
index--; // at top of array, so force downward step
|
index--; // at top, so force downward step
|
||||||
} else if (Math.random() < 0.5) { // else choose random downward or upward step
|
} else if (Math.random() < 0.5) { // else choose random downward or upward step
|
||||||
index--;
|
index--;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue